Author: jpapouse
Date: 2011-10-20 05:35:37 -0400 (Thu, 20 Oct 2011)
New Revision: 22831
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyTestAttributes.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:
fixing tests for notify component
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-10-20
09:00:54 UTC (rev 22830)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java 2011-10-20
09:35:37 UTC (rev 22831)
@@ -53,6 +53,11 @@
protected final Attributes<NotifyStackAttributes> attributesStack = new
Attributes<NotifyStackAttributes>(pjq("table.attributes[id$=attributesNotifyStack]"));
/**
+ * attributes for test
+ */
+ protected final Attributes<NotifyTestAttributes> attributesTest = new
Attributes<NotifyTestAttributes>(pjq("table.attributes[id$=attributesBean]"));
+
+ /**
* notify locator which matches on all notifies and messages
*/
protected final JQueryLocator notify = jq("div.rf-ntf");
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyTestAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyTestAttributes.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/NotifyTestAttributes.java 2011-10-20
09:35:37 UTC (rev 22831)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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 NotifyTestAttributes implements AttributeEnum {
+
+ messageCount,
+ messageDetail,
+ messageText
+
+}
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-10-20
09:00:54 UTC (rev 22830)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richNotify/TestRichNotify.java 2011-10-20
09:35:37 UTC (rev 22831)
@@ -32,12 +32,11 @@
import java.util.Map;
import org.jboss.test.selenium.css.CssProperty;
-import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.NegationCondition;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.bean.rich.RichNotifyBean;
-import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.richfaces.tests.metamer.ftest.annotations.RegressionTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -105,52 +104,33 @@
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);
- close(notify);
- close(notify);
// click on the All button in history menu
selenium.click(notifyHistoryAll);
- waitModel
- .failWith("After clicking on <All> in history menu there should be
all notifies. Expected <2>, found <" + getNumberOfNotifies() +
">")
- .until(new SeleniumCondition() {
- @Override
- public boolean isTrue() {
- return getNumberOfNotifies() == 2;
- }
- });
+ waitGui
+ .failWith("After clicking on <All> in history menu there should be
all notifies.")
+ .until(elementPresent.locator(notify));
close(notify);
- close(notify);
// click on the Last button in the history menu
selenium.click(notifyHistoryLast);
waitModel
- .failWith("After clicking on <Last> in history menu there should
be last notify. Expected <1>, found <" + getNumberOfNotifies() +
">")
- .until(new SeleniumCondition() {
- @Override
- public boolean isTrue() {
- return getNumberOfNotifies() == 1;
- }
- });
+ .failWith("After clicking on <Last> in history menu there should
be last notify.")
+ .until(elementPresent.locator(notify));
}
@Test
public void testAttributesStayTime() {
// stayTime is set to a very high number
- close(notify);
- produceMessage(notifyError, "Error", 1);
- close(notifyError);
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>
attributesNotify.set(NotifyAttributes.stayTime, 500);
- produceMessage(notifyError, "Error", 1);
- close(notifyError);
// wait for <1000>
delay(1000);
assertFalse(selenium.isElementPresent(notify), "The stayTime is set to 500
but after some delay the notify is still present.");
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11433")
+ @RegressionTest("https://issues.jboss.org/browse/RF-11433")
public void testAttributeSticky() {
// set the stayTime to <0>
attributesNotify.set(NotifyAttributes.stayTime, 0);
@@ -159,7 +139,7 @@
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)));
- // produce messages and notifies and close messages
+ // produce messages and close them
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
close(messages.get(type));
@@ -172,20 +152,14 @@
waitGui
.failWith("The stayTime is set to <0> and sticky to <true>,
so the notify should be present.")
.until(elementPresent.locator(notify));
- closeAll(notify);
- // produce messages and notifies and close messages
+ // produce messages and close them
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
close(messages.get(type));
}
- waitModel
- .failWith("The stayTime is set to <0> and sticky to <true>,
so the notifies should be present.")
- .until(new SeleniumCondition() {
- @Override
- public boolean isTrue() {
- return selenium.getCount(notify) == messages.size();
- }
- });
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to <true>,
so the notify should be present.")
+ .until(elementPresent.locator(notify));
}
@Test
@@ -251,17 +225,16 @@
@Test
public void testAttributeMessagesShowHistory() {
// check whether the history isn't present (showHistory is set to
<false>)
- 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>
attributesMessages.set(NotifyMessagesAttributes.showHistory, true);
+ close(notify);
// 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
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
- close(notify);
- close(notify);
+ close(messages.get(type));
}
// click on All button in the history menu
selenium.click(notifyHistoryAll);
@@ -361,21 +334,21 @@
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11433")
+ @RegressionTest("https://issues.jboss.org/browse/RF-11433")
public void testCloseAndProduceNotify() {
// check closing the notify
close(notify);
waitGui
.failWith("After closing notify message the message is stil
present.")
.until(NegationCondition.getInstance().condition(elementPresent.locator(notify)));
- // check producing notifies
+ // check notify is not produced
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
close(messages.get(type));
}
waitGui
- .failWith("After producing messages the correct number of notifies
isn't present. Expected <" + messages.size() + ">, was <" +
selenium.getCount(notify) + ">")
- .until(countEquals.locator(notify).count(messages.size()));
+ .failWith("After producing messages there should be no notify. Expected
<0>, was <" + selenium.getCount(notify) + ">")
+ .until(countEquals.locator(notify).count(0));
}
@Test
@@ -387,19 +360,16 @@
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11433")
+ @RegressionTest("https://issues.jboss.org/browse/RF-11433")
public void testProduceMoreMessages() {
// set the messageCount to <testedNumber>
int testedNumber = 3;
- selenium.type(pjq("input[name*=messageCountInput]"), testedNumber +
"");
- selenium.fireEvent(pjq("input[name*=messageCountInput]"), Event.BLUR);
- selenium.waitForPageToLoad();
+ attributesTest.set(NotifyTestAttributes.messageCount, testedNumber);
close(notify);
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, testedNumber);
- assertEquals(getNumberOfNotifies(), 1, "Number of produced messages has
been set to <" + testedNumber + "> but number of notifies should be still
<1>.");
+ assertEquals(getNumberOfNotifies(), 0, "Number of produced messages has
been set to <" + testedNumber + "> but number of notifies should be still
<0>.");
closeAll(messages.get(type));
- close(notify);
}
}
}