JBoss Rich Faces SVN: r22703 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify.
by richfaces-svn-commits@lists.jboss.org
Author: jpapouse
Date: 2011-09-12 09:08:15 -0400 (Mon, 12 Sep 2011)
New Revision: 22703
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyMessagesAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyStackAttributes.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/TestRichNotify.java
Log:
RFPL-1635 (notify component):
- changed tests to use better access to attributes
- fixed tests using info message (it lost its unique style class)
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java 2011-09-11 23:57:38 UTC (rev 22702)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java 2011-09-12 13:08:15 UTC (rev 22703)
@@ -28,6 +28,7 @@
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.attributes.Attributes;
/**
* Abstract test case for pages faces/components/notify/
@@ -37,6 +38,21 @@
public abstract class AbstractRichNotifyTest extends AbstractMetamerTest {
/**
+ * attributes for rich:notifyMessages tag
+ */
+ protected final Attributes<NotifyMessagesAttributes> attributesMessages = new Attributes<NotifyMessagesAttributes>(pjq("table.attributes[id$=attributesNotifyMessages]"));
+
+ /**
+ * attributes for rich:notify tag
+ */
+ protected final Attributes<NotifyAttributes> attributesNotify = new Attributes<NotifyAttributes>(pjq("table.attributes[id$=attributesNotify]"));
+
+ /**
+ * attributes for rich:notifyStack tag
+ */
+ protected final Attributes<NotifyStackAttributes> attributesStack = new Attributes<NotifyStackAttributes>(pjq("table.attributes[id$=attributesNotifyStack]"));
+
+ /**
* notify locator which matches on all notifies and messages
*/
protected final JQueryLocator notify = jq("div.rf-ntf");
@@ -149,7 +165,7 @@
* @return number of notifies
*/
protected int getNumberOfNotifies() {
- return selenium.getCount(notify) - (selenium.getCount(notifyError) + selenium.getCount(notifyFatal) + selenium.getCount(notifyInfo) + selenium.getCount(notifyWarn));
+ return selenium.getCount(notify) - (selenium.getCount(notifyError) + selenium.getCount(notifyFatal) /*+ selenium.getCount(notifyInfo)*/ + selenium.getCount(notifyWarn));
}
/**
@@ -174,7 +190,7 @@
final int before = selenium.getCount(message);
selenium.click(pjq("input[id$=produce" + type + "]"));
waitGui
- .failWith("Number of produced messages has been set to <" + expected + "> but <" + selenium.getCount(message) + "> " + type + " messages is present.")
+ .failWith("Number of produced messages has been set to <" + expected + "> but <" + selenium.getCount(message) + "> " + type + " messages is present (" + message.getRawLocator() + ").")
.until(countEquals.locator(message).count(expected + before));
}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyAttributes.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyAttributes.java 2011-09-12 13:08:15 UTC (rev 22703)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richNotify;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public enum NotifyAttributes implements AttributeEnum {
+
+ delay,
+ rendered,
+ showCloseButton,
+ showHistory,
+ stayTime,
+ sticky,
+ styleClass
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyMessagesAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyMessagesAttributes.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyMessagesAttributes.java 2011-09-12 13:08:15 UTC (rev 22703)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richNotify;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public enum NotifyMessagesAttributes implements AttributeEnum {
+
+ delay,
+ rendered,
+ showCloseButton,
+ showDetail,
+ showHistory,
+ stayTime,
+ sticky,
+ styleClass
+
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyStackAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyStackAttributes.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyStackAttributes.java 2011-09-12 13:08:15 UTC (rev 22703)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010-2011, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richNotify;
+
+import org.richfaces.tests.metamer.ftest.attributes.AttributeEnum;
+
+/**
+ * @author <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public enum NotifyStackAttributes implements AttributeEnum {
+
+ rendered,
+ styleClass
+
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/TestRichNotify.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/TestRichNotify.java 2011-09-11 23:57:38 UTC (rev 22702)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/TestRichNotify.java 2011-09-12 13:08:15 UTC (rev 22703)
@@ -60,7 +60,7 @@
public void init() {
messages.put("Error", notifyError);
messages.put("Fatal", notifyFatal);
- messages.put("Info", notifyInfo);
+// messages.put("Info", notifyInfo);
messages.put("Warn", notifyWarn);
}
@@ -72,10 +72,7 @@
@Test
public void testAttributeDelay() {
// set the delay to <1000>
- JQueryLocator attribute = pjq("input[id$='attributesNotify:delayInput']");
- selenium.type(attribute, "1000");
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.delay, 1000);
// wait for <500>
delay(500);
assertFalse(selenium.isElementPresent(notify), "The delay is set to 1000 and after some little waiting the notify shouldn't be present.");
@@ -87,16 +84,14 @@
@Test
public void testAttributeRendered() {
// set the rendered to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotify:rendered'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.rendered, false);
assertFalse(selenium.isElementPresent(notify), "The attribute rendered is set to <false> but the notify is still present.");
}
@Test
public void testAttributeShowCloseButton() {
// set the showCloseButton to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotify:showCloseButtonInput'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.showCloseButton, false);
assertTrue(selenium.getStyle(getCloseButton(notify), new CssProperty("visibility")).contains("hidden"), "The showCloseButton is set to <false> and therefore the close button shouldn't be displayed.");
}
@@ -105,8 +100,7 @@
// check whether the history is not present (showHistory is set to <false>)
assertFalse(selenium.isElementPresent(notifyHistory), "The showHistory is set to <false> and there shouldn't be any history menu.");
// set the showHistory to <true>
- selenium.click(pjq("input[type=radio][name*='attributesNotify:showHistory'][value=true]"));
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.showHistory, true);
assertTrue(selenium.isElementPresent(notifyHistory), "The showHistory is set to <true> and one notify is present, but there is no history menu.");
close(notify);
produceMessage(notifyError, "Error", 1);
@@ -145,10 +139,7 @@
delay(1000);
assertTrue(selenium.isElementPresent(notify), "The stayTime is set to very high number and after some little delay the notify is not present.");
// set the stayTime to <500>
- JQueryLocator attribute = pjq("input[name*='attributesNotify:stayTime']");
- selenium.type(attribute, "500");
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.stayTime, 500);
produceMessage(notifyError, "Error", 1);
close(notifyError);
// wait for <1000>
@@ -159,13 +150,9 @@
@Test
public void testAttributeSticky() {
// set the stayTime to <0>
- JQueryLocator stayTime = pjq("input[name*='attributesNotify:stayTime']");
- selenium.type(stayTime, "0");
- selenium.fireEvent(stayTime, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.stayTime, 0);
// set the sticky to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotify:sticky'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.sticky, false);
waitGui
.failWith("The stayTime is set to <0> and sticky to <false>, so the notify shouldn't be present.")
.until(NegationCondition.getInstance().condition(elementPresent.locator(notify)));
@@ -178,9 +165,7 @@
.failWith("The stayTime is set to <0> and sticky to <false>, so the notify shouldn't be present.")
.until(NegationCondition.getInstance().condition(elementPresent.locator(notify)));
// set the sticky to <true>
- selenium.click(pjq("input[type=radio][name*='attributesNotify:sticky'][value=true]"));
- selenium.waitForPageToLoad();
- delay(500);
+ attributesNotify.set(NotifyAttributes.sticky, true);
waitGui
.failWith("The stayTime is set to <0> and sticky to <true>, so the notify should be present.")
.until(elementPresent.locator(notify));
@@ -191,7 +176,7 @@
close(messages.get(type));
}
waitModel
- .failWith("The stayTime is set to <0> and sticky to <true>, so the notify shouldn't be present.")
+ .failWith("The stayTime is set to <0> and sticky to <true>, so the notifies should be present.")
.until(new SeleniumCondition() {
@Override
public boolean isTrue() {
@@ -202,18 +187,14 @@
@Test
public void testAttributeStyleClass() {
- selenium.type(pjq("input[name*='attributesNotify:styleClassInput']"), "someStyleClass");
- selenium.waitForPageToLoad();
+ attributesNotify.set(NotifyAttributes.styleClass, "someStyleClass");
assertTrue(selenium.belongsClass(notify, "someStyleClass"), "The cssStyle has been set but notify doesn't belong to the set class.");
}
@Test
public void testAttributeMessagesDelay() {
// set the delay to <1000>
- JQueryLocator attribute = pjq("input[id$='attributesNotifyMessages:delayInput']");
- selenium.type(attribute, "1000");
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.delay, 1000);
// check the delay for each message type
for(String type : messages.keySet()) {
selenium.click(pjq("input[id$=produce" + type + "]"));
@@ -227,8 +208,7 @@
@Test
public void testAttributeMessagesRendered() {
// set the rendered to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:rendered'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.rendered, false);
// check the message isn't displayed for each message type
for(String type : messages.keySet()) {
String before = selenium.getText(jq("span[id=requestTime]"));
@@ -241,8 +221,7 @@
@Test(enabled=false)
public void testAttributeMessagesShowCloseButton() {
// set the showCloseButton to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:showCloseButtonInput'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.showCloseButton, false);
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
assertTrue(selenium.getStyle(jq(messages.get(type) + " > div.rf-ntf-co > div.rf-ntf-cls"), new CssProperty("visibility")).contains("hidden"), "The showCloseButton is set to <false> and therefore the close button shouldn't be displayed.");
@@ -272,8 +251,7 @@
close(notify);
assertFalse(selenium.isElementPresent(notifyHistory), "The showHistory is set to <false> and there shouldn't be any history menu.");
// set the showHistory to <true>
- selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:showHistory'][value=true]"));
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.showHistory, true);
// check whether the history isn't displayed (there is no message in the history)
assertFalse(selenium.isElementPresent(notifyHistory), "The showHistory is set to <true>, but there is no message, so there shouldn't be any history menu.");
// produce messages and close them
@@ -318,10 +296,7 @@
close(messages.get(type));
}
// set the stayTime to <500>
- JQueryLocator attribute = pjq("input[name*='attributesNotifyMessages:stayTime']");
- selenium.type(attribute, "500");
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.stayTime, 500);
// produce messages and check whether the stay less then 1000 ms
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
@@ -333,13 +308,9 @@
@Test
public void testAttributeMessagesSticky() {
// set the stayTime to <0>
- JQueryLocator stayTime = pjq("input[name*='attributesNotifyMessages:stayTime']");
- selenium.type(stayTime, "0");
- selenium.fireEvent(stayTime, Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.stayTime, 0);
// set the sticky to <false>
- selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:sticky'][value=false]"));
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.sticky, false);
// produce messages and check whether they disappear quickly
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
@@ -366,8 +337,7 @@
@Test
public void testAttributeMessagesStyleClass() {
- selenium.type(pjq("input[name*='attributesNotifyMessages:styleClassInput']"), "someStyleClass");
- selenium.waitForPageToLoad();
+ attributesMessages.set(NotifyMessagesAttributes.styleClass, "someStyleClass");
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
assertTrue(selenium.belongsClass(messages.get(type), "someStyleClass"), "The cssStyle has been set but " + type + " message doesn't belong to the set class.");
@@ -375,23 +345,19 @@
}
@Test
- public void testAttributeStackStyleClass() {
- JQueryLocator attribute = pjq("input[name*='attributesNotifyStack:styleClass']");
- selenium.type(attribute, "someNiceStyleClass");
- selenium.fireEvent(attribute, Event.BLUR);
- selenium.waitForPageToLoad();
- assertTrue(selenium.belongsClass(notifyStack, "someNiceStyleClass"));
- }
-
- @Test
public void testAttributeStackRendered() {
// set the rendered to <false>
- selenium.click(pjq("input[name*='attributesNotifyStack:rendered']"));
- selenium.waitForPageToLoad();
+ attributesStack.set(NotifyStackAttributes.rendered, false);
assertFalse(selenium.isElementPresent(notifyStack), "The attribute rendered is set to <false> but messages in the notify stack are still present.");
}
@Test
+ public void testAttributeStackStyleClass() {
+ attributesStack.set(NotifyStackAttributes.styleClass, "someNiceStyleClass");
+ assertTrue(selenium.belongsClass(notifyStack, "someNiceStyleClass"));
+ }
+
+ @Test
public void testInit() {
assertTrue(selenium.isElementPresent(notify), "There is no notify message after page is loaded.");
assertEquals(selenium.getText(getDetail(notify)), RichNotifyBean.DEFAULT_DETAIL, "The notify detail doesn't match.");