From richfaces-svn-commits at lists.jboss.org Mon Aug 8 04:23:11 2011
Content-Type: multipart/mixed; boundary="===============3217093821466504460=="
MIME-Version: 1.0
From: richfaces-svn-commits at lists.jboss.org
To: richfaces-svn-commits at lists.jboss.org
Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r22597 - in
modules/tests/metamer/trunk/ftest-source/src/main/java/org:
richfaces/tests/metamer/ftest and 1 other directories.
Date: Mon, 08 Aug 2011 04:23:10 -0400
Message-ID: <201108080823.p788NACU010632@svn01.web.mwc.hst.phx2.redhat.com>
--===============3217093821466504460==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: jpapouse
Date: 2011-08-08 04:23:10 -0400 (Mon, 08 Aug 2011)
New Revision: 22597
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/se=
lenium/waiting/NegationCondition.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes=
ts/metamer/ftest/richNotify/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes=
ts/metamer/ftest/richNotify/AbstractRichNotifyTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes=
ts/metamer/ftest/richNotify/TestRichNotify.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes=
ts/metamer/ftest/richNotify/TestRichNotifyMoreStacks.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes=
ts/metamer/ftest/richNotify/TestRichNotifyValidation.java
Log:
selenium tests for rich:notify (containing some unstable tests)
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/tes=
t/selenium/waiting/NegationCondition.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/s=
elenium/waiting/NegationCondition.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/s=
elenium/waiting/NegationCondition.java 2011-08-08 08:23:10 UTC (rev 22597)
@@ -0,0 +1,66 @@
+/*************************************************************************=
******
+ * 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.jboss.test.selenium.waiting;
+
+import org.apache.commons.lang.Validate;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
+
+/**
+ * Condition that verifies that the given condition doesn't hold.
+ *
+ * @author Jan Papousek
+ */
+public class NegationCondition implements SeleniumCondition, JavaScriptCon=
dition{
+
+ private SeleniumCondition condition;
+ =
+ /**
+ * Factory method.
+ * =
+ * @return single instance of NegationCondition
+ */
+ public static NegationCondition getInstance() {
+ return new NegationCondition();
+ } =
+ =
+ public NegationCondition condition(SeleniumCondition condition) {
+ Validate.notNull(condition);
+ NegationCondition copy =3D new NegationCondition();
+ copy.condition =3D condition;
+ return copy;
+ }
+ =
+ @Override
+ public JavaScript getJavaScriptCondition() {
+ if (!(condition instanceof JavaScriptCondition)) {
+ throw new IllegalStateException("The given condition doesn't i=
mplement JavaScriptCondition so its negation can't be converted to the Java=
Script.");
+ }
+ return new JavaScript("!(" + ((JavaScriptCondition) condition).get=
JavaScriptCondition().getAsString() + ")");
+ }
+
+ @Override
+ public boolean isTrue() {
+ return !condition.isTrue();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces=
/tests/metamer/ftest/richNotify/AbstractRichNotifyTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/AbstractRichNotifyTest.java =
(rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/AbstractRichNotifyTest.java 2011-08-08 08:23:1=
0 UTC (rev 22597)
@@ -0,0 +1,181 @@
+/*************************************************************************=
******
+ * 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 static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+
+/**
+ * Abstract test case for pages faces/components/notify/
+ * =
+ * @author Jan Papousek
+ */
+public abstract class AbstractRichNotifyTest extends AbstractMetamerTest {
+
+ /**
+ * notify locator which matches on all notifies and messages
+ */
+ protected final JQueryLocator notify =3D jq("div.rf-ntf");
+ =
+ /**
+ * error message locator
+ */
+ protected final JQueryLocator notifyError =3D jq("div.rf-ntf-error");
+ =
+ /**
+ * fatal message locator
+ */
+ protected final JQueryLocator notifyFatal =3D jq("div.rf-ntf-fatal");
+ =
+ /**
+ * history of notifies and notify messages
+ */
+ protected final JQueryLocator notifyHistory =3D jq("div.rf-ntf-hstr-hd=
r");
+ =
+ /**
+ * 'all' button in the history menu
+ */
+ protected final JQueryLocator notifyHistoryAll =3D jq("button.rf-ntf-h=
str-all");
+ =
+ /**
+ * 'last' button in the history menu
+ */
+ protected final JQueryLocator notifyHistoryLast =3D jq("button.rf-ntf-=
hstr-last");
+ =
+ /**
+ * info message locator
+ */
+ protected final JQueryLocator notifyInfo =3D jq("div.rf-ntf-info");
+ =
+ /**
+ * warn message locator
+ */
+ protected final JQueryLocator notifyWarn =3D jq("div.rf-ntf-warn");
+ =
+ /**
+ * It closes a message defined by the given locator
+ * =
+ * @param locator the message locator
+ */
+ protected void close(final JQueryLocator locator) {
+ final int before =3D selenium.getCount(locator);
+ selenium.click(getFirstCloseButton(locator));
+ waitGui
+ .failWith("Message " + locator.getRawLocator() + " can't be cl=
osed.")
+ .until(countEquals.locator(locator).count(before - 1));
+ } =
+ =
+ /**
+ * It closes all message defined by the given locator
+ * =
+ * @param locator the message locator
+ */
+ protected void closeAll(final JQueryLocator locator) {
+ while(selenium.isElementPresent(locator)) {
+ close(locator);
+ }
+ }
+ =
+ /**
+ * It delays for the given number of ms. If there is any exception thr=
own, it's logged by logger of this class.
+ * =
+ * @param ms number of miliseconds
+ */
+ protected void delay(int ms) {
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e) {
+ Logger.getLogger(getClass().getName()).log(Level.WARNING, e.to=
String());
+ } =
+ } =
+ =
+ /**
+ * It returns a close button of a message defined by the given locator
+ * =
+ * @param message the message locator
+ * @return the close button locator
+ */
+ protected JQueryLocator getCloseButton(JQueryLocator message) {
+ return jq(message.getRawLocator() + " > div.rf-ntf-cnt > div.rf-nt=
f-cls > span.rf-ntf-cls-ico");
+ }
+ =
+ /**
+ * It returns a detail element of a message defined by the given locat=
or
+ * =
+ * @param message the message locator
+ * @return the detail locator
+ */
+ protected JQueryLocator getDetail(JQueryLocator message) {
+ return jq(notify.getRawLocator() + " > div.rf-ntf-cnt > div.rf-ntf=
-txt");
+ }
+ =
+ /**
+ * It returns the first available close button of a message defined by=
the given locator
+ * =
+ * @param message the message locator
+ * @return the close button locator
+ */
+ protected JQueryLocator getFirstCloseButton(JQueryLocator message) {
+ return jq(getCloseButton(message).getRawLocator() + ":first");
+ }
+ =
+ /**
+ * It returns a number of notifes (only notifies, not messages) in the=
given stack.
+ * =
+ * @return number of notifies
+ */
+ protected int getNumberOfNotifies() {
+ return selenium.getCount(notify) - (selenium.getCount(notifyError)=
+ selenium.getCount(notifyFatal) + selenium.getCount(notifyInfo) + seleniu=
m.getCount(notifyWarn));
+ }
+ =
+ /**
+ * It returns a summary element of a message defined by the given loca=
tor
+ * =
+ * @param message the message locator
+ * @return the summary locator
+ */ =
+ protected JQueryLocator getSummary(JQueryLocator message) {
+ return jq(notify.getRawLocator() + " > div.rf-ntf-cnt > div.rf-ntf=
-tl");
+ }
+ =
+ /**
+ * It produces a message defined by the given message locator and the =
given type.
+ * It waits until the number of message is produced.
+ * =
+ * @param message the message locator
+ * @param type the name of the message type (started with capital lett=
er)
+ * @param expected expected number of produced messages
+ */
+ protected void produceMessage(final JQueryLocator message, String type=
, final int expected) {
+ final int before =3D selenium.getCount(message);
+ selenium.click(pjq("input[id$=3Dproduce" + type + "]"));
+ waitGui
+ .failWith("Number of produced messages has been set to <" + ex=
pected + "> but <" + selenium.getCount(message) + "> " + type + " messages =
is present.")
+ .until(countEquals.locator(message).count(expected + before));=
=
+ } =
+ =
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces=
/tests/metamer/ftest/richNotify/TestRichNotify.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotify.java (r=
ev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotify.java 2011-08-08 08:23:10 UTC (r=
ev 22597)
@@ -0,0 +1,441 @@
+/*************************************************************************=
******
+ * 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 static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertEquals;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for pages faces/components/notify/simple.xhtml
+ * =
+ * @author Jan Papousek
+ */
+public class TestRichNotify extends AbstractRichNotifyTest {
+
+ /**
+ * notify stack locator
+ */
+ private JQueryLocator notifyStack =3D jq("div.rf-ntf");
+ =
+ /**
+ * Map containing locators of all tested messages. Type of the message=
is a key in the map. =
+ */
+ private Map messages =3D new HashMap();
+ =
+ @BeforeClass
+ public void init() {
+ messages.put("Error", notifyError);
+ messages.put("Fatal", notifyFatal);
+ messages.put("Info", notifyInfo);
+ messages.put("Warn", notifyWarn);
+ }
+ =
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richNotify/simple.x=
html");
+ }
+
+ @Test
+ public void testAttributeDelay() {
+ // set the delay to <1000>
+ JQueryLocator attribute =3D pjq("input[id$=3D'attributesNotify:del=
ayInput']");
+ selenium.type(attribute, "1000");
+ selenium.fireEvent(attribute, Event.BLUR);
+ selenium.waitForPageToLoad();
+ // wait for <500>
+ delay(500);
+ assertFalse(selenium.isElementPresent(notify), "The delay is set t=
o 1000 and after some little waiting the notify shouldn't be present.");
+ // wait for <1000>
+ delay(1000);
+ assertTrue(selenium.isElementPresent(notify), "The delay is set to=
1000 and after some waiting the notify should be present.");
+ }
+
+ @Test
+ public void testAttributeRendered() {
+ // set the rendered to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotify:=
rendered'][value=3Dfalse]"));
+ selenium.waitForPageToLoad();
+ assertFalse(selenium.isElementPresent(notify), "The attribute rend=
ered is set to but the notify is still present.");
+ }
+
+ @Test
+ public void testAttributeShowCloseButton() {
+ // set the showCloseButton to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotify:=
showCloseButtonInput'][value=3Dfalse]"));
+ selenium.waitForPageToLoad(); =
+ assertTrue(selenium.getStyle(getCloseButton(notify), new CssProper=
ty("visibility")).contains("hidden"), "The showCloseButton is set to and therefore the close button shouldn't be displayed.");
+ }
+
+ @Test
+ public void testAttributeShowHistory() {
+ // check whether the history is not present (showHistory is set to=
)
+ assertFalse(selenium.isElementPresent(notifyHistory), "The showHis=
tory is set to and there shouldn't be any history menu.");
+ // set the showHistory to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotify:=
showHistory'][value=3Dtrue]"));
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.isElementPresent(notifyHistory), "The showHist=
ory is set to and one notify is present, but there is no history men=
u.");
+ 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 in history menu there shoul=
d be all notifies. Expected <2>, found <" + getNumberOfNotifies() + ">")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return getNumberOfNotifies() =3D=3D 2;
+ }
+ });
+ close(notify);
+ close(notify);
+ // click on the Last button in the history menu
+ selenium.click(notifyHistoryLast);
+ waitModel
+ .failWith("After clicking on in history menu there shou=
ld be last notify. Expected <1>, found <" + getNumberOfNotifies() + ">")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return getNumberOfNotifies() =3D=3D 1;
+ }
+ }); =
+ } =
+ =
+ @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>
+ JQueryLocator attribute =3D pjq("input[name*=3D'attributesNotify:s=
tayTime']");
+ selenium.type(attribute, "500");
+ selenium.fireEvent(attribute, Event.BLUR);
+ selenium.waitForPageToLoad();
+ produceMessage(notifyError, "Error", 1);
+ close(notifyError);
+ // wait for <1000>
+ delay(1000);
+ assertFalse(selenium.isElementPresent(notify), "The stayTime is se=
t to 500 but after some delay the notify is still present.");
+ }
+ =
+ @Test
+ public void testAttributeSticky() {
+ // set the stayTime to <0>
+ JQueryLocator stayTime =3D pjq("input[name*=3D'attributesNotify:st=
ayTime']"); =
+ selenium.type(stayTime, "0");
+ selenium.fireEvent(stayTime, Event.BLUR);
+ selenium.waitForPageToLoad();
+ // set the sticky to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotify:=
sticky'][value=3Dfalse]"));
+ selenium.waitForPageToLoad();
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to , s=
o the notify shouldn't be present.")
+ .until(NegationCondition.getInstance().condition(elementPresen=
t.locator(notify)));
+ // produce messages and notifies and close messages
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ close(messages.get(type));
+ }
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to , s=
o the notify shouldn't be present.")
+ .until(NegationCondition.getInstance().condition(elementPresen=
t.locator(notify))); =
+ // set the sticky to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotify:=
sticky'][value=3Dtrue]"));
+ selenium.waitForPageToLoad();
+ delay(500);
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to , so=
the notify should be present.")
+ .until(elementPresent.locator(notify));
+ closeAll(notify);
+ // produce messages and notifies and close messages
+ 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 , so=
the notify shouldn't be present.")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return selenium.getCount(notify) =3D=3D messages.size(=
);
+ }
+ }); =
+ }
+ =
+ @Test
+ public void testAttributeStyleClass() {
+ selenium.type(pjq("input[name*=3D'attributesNotify:styleClassInput=
']"), "someStyleClass");
+ selenium.waitForPageToLoad();
+ assertTrue(selenium.belongsClass(notify, "someStyleClass"), "The c=
ssStyle has been set but notify doesn't belong to the set class.");
+ }
+ =
+ @Test
+ public void testAttributeMessagesDelay() {
+ // set the delay to <1000>
+ JQueryLocator attribute =3D pjq("input[id$=3D'attributesNotifyMess=
ages:delayInput']");
+ selenium.type(attribute, "1000");
+ selenium.fireEvent(attribute, Event.BLUR);
+ selenium.waitForPageToLoad();
+ // check the delay for each message type
+ for(String type : messages.keySet()) {
+ selenium.click(pjq("input[id$=3Dproduce" + type + "]"));
+ delay(500);
+ assertFalse(selenium.isElementPresent(messages.get(type)), "Th=
e delay is set to 1000 and after some little waiting the " + type + " messa=
ge shouldn't be present.");
+ delay(1000);
+ assertTrue(selenium.isElementPresent(messages.get(type)), "The=
delay is set to 1000 and after some waiting the " + type + " message shoul=
d be present.");
+ }
+ }
+ =
+ @Test
+ public void testAttributeMessagesRendered() {
+ // set the rendered to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:rendered'][value=3Dfalse]"));
+ selenium.waitForPageToLoad();
+ // check the message isn't displayed for each message type
+ for(String type : messages.keySet()) {
+ String before =3D selenium.getText(jq("span[id=3DrequestTime]"=
));
+ selenium.click(pjq("input[id$=3Dproduce" + type + "]"));
+ waitGui.until(NegationCondition.getInstance().condition(textEq=
uals.locator(jq("span[id=3DrequestTime]")).text(before)));
+ assertFalse(selenium.isElementPresent(messages.get(type)), "Th=
e attribute rendered is set to but the " + type + " message is stil=
l present.");
+ } =
+ }
+ =
+ @Test(enabled=3Dfalse)
+ public void testAttributeMessagesShowCloseButton() {
+ // set the showCloseButton to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:showCloseButtonInput'][value=3Dfalse]"));
+ selenium.waitForPageToLoad(); =
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ assertTrue(selenium.getStyle(jq(messages.get(type) + " > div.r=
f-ntf-co > div.rf-ntf-cls"), new CssProperty("visibility")).contains("hidde=
n"), "The showCloseButton is set to and therefore the close button =
shouldn't be displayed.");
+ }
+ }
+
+ @Test(enabled=3Dfalse)
+ public void testAttributeMessagesShowDetail() {
+ // produce messages and check whether the detail isn't displayed (=
showDetail is set to )
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ // FIXME:
+ assertTrue(selenium.getStyle(jq(messages.get(type) + " > div.r=
f-ny-co > div.rf-ny-te"), new CssProperty("display")).contains("none"));
+ } =
+ // set showDetail to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:showDetail'][value=3Dtrue]"));
+ selenium.waitForPageToLoad();
+ for(String type : messages.keySet()) {
+ // FIXME:
+ assertFalse(selenium.getStyle(jq(messages.get(type) + " > div.=
rf-ny-co > div.rf-ny-te"), new CssProperty("display")).contains("none"));
+ } =
+ }
+ =
+ @Test
+ public void testAttributeMessagesShowHistory() {
+ // check whether the history isn't present (showHistory is set to =
) =
+ close(notify);
+ assertFalse(selenium.isElementPresent(notifyHistory), "The showHis=
tory is set to and there shouldn't be any history menu.");
+ // set the showHistory to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:showHistory'][value=3Dtrue]"));
+ selenium.waitForPageToLoad(); =
+ // check whether the history isn't displayed (there is no message =
in the history)
+ assertFalse(selenium.isElementPresent(notifyHistory), "The showHis=
tory is set to , but there is no message, so there shouldn't be any h=
istory menu.");
+ // produce messages and close them
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ close(notify);
+ close(notify);
+ }
+ // click on All button in the history menu
+ selenium.click(notifyHistoryAll);
+ final int expected =3D messages.size();
+ waitModel
+ .failWith("After clicking on in history menu there shoul=
d be all messages. Expected <" + expected + ">, found <" + selenium.getCoun=
t(notify) + ">")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return selenium.getCount(notify) =3D=3D expected;
+ }
+ }); =
+ for(int i=3D0; i in history menu there shou=
ld be last message. Expected <1>, found <" + selenium.getCount(notify) + "=
>")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return selenium.getCount(notify) =3D=3D 1;
+ }
+ }); =
+ }
+ =
+ @Test
+ public void testAttributeMessagesStayTime() {
+ // produce messages and check whether the stay at least 1000 ms (s=
tayTime is set to a very high number)
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ delay(1000);
+ assertTrue(selenium.isElementPresent(messages.get(type)), "The=
stayTime is set to very high number and after some little delay the " + ty=
pe + " message is not present.");
+ close(messages.get(type));
+ }
+ // set the stayTime to <500>
+ JQueryLocator attribute =3D pjq("input[name*=3D'attributesNotifyMe=
ssages:stayTime']");
+ selenium.type(attribute, "500");
+ selenium.fireEvent(attribute, Event.BLUR);
+ selenium.waitForPageToLoad();
+ // produce messages and check whether the stay less then 1000 ms
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ delay(1000);
+ assertFalse(selenium.isElementPresent(messages.get(type)), "Th=
e stayTime is set to 500 but after some delay the " + type + " message is s=
till present.");
+ } =
+ }
+ =
+ @Test
+ public void testAttributeMessagesSticky() {
+ // set the stayTime to <0>
+ JQueryLocator stayTime =3D pjq("input[name*=3D'attributesNotifyMes=
sages:stayTime']"); =
+ selenium.type(stayTime, "0");
+ selenium.fireEvent(stayTime, Event.BLUR);
+ selenium.waitForPageToLoad();
+ // set the sticky to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:sticky'][value=3Dfalse]"));
+ selenium.waitForPageToLoad();
+ // produce messages and check whether they disappear quickly =
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to , so the " + type + " message shouldn't be present.")
+ .until(NegationCondition.getInstance().condition(elementPr=
esent.locator(messages.get(type))));
+ closeAll(notify);
+ }
+ // set the sticky to
+ selenium.click(pjq("input[type=3Dradio][name*=3D'attributesNotifyM=
essages:sticky'][value=3Dtrue]"));
+ selenium.waitForPageToLoad(); =
+ // produce messages
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ } =
+ // check whether the messages are still present
+ delay(500);
+ for(String type : messages.keySet()) {
+ waitGui
+ .failWith("The stayTime is set to <0> and sticky to =
, so the " + type + " message should be present.")
+ .until(elementPresent.locator(messages.get(type)));
+ }
+ }
+ =
+ @Test
+ public void testAttributeMessagesStyleClass() {
+ selenium.type(pjq("input[name*=3D'attributesNotifyMessages:styleCl=
assInput']"), "someStyleClass");
+ selenium.waitForPageToLoad();
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ assertTrue(selenium.belongsClass(messages.get(type), "someStyl=
eClass"), "The cssStyle has been set but " + type + " message doesn't belon=
g to the set class.");
+ }
+ } =
+ =
+ @Test
+ public void testAttributeStackStyleClass() {
+ JQueryLocator attribute =3D pjq("input[name*=3D'attributesNotifySt=
ack: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
+ selenium.click(pjq("input[name*=3D'attributesNotifyStack:rendered'=
]"));
+ selenium.waitForPageToLoad();
+ assertFalse(selenium.isElementPresent(notifyStack), "The attribute=
rendered is set to but messages in the notify stack are still pres=
ent.");
+ }
+ =
+ @Test
+ public void testInit() {
+ assertTrue(selenium.isElementPresent(notify), "There is no notify =
message after page is loaded.");
+ assertEquals(selenium.getText(getDetail(notify)), RichNotifyBean.D=
EFAULT_DETAIL, "The notify detail doesn't match.");
+ assertEquals(selenium.getText(getSummary(notify)), RichNotifyBean.=
DEFAULT_SUMMARY, "The notify summary doesn't match.");
+ }
+ =
+ @Test
+ public void testCloseAndProduceNotify() {
+ // check closing the notify
+ close(notify);
+ waitGui
+ .failWith("After closing notify message the message is stil pr=
esent.")
+ .until(NegationCondition.getInstance().condition(elementPresen=
t.locator(notify)));
+ // check producing notifies
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ close(messages.get(type));
+ }
+ waitGui
+ .failWith("After producing messages the correct number of noti=
fies isn't present. Expected <" + messages.size() + ">, was <" + selenium.g=
etCount(notify) + ">")
+ .until(countEquals.locator(notify).count(messages.size())); =
+ } =
+ =
+ @Test
+ public void testProduceAndCloseMessages() {
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, 1);
+ close(messages.get(type));
+ }
+ }
+ =
+ @Test
+ public void testProduceMoreMessages() {
+ // set the messageCount to
+ int testedNumber =3D 3;
+ selenium.type(pjq("input[name*=3DmessageCountInput]"), testedNumbe=
r + "");
+ selenium.fireEvent(pjq("input[name*=3DmessageCountInput]"), Event.=
BLUR); =
+ selenium.waitForPageToLoad();
+ close(notify);
+ for(String type : messages.keySet()) {
+ produceMessage(messages.get(type), type, testedNumber);
+ assertEquals(getNumberOfNotifies(), 1, "Number of produced mes=
sages has been set to <" + testedNumber + "> but number of notifies should =
be still <1>.");
+ closeAll(messages.get(type));
+ close(notify);
+ } =
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces=
/tests/metamer/ftest/richNotify/TestRichNotifyMoreStacks.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotifyMoreStacks.java =
(rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotifyMoreStacks.java 2011-08-08 08:23=
:10 UTC (rev 22597)
@@ -0,0 +1,134 @@
+/*************************************************************************=
******
+ * 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 static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.annotations.Test;
+
+
+/**
+ * Test case for pages faces/components/notify/moreStacks.xhtml
+ * =
+ * @author Jan Papousek
+ */
+public class TestRichNotifyMoreStacks extends AbstractRichNotifyTest {
+ =
+ /**
+ * locator of the first stack =
+ */
+ private final JQueryLocator stack1 =3D jq("div.topRight");
+ =
+ /**
+ * locator of the second stack
+ */
+ private final JQueryLocator stack2 =3D jq("div.bottomRight");
+ =
+ /**
+ * locater of the input which is associated with messages for the firs=
t stack
+ */
+ private final JQueryLocator number1 =3D pjq("input[id$=3Dnumber1]");
+ =
+ /**
+ * locater of the input which is associated with messages for the seco=
nd stack
+ */
+ private final JQueryLocator number2 =3D pjq("input[id$=3Dnumber2]");
+ =
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richNotify/moreStac=
ks.xhtml");
+ } =
+ =
+ @Test
+ public void testInit() {
+ assertTrue(selenium.isElementPresent(stack1), "The first stack is =
not present.");
+ assertTrue(selenium.isElementPresent(stack2), "The second stack is=
not present.");
+ assertTrue(selenium.isElementPresent(inStack(stack1, notify)), "Th=
e notify in the first stack is not present.");
+ assertTrue(selenium.isElementPresent(inStack(stack2, notify)), "Th=
e notify in the second stack is not present.");
+ assertEquals(1, getNumberOfNotifies(stack1), "The initial number o=
f notifies in the first stack should be <1>, found <" + getNumberOfNotifies=
(stack1) + ">.");
+ assertEquals(1, getNumberOfNotifies(stack2), "The initial number o=
f notifies in the second stack should be <1>, found <" + getNumberOfNotifie=
s(stack2) + ">.");
+ }
+ =
+ @Test
+ public void testValidationErrorInTwoStacks() {
+ // notify in stacks
+ JQueryLocator message1 =3D inStack(stack1, notify);
+ JQueryLocator message2 =3D inStack(stack2, notify);
+ // close notifes in both stacks
+ close(message1);
+ close(message2);
+ // try to fill the number 1 field (wrong)
+ selenium.type(number1, "1");
+ selenium.fireEvent(number1, Event.BLUR);
+ delay(1000);
+ waitGui
+ .failWith("After wrong filling the first form field the number=
of messages in the first stack should be <1>, found <" + selenium.getCount=
(message1) + ">")
+ .until(countEquals.locator(message1).count(1));
+ waitGui
+ .failWith("After wrong filling the first form field the number=
of messages in the second stack should be <0>, found <" + selenium.getCoun=
t(message2) + ">")
+ .until(countEquals.locator(message1).count(0));
+ =
+ // close produced notifies
+ close(message1);
+ close(message2);
+ // try to fill the number 2 field (wrong)
+ selenium.type(number2, "1");
+ selenium.fireEvent(number2, Event.BLUR);
+ delay(1000);
+ waitGui
+ .failWith("After wrong filling the second form field the numbe=
r of messages in the second stack should be <1>, found <" + selenium.getCou=
nt(message2) + ">")
+ .until(countEquals.locator(message1).count(1));
+ waitGui
+ .failWith("After wrong filling the second form field the numbe=
r of messages in the first stack should be <0>, found <" + selenium.getCoun=
t(message1) + ">")
+ .until(countEquals.locator(message1).count(0)); =
+ }
+ =
+ /**
+ * It returns a number of notifes (only notifies, not messages) in the=
given stack
+ * =
+ * @param stack the stack where the notifies should be present
+ * @return number of notifies
+ */
+ private int getNumberOfNotifies(JQueryLocator stack) {
+ return selenium.getCount(inStack(stack, notify)) - (selenium.getCo=
unt(inStack(stack, notifyError)) + selenium.getCount(inStack(stack, notifyF=
atal)) + selenium.getCount(inStack(stack, notifyInfo)) + selenium.getCount(=
inStack(stack, notifyWarn)));
+ }
+ =
+ /**
+ * It returns a new locator of the given message in the given stack
+ * @param stack
+ * @param message
+ * @return a new locator of the given message in the given stack
+ */
+ private JQueryLocator inStack(JQueryLocator stack, JQueryLocator messa=
ge) {
+ String[] splittedMessageLocator =3D message.getAsString().split("\=
\.");
+ String[] splittedStackLocator =3D stack.getAsString().split("\\.");
+ String locator =3D "div[class*=3D" + splittedStackLocator[splitted=
StackLocator.length - 1] + "][class*=3D" + splittedMessageLocator[splittedM=
essageLocator.length - 1] + "]";
+ return jq(locator);
+ }
+ =
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces=
/tests/metamer/ftest/richNotify/TestRichNotifyValidation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotifyValidation.java =
(rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te=
sts/metamer/ftest/richNotify/TestRichNotifyValidation.java 2011-08-08 08:23=
:10 UTC (rev 22597)
@@ -0,0 +1,71 @@
+/*************************************************************************=
******
+ * 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 static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.NegationCondition;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for pages faces/components/notify/validation.xhtml
+ * =
+ * @author Jan Papousek
+ */
+public class TestRichNotifyValidation extends AbstractRichNotifyTest {
+
+ private JQueryLocator number =3D pjq("input[id$=3Dnumber]");
+ =
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richNotify/validati=
on.xhtml");
+ }
+
+ @Test
+ public void testAttributeMessagesGlobalOnly() {
+ =
+ }
+ =
+ @Test
+ public void testValidationMessageAppear() {
+ closeAll(notify);
+ selenium.type(number, "4");
+ selenium.fireEvent(number, Event.BLUR);
+ waitGui
+ .failWith("After typing <4> into the number field, the error s=
hould appear.")
+ .until(elementPresent.locator(notifyError));
+ }
+ =
+ @Test
+ public void testValidationMessageNotAppear() {
+ closeAll(notify);
+ selenium.type(number, "5");
+ selenium.fireEvent(number, Event.BLUR);
+ waitGui
+ .failWith("After typing <5> into the number field, the error s=
hould appear.")
+ .until(NegationCondition.getInstance().condition(elementPresen=
t.locator(notifyError))); =
+ }
+ =
+}
--===============3217093821466504460==--