Author: jpapouse
Date: 2011-07-27 08:45:48 -0400 (Wed, 27 Jul 2011)
New Revision: 22569
Added:
modules/tests/metamer/branches/sandbox-components/application/src/main/resources/org/richfaces/tests/metamer/bean/NotifyBean.properties
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/validation.xhtml
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyValidation.java
Modified:
modules/tests/metamer/branches/sandbox-components/application/src/main/java/org/richfaces/tests/metamer/bean/NotifyBean.java
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/list.xhtml
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/AbstractNotifyTest.java
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotify.java
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyMoreStacks.java
Log:
FPL-1504:
- corrected details in pages and tests for Notify component
- created page containg only component handling messages from validation and selenium
tests for this page
Modified:
modules/tests/metamer/branches/sandbox-components/application/src/main/java/org/richfaces/tests/metamer/bean/NotifyBean.java
===================================================================
---
modules/tests/metamer/branches/sandbox-components/application/src/main/java/org/richfaces/tests/metamer/bean/NotifyBean.java 2011-07-27
08:48:15 UTC (rev 22568)
+++
modules/tests/metamer/branches/sandbox-components/application/src/main/java/org/richfaces/tests/metamer/bean/NotifyBean.java 2011-07-27
12:45:48 UTC (rev 22569)
@@ -99,64 +99,131 @@
attributesBean.setAttribute("messageText", DEFAULT_TEXT);
}
+ /**
+ * Produces error message which is handled by notify:notifyMessages component.
+ */
public void produceError() {
produceMessage(FacesMessage.SEVERITY_ERROR);
}
-
+
+ /**
+ * Produces fatal message which is handled by notify:notifyMessages component.
+ */
public void produceFatal() {
produceMessage(FacesMessage.SEVERITY_FATAL);
}
-
+
+ /**
+ * Produces info message which is handled by notify:notifyMessages component.
+ */
public void produceInfo() {
produceMessage(FacesMessage.SEVERITY_INFO);
}
+ /**
+ * Produces warn message which is handled by notify:notifyMessages component.
+ */
public void produceWarn() {
produceMessage(FacesMessage.SEVERITY_WARN);
}
+ /**
+ * General attributes for this bean
+ */
public Attributes getAttributesBean() {
return attributesBean;
}
+ /**
+ * Attributes for notify:notify component
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
public Attributes getAttributesNotify() {
return attributesNotify;
}
-
-
+
+ /**
+ * Attributes for notify:notifyMessages component
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
public Attributes getAttributesNotifyMessages() {
return attributesNotifyMessages;
}
-
+ /**
+ * Attributes for notify:notifyStack (1) component
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
public Attributes getAttributesNotifyStackFirst() {
return attributesNotifyStackFirst;
}
+ /**
+ * Attributes for notify:notifyStack (2) component
+ *
+ * @return A map containing all attributes of tested component. Name of the component
is key in the map.
+ */
public Attributes getAttributesNotifyStackSecond() {
return attributesNotifyStackSecond;
}
-
+ /**
+ * General attributes for this bean
+ *
+ * @param attributesBean
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
public void setAttributesBean(Attributes attributesBean) {
this.attributesBean = attributesBean;
}
+ /**
+ * Attributes for notify:notify component
+ *
+ * @param attributesNotify
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
public void setAttributesNotify(Attributes attributesNotify) {
this.attributesNotify = attributesNotify;
}
+ /**
+ * Attributes for notify:notifyMessages component
+ *
+ * @param attributesNotifyMessages
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
public void setAttributesNotifyMessages(Attributes attributesNotifyMessages) {
this.attributesNotifyMessages = attributesNotifyMessages;
}
+ /**
+ * Attributes for notify:notifyStack (1) component
+ *
+ * @param attributesNotifyStack
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
public void setAttributesNotifyStackFirst(Attributes attributesNotifyStack) {
this.attributesNotifyStackFirst = attributesNotifyStack;
}
+ /**
+ * Attributes for notify:notifyStack (2) component
+ *
+ * @param attributesNotifyStack
+ * map containing all attributes of tested component. Name of the
component is key in the map.
+ */
public void setAttributesNotifyStackSecond(Attributes attributesNotifyStack) {
this.attributesNotifyStackSecond = attributesNotifyStack;
}
+ /**
+ * Produces a message which is handled by notify:notifyMessages component.
+ *
+ * @param severity the severity
+ */
private void produceMessage(FacesMessage.Severity severity) {
int messageCount =
Integer.valueOf((String)attributesBean.get("messageCount").getValue());
String text = (String) attributesBean.get("messageText").getValue();
@@ -166,6 +233,11 @@
}
}
+ /**
+ * It returns attributes shared by AbstractNotify and AbstractNotifyMessages
(NotifyAttributes)
+ *
+ * @return map containing all attributes of tested component. Name of the component
is key in the map.
+ */
private Attributes getGeneralAttributes() {
Attributes attributes = Attributes.getAttributesFromClass(NotifyAttributes.class,
getClass());
attributes.setAttribute("animationSpeed", 100);
Added:
modules/tests/metamer/branches/sandbox-components/application/src/main/resources/org/richfaces/tests/metamer/bean/NotifyBean.properties
===================================================================
---
modules/tests/metamer/branches/sandbox-components/application/src/main/resources/org/richfaces/tests/metamer/bean/NotifyBean.properties
(rev 0)
+++
modules/tests/metamer/branches/sandbox-components/application/src/main/resources/org/richfaces/tests/metamer/bean/NotifyBean.properties 2011-07-27
12:45:48 UTC (rev 22569)
@@ -0,0 +1,9 @@
+attr.appearAnimation.fade=fade
+attr.appearAnimation.show=show
+attr.appearAnimation.slide=slide
+attr.appearAnimation.none=
+
+attr.hideAnimation.fade=fade
+attr.hideAnimation.show=show
+attr.hideAnimation.slide=slide
+attr.hideAnimation.none=
\ No newline at end of file
Modified:
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/list.xhtml
===================================================================
---
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/list.xhtml 2011-07-27
08:48:15 UTC (rev 22568)
+++
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/list.xhtml 2011-07-27
12:45:48 UTC (rev 22569)
@@ -32,13 +32,17 @@
<ui:define name="links">
+ <metamer:testPageLink id="moreStacks"
outcome="moreStacks" value="More Stacks">
+ Simple page that contains two stacks for <b>notify:notify</b>
and <b>notify:notifyMessages</b> and input boxes for all its attributes.
+ </metamer:testPageLink>
+
<metamer:testPageLink id="simple" outcome="simple"
value="Simple">
- Simple page that contains <b>notify:notify</b> and input
boxes for all its attributes.
+ Simple page that contains <b>notify:notify</b>,
<b>notify:notifyMessages</b>, <b>notify:notifyStack</b> and input
boxes for all its attributes.
</metamer:testPageLink>
- <metamer:testPageLink id="moreStacks"
outcome="moreStacks" value="More Stacks">
- Simple page that contains stacks for <b>notify:notify</b> and
input boxes for all its attributes.
- </metamer:testPageLink>
+ <metamer:testPageLink id="validation"
outcome="validation" value="Validation">
+ Simple page that contains input field that generates validation messages
handled by for <b>notify:notifyMessages</b> and input boxes for all its
attributes.
+ </metamer:testPageLink>
</ui:define>
Added:
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/validation.xhtml
===================================================================
---
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/validation.xhtml
(rev 0)
+++
modules/tests/metamer/branches/sandbox-components/application/src/main/webapp/components/notify/validation.xhtml 2011-07-27
12:45:48 UTC (rev 22569)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:notify="http://richfaces.org/sandbox/notify"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
xmlns:a4j="http://richfaces.org/a4j">
+
+ <!--
+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.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="component">
+ <h:form>
+ <notify:notifyMessages ajaxRendered="true"
+
animationSpeed="#{notifyBean.attributesNotifyMessages['animationSpeed'].value}"
+
appearAnimation="#{notifyBean.attributesNotifyMessages['appearAnimation'].value}"
+
delay="#{notifyBean.attributesNotifyMessages['delay'].value}"
+ execute="{@form}"
+ for="number"
+
globalOnly="#{notifyBean.attributesNotifyMessages['delay'].value}"
+
hideAnimation="#{notifyBean.attributesNotifyMessages['hideAnimation'].value}"
+
keepTransient="#{notifyBean.attributesNotifyMessages['keepTransient'].value}"
+
interval="#{notifyBean.attributesNotifyMessages['interval'].value}"
+
nonblocking="#{notifyBean.attributesNotifyMessages['nonBlocking'].value}"
+
nonblockingOpacity="#{notifyBean.attributesNotifyMessages['nonBlockingOpacity'].value}"
+
rendered="#{notifyBean.attributesNotifyMessages['rendered'].value}"
+
showCloseButton="#{notifyBean.attributesNotifyMessages['showCloseButton'].value}"
+
showDetail="#{notifyBean.attributesNotifyMessages['showDetail'].value}"
+
showHistory="#{notifyBean.attributesNotifyMessages['showHistory'].value}"
+
showShadow="#{notifyBean.attributesNotifyMessages['showShadow'].value}"
+
showSummary="#{notifyBean.attributesNotifyMessages['showSummary'].value}"
+ stack="exampleNotifyStack"
+
stayTime="#{notifyBean.attributesNotifyMessages['stayTime'].value}"
+
sticky="#{notifyBean.attributesNotifyMessages['sticky'].value}"
+
styleClass="#{notifyBean.attributesNotifyMessages['styleClass'].value}"
+ />
+
+ <notify:notify
animationSpeed="#{notifyBean.attributesNotify['animationSpeed'].value}"
+
appearAnimation="#{notifyBean.attributesNotify['appearAnimation'].value}"
+
delay="#{notifyBean.attributesNotify['delay'].value}"
+
hideAnimation="#{notifyBean.attributesNotify['hideAnimation'].value}"
+
nonblocking="#{notifyBean.attributesNotify['nonBlocking'].value}"
+
nonblockingOpacity="#{notifyBean.attributesNotify['nonBlockingOpacity'].value}"
+
rendered="#{notifyBean.attributesNotify['rendered'].value}"
+
showCloseButton="#{notifyBean.attributesNotify['showCloseButton'].value}"
+
showHistory="#{notifyBean.attributesNotify['showHistory'].value}"
+
showShadow="#{notifyBean.attributesNotify['showShadow'].value}"
+ stack="exampleNotifyStack"
+
stayTime="#{notifyBean.attributesNotify['stayTime'].value}"
+
sticky="#{notifyBean.attributesNotify['sticky'].value}"
+
styleClass="#{notifyBean.attributesNotify['styleClass'].value}"
+
text="#{notifyBean.attributesNotify['text'].value}"
+ title="
#{notifyBean.attributesNotify['title'].value}"
+ />
+
+ <notify:notifyStack id="exampleNotifyStack"
+
push="#{notifyBean.attributesNotifyStackFirst['push'].value}"
+
rendered="#{notifyBean.attributesNotifyStackFirst['rendered'].value}"
+
stackDir1="#{notifyBean.attributesNotifyStackFirst['stackDir1'].value}"
+
stackDir2="#{notifyBean.attributesNotifyStackFirst['stackDir2'].value}"
+
styleClass="#{notifyBean.attributesNotifyStackFirst['styleClass'].value}"
+ />
+
+ <h:outputLabel for="number" value="Number (from 5 to
10)"/>
+ <h:inputText id="number" required="true">
+ <f:validateLongRange minimum="5"
maximum="10"/>
+ <a4j:ajax event="change" execute="@form"/>
+ </h:inputText>
+
+ </h:form>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <h2>Attributes - Notify</h2>
+ <metamer:attributes value="#{notifyBean.attributesNotify}"
id="attributesNotify" render="panel"/>
+ <h2>Attributes - Notify Messages</h2>
+ <metamer:attributes
value="#{notifyBean.attributesNotifyMessages}"
id="attributesNotifyMessages" render="panel"/>
+ <h2>Attributes - Notify Stack</h2>
+ <metamer:attributes
value="#{notifyBean.attributesNotifyStackFirst}"
id="attributesNotifyStack" render="panel"/>
+ </ui:define>
+ </ui:composition>
+
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/AbstractNotifyTest.java
===================================================================
---
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/AbstractNotifyTest.java 2011-07-27
08:48:15 UTC (rev 22568)
+++
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/AbstractNotifyTest.java 2011-07-27
12:45:48 UTC (rev 22569)
@@ -36,12 +36,36 @@
*/
public abstract class AbstractNotifyTest extends AbstractMetamerTest {
+ /**
+ * notify locator which matches on all notifies and messages
+ */
protected JQueryLocator notify = jq("div.rf-ny");
+
+ /**
+ * error message locator
+ */
protected JQueryLocator notifyError = jq("div.rf-ny-error");
+
+ /**
+ * fatal message locator
+ */
protected JQueryLocator notifyFatal = jq("div.rf-ny-fatal");
+
+ /**
+ * info message locator
+ */
protected JQueryLocator notifyInfo = jq("div.rf-ny-info");
+
+ /**
+ * warn message locator
+ */
protected JQueryLocator notifyWarn = jq("div.rf-ny-warn");
+ /**
+ * It closes a message defined by the given locator
+ *
+ * @param locator the message locator
+ */
protected void close(final JQueryLocator locator) {
final int before = selenium.getCount(locator);
selenium.click(getFirstCloseButton(locator));
@@ -50,6 +74,22 @@
.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 thrown, it's
logged by logger of this class.
+ *
+ * @param ms number of miliseconds
+ */
protected void delay(int ms) {
try {
Thread.sleep(ms);
@@ -58,18 +98,43 @@
}
}
+ /**
+ * 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-ny-co > div.rf-ny-cl
> span.rf-ny-cl-ic");
}
+ /**
+ * 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) +
selenium.getCount(notifyWarn));
}
+ /**
+ * It produces a message defined by the given message locator and the given type.
+ * It waits until the <expected> number of message is produced.
+ *
+ * @param message the message locator
+ * @param type the name of the message type (started with capital letter)
+ * @param expected expected number of produced messages
+ */
protected void produceMessage(final JQueryLocator message, String type, final int
expected) {
final int before = selenium.getCount(message);
selenium.click(pjq("input[id$=produce" + type + "]"));
Modified:
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotify.java
===================================================================
---
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotify.java 2011-07-27
08:48:15 UTC (rev 22568)
+++
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotify.java 2011-07-27
12:45:48 UTC (rev 22569)
@@ -46,7 +46,14 @@
*/
public class TestNotify extends AbstractNotifyTest {
+ /**
+ * notify stack locator
+ */
private JQueryLocator notifyStack = jq("div.rf-ny");
+
+ /**
+ * Map containing locators of all tested messages. Type of the message is a key in
the map.
+ */
private Map<String, JQueryLocator> messages = new HashMap<String,
JQueryLocator>();
@BeforeClass
@@ -64,18 +71,22 @@
@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();
+ // 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.");
+ // 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 <false>
selenium.click(pjq("input[type=radio][name*='attributesNotify:rendered'][value=false]"));
selenium.waitForPageToLoad();
assertFalse(selenium.isElementPresent(notify), "The attribute rendered is
set to <false> but the notify is still present.");
@@ -83,6 +94,7 @@
@Test
public void testAttributeShowCloseButton() {
+ // set the showCloseButton to <false>
selenium.click(pjq("input[type=radio][name*='attributesNotify:showCloseButtonInput'][value=false]"));
selenium.waitForPageToLoad();
assertTrue(selenium.getStyle(jq(notify.getRawLocator() + " > div.rf-ny-co
> div.rf-ny-cl"), new
CssProperty("visibility")).contains("hidden"), "The
showCloseButton is set to <false> and therefore the close button shouldn't be
displayed.");
@@ -90,8 +102,10 @@
@Test
public void testAttributeShowHistory() {
+ // check whether the history is not present (showHistory is set to
<false>)
JQueryLocator history = jq("div.rf-ny-hc");
assertFalse(selenium.isElementPresent(history), "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();
assertTrue(selenium.isElementPresent(history), "The showHistory is set to
<true> and one notify is present, but there is no history menu.");
@@ -99,6 +113,7 @@
produceMessage(notifyError, "Error", 1);
close(notify);
close(notify);
+ // click on the All button in history menu
selenium.click(jq("button.rf-ny-ha"));
waitModel
.failWith("After clicking on <All> in history menu there should be
all notifies. Expected <2>, found <" + getNumberOfNotifies() +
">")
@@ -110,6 +125,7 @@
});
close(notify);
close(notify);
+ // click on the Last button in the history menu
selenium.click(jq("button.rf-ny-hl"));
waitModel
.failWith("After clicking on <Last> in history menu there should
be last notify. Expected <1>, found <" + getNumberOfNotifies() +
">")
@@ -123,35 +139,83 @@
@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 =
pjq("input[name*='attributesNotify:stayTime']");
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 set to 500
but after some delay the notify is still present.");
}
@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();
+ // set the sticky to <false>
+
selenium.click(pjq("input[type=radio][name*='attributesNotify:sticky'][value=false]"));
+ selenium.waitForPageToLoad();
+ 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
+ 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 <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);
+ 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
+ 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 notify shouldn't be present.")
+ .until(new SeleniumCondition() {
+ @Override
+ public boolean isTrue() {
+ return selenium.getCount(notify) == messages.size();
+ }
+ });
+ }
+
+ @Test
public void testAttributeStyleClass() {
selenium.type(pjq("input[name*='attributesNotify:styleClassInput']"),
"someStyleClass");
selenium.waitForPageToLoad();
assertTrue(selenium.belongsClass(notify, "someStyleClass"), "The
cssStyle has been set but notify doesn't belong to the set class.");
}
- @Test(enabled=false)
+ @Test(enabled=true)
public void testAttributeMessagesDelay() {
- JQueryLocator attribute =
jq("input[id$='attributesNotifyMessages:delayInput']");
+ // set the delay to <1000>
+ JQueryLocator attribute =
pjq("input[id$='attributesNotifyMessages: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$=produce" + type + "]"));
delay(500);
@@ -163,8 +227,10 @@
@Test
public void testAttributeMessagesRendered() {
+ // set the rendered to <false>
selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:rendered'][value=false]"));
selenium.waitForPageToLoad();
+ // check the message isn't displayed for each message type
for(String type : messages.keySet()) {
String before = selenium.getText(jq("span[id=requestTime]"));
selenium.click(pjq("input[id$=produce" + type + "]"));
@@ -175,6 +241,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();
for(String type : messages.keySet()) {
@@ -185,10 +252,12 @@
@Test(enabled=false)
public void testAttributeMessagesShowDetail() {
+ // produce messages and check whether the detail isn't displayed (showDetail
is set to <false>)
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
assertTrue(selenium.getStyle(jq(messages.get(type) + " > div.rf-ny-co
> div.rf-ny-te"), new
CssProperty("display")).contains("none"));
}
+ // set showDetail to <true>
selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:showDetail'][value=true]"));
selenium.waitForPageToLoad();
for(String type : messages.keySet()) {
@@ -198,17 +267,22 @@
@Test
public void testAttributeMessagesShowHistory() {
+ // check whether the history isn't present (showHistory is set to
<false>)
close(notify);
JQueryLocator history = jq("div.rf-ny-hc");
assertFalse(selenium.isElementPresent(history), "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();
+ // check whether the history isn't displayed (there is no message in the
history)
assertFalse(selenium.isElementPresent(history), "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);
}
+ // click on All button in the history menu
selenium.click(jq("button.rf-ny-ha"));
final int expected = messages.size();
waitModel
@@ -222,6 +296,7 @@
for(int i=0; i<expected; i++) {
close(notify);
}
+ // click on Last button in the history menu
selenium.click(jq("button.rf-ny-hl"));
waitModel
.failWith("After clicking on <Last> in history menu there should
be last message. Expected <1>, found <" + selenium.getCount(notify) +
">")
@@ -235,17 +310,19 @@
@Test
public void testAttributeMessagesStayTime() {
+ // produce messages and check whether the stay at least 1000 ms (stayTime 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 " + type + " message
is not present.");
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();
+ // produce messages and check whether the stay less then 1000 ms
for(String type : messages.keySet()) {
produceMessage(messages.get(type), type, 1);
delay(1000);
@@ -254,6 +331,40 @@
}
@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();
+ // set the sticky to <false>
+
selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:sticky'][value=false]"));
+ 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
<false>, so the " + type + " message shouldn't be present.")
+
.until(NegationCondition.getInstance().condition(elementPresent.locator(messages.get(type))));
+ closeAll(notify);
+ }
+ // set the sticky to <true>
+
selenium.click(pjq("input[type=radio][name*='attributesNotifyMessages:sticky'][value=true]"));
+ 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
<true>, so the " + type + " message should be present.")
+ .until(elementPresent.locator(messages.get(type)));
+ }
+ }
+
+ @Test
public void testAttributeMessagesStyleClass() {
selenium.type(pjq("input[name*='attributesNotifyMessages:styleClassInput']"),
"someStyleClass");
selenium.waitForPageToLoad();
@@ -274,6 +385,7 @@
@Test
public void testAttributeStackRendered() {
+ // set the rendered to <false>
selenium.click(pjq("input[name*='attributesNotifyStack:rendered']"));
selenium.waitForPageToLoad();
assertFalse(selenium.isElementPresent(notifyStack), "The attribute rendered
is set to <false> but the notify stack is still present.");
@@ -288,54 +400,42 @@
@Test
public void testCloseAndProduceNotify() {
+ // check closing the notify
close(notify);
- waitModel
+ waitGui
.failWith("After closing notify message the message is stil
present.")
.until(NegationCondition.getInstance().condition(elementPresent.locator(notify)));
- selenium.click(pjq("input[id$=produceError]"));
- selenium.click(pjq("input[id$=produceError]"));
- selenium.click(pjq("input[id$=produceFatal]"));
- selenium.click(pjq("input[id$=produceInfo]"));
- selenium.click(pjq("input[id$=produceWarn]"));
- waitModel
- .failWith("After producing messages the correct number of notifies
isn't present. Expected <5>, was <" + getNumberOfNotifies() +
">")
- .until(new SeleniumCondition() {
- @Override
- public boolean isTrue() {
- return getNumberOfNotifies() == 5;
- }
- });
+ // 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 notifies
isn't present. Expected <" + messages.size() + ">, was <" +
selenium.getCount(notify) + ">")
+ .until(countEquals.locator(notify).count(messages.size()));
}
@Test
public void testProduceAndCloseMessages() {
for(String type : messages.keySet()) {
- testProduceAndCloseMessage(messages.get(type), type);
+ produceMessage(messages.get(type), type, 1);
+ close(messages.get(type));
}
}
@Test
- public void testProduceMoreMessages() {
+ public void testProduceMoreMessages() {
+ // set the messageCount to <testedNumber>
int testedNumber = 3;
- selenium.type(pjq("input[id$=messageCountInput]"), testedNumber +
"");
- selenium.fireEvent(pjq("input[id$=messageCountInput]"), Event.BLUR);
+ selenium.type(pjq("input[name*=messageCountInput]"), testedNumber +
"");
+ selenium.fireEvent(pjq("input[name*=messageCountInput]"), Event.BLUR);
selenium.waitForPageToLoad();
+ close(notify);
for(String type : messages.keySet()) {
- testProduceMoreMessages(messages.get(type), type, testedNumber);
- }
+ 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>.");
+ closeAll(messages.get(type));
+ close(notify);
+ }
}
-
- private void testProduceAndCloseMessage(final JQueryLocator message, String type) {
- produceMessage(message, type, 1);
- close(message);
- }
-
- private void testProduceMoreMessages(final JQueryLocator message, String type, int
number) {
- close(notify);
- produceMessage(message, type, number);
- assertEquals(getNumberOfNotifies(), 1, "Number of produced messages has been
set to <" + number + "> but number of notifies should be still
<1>.");
- for(int i=0; i<number; i++) {
- close(message);
- }
- }
}
Modified:
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyMoreStacks.java
===================================================================
---
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyMoreStacks.java 2011-07-27
08:48:15 UTC (rev 22568)
+++
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyMoreStacks.java 2011-07-27
12:45:48 UTC (rev 22569)
@@ -26,7 +26,6 @@
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertEquals;
import java.net.URL;
-import java.util.logging.Logger;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.JQueryLocator;
@@ -40,9 +39,24 @@
*/
public class TestNotifyMoreStacks extends AbstractNotifyTest {
+ /**
+ * locator of the first stack
+ */
private JQueryLocator stack1 = jq("div.topRight");
+
+ /**
+ * locator of the second stack
+ */
private JQueryLocator stack2 = jq("div.bottomRight");
+
+ /**
+ * locater of the input which is associated with messages for the first stack
+ */
private JQueryLocator number1 = pjq("input[id$=number1]");
+
+ /**
+ * locater of the input which is associated with messages for the second stack
+ */
private JQueryLocator number2 = pjq("input[id$=number2]");
@Override
@@ -61,12 +75,14 @@
}
@Test
- public void testValidationError() {
- close(inStack(stack1, notify));
- close(inStack(stack2, notify));
+ public void testValidationErrorInTwoStacks() {
+ // notify in stacks
JQueryLocator message1 = inStack(stack1, notify);
- JQueryLocator message2 = inStack(stack2, notify);
-
+ JQueryLocator message2 = 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);
@@ -77,9 +93,10 @@
.failWith("After wrong filling the first form field the number of
messages in the second stack should be <0>, found <" +
selenium.getCount(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);
@@ -91,10 +108,22 @@
.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.getCount(inStack(stack, notifyError)) + selenium.getCount(inStack(stack,
notifyFatal)) + 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 message) {
// FIXME
String[] splittedMessageLocator = message.getAsString().split("\\.");
Added:
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyValidation.java
===================================================================
---
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyValidation.java
(rev 0)
+++
modules/tests/metamer/branches/sandbox-components/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/notify/TestNotifyValidation.java 2011-07-27
12:45:48 UTC (rev 22569)
@@ -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.notify;
+
+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 <a href="mailto:jpapouse@redhat.com">Jan Papousek</a>
+ */
+public class TestNotifyValidation extends AbstractNotifyTest {
+
+ private JQueryLocator number = pjq("input[id$=number]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/notify/validation.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
should 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
should appear.")
+
.until(NegationCondition.getInstance().condition(elementPresent.locator(notifyError)));
+ }
+
+}