Author: ppitonak(a)redhat.com
Date: 2011-08-26 07:21:29 -0400 (Fri, 26 Aug 2011)
New Revision: 22665
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richPickList/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java
Log:
sample and tests for rich:pickList updated
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java 2011-08-23
08:46:49 UTC (rev 22664)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichPickListBean.java 2011-08-26
11:21:29 UTC (rev 22665)
@@ -42,34 +42,34 @@
import org.slf4j.LoggerFactory;
/**
- * Backing Bean for rich:pickList component at
- *
+ * Backing Bean for rich:pickList component at
+ *
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
* @version $Revision$
*/
@ManagedBean(name = "richPickListBean")
@ViewScoped
public class RichPickListBean implements Serializable {
-
+
private static final Logger LOG = LoggerFactory.getLogger(RichPickListBean.class);
/** Generated Serial UID Number */
private static final long serialVersionUID = 2158237918061200181L;
-
+
private Attributes attributes;
@ManagedProperty(value = "#{model.capitals}")
private List<Capital> capitals;
private List<SelectItem> capitalsOptions = null;
private List<SelectItem> validationOptions = null;
private List<SelectItem> value = null;
-
+
@PostConstruct
public void init() {
attributes = Attributes.getComponentAttributesFromFacesConfig(UIPickList.class,
getClass());
capitalsOptions = new ArrayList<SelectItem>();
validationOptions = new ArrayList<SelectItem>();
value = new ArrayList<SelectItem>();
-
+
for (Capital capital : capitals) {
capitalsOptions.add(new SelectItem(capital.getState(), capital.getState()));
validationOptions.add(new SelectItem(capital.getState(),
capital.getState()));
@@ -78,38 +78,45 @@
validationOptions.add(new SelectItem("", ""));
validationOptions.add(new SelectItem("RichFaces",
"RichFaces"));
validationOptions.add(new SelectItem("richfaces",
"richfaces"));
-
+
attributes.setAttribute("rendered", Boolean.TRUE);
attributes.setAttribute("minListHeight", "100");
-
+
attributes.setAttribute("requiredMessage", "Not empty target list
is required!");
-
+
attributes.setAttribute("addText", ">");
attributes.setAttribute("addAllText", ">>");
attributes.setAttribute("removeText", "<");
attributes.setAttribute("removeAllText", "<<");
-
+
+ attributes.setAttribute("upTopText", "⇑ First");
+ attributes.setAttribute("upText", "↑ Up");
+ attributes.setAttribute("downText", "↓ Down");
+ attributes.setAttribute("downBottomText", "⇓ Last");
+
attributes.remove("converter");
attributes.remove("converterMessage");
+ attributes.remove("valueChangeListener");
+ attributes.remove("var");
}
-
+
/**
* Test method for verify validator attribute
+ *
* @param context
* @param component
* @param value
*/
public void validatePickListValue(FacesContext context, UIComponent component, Object
value) {
LOG.info(" #validatePickListValue: Custom validation for rich:pickList
");
-
+
@SuppressWarnings("unchecked")
- List<String> l = (List<String>)value;
+ List<String> l = (List<String>) value;
if (l.contains("@@")) {
LOG.info(" Validation rule violation found! One of picked items contains
'@'!");
- throw new ValidatorException(
- new FacesMessage(FacesMessage.SEVERITY_ERROR,
- "PickList don't like '@' char!", "PickList
don't like '@' char!"));
- }
+ throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
"PickList don't like '@' char!",
+ "PickList don't like '@' char!"));
+ }
}
/**
@@ -127,7 +134,7 @@
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
}
-
+
/**
*
* @return capitals
@@ -152,7 +159,8 @@
}
/**
- * @param capitalsOptions the capitalsOptions to set
+ * @param capitalsOptions
+ * the capitalsOptions to set
*/
public void setCapitalsOptions(List<SelectItem> capitalsOptions) {
this.capitalsOptions = capitalsOptions;
@@ -166,7 +174,8 @@
}
/**
- * @param validationOptions the validationOptions to set
+ * @param validationOptions
+ * the validationOptions to set
*/
public void setValidationOptions(List<SelectItem> validationOptions) {
this.validationOptions = validationOptions;
@@ -180,7 +189,8 @@
}
/**
- * @param value the value to set
+ * @param value
+ * the value to set
*/
public void setValue(List<SelectItem> value) {
this.value = value;
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richPickList/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richPickList/simple.xhtml 2011-08-23
08:46:49 UTC (rev 22664)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richPickList/simple.xhtml 2011-08-26
11:21:29 UTC (rev 22665)
@@ -1,10 +1,10 @@
<?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:metamer="http://java.sun.com/jsf/composite/metamer"
-
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j" >
+
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
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
@@ -26,112 +26,113 @@
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
- <ui:composition template="/templates/template.xhtml">
+<ui:composition template="/templates/template.xhtml">
- <ui:define name="view">
- <f:metadata>
- <f:viewParam name="templates"
value="#{templateBean.templates}">
- <f:converter converterId="templatesListConverter" />
- </f:viewParam>
- </f:metadata>
- </ui:define>
+ <ui:define name="view">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
- <ui:define name="component">
+ <ui:define name="component">
- <rich:pickList id="pickList"
- addAllText="#{richPickListBean.attributes['addAllText'].value}"
- addText="#{richPickListBean.attributes['addText'].value}"
- columnClasses="#{richPickListBean.attributes['columnClasses'].value}"
- columnVar="#{richPickListBean.attributes['columnVar'].value}"
- defaultLabel="#{richPickListBean.attributes['defaultLabel'].value}"
- disabled="#{richPickListBean.attributes['disabled'].value}"
- disabledClass="#{richPickListBean.attributes['disabledClass'].value}"
- headerClass="#{richPickListBean.attributes['headerClass'].value}"
- immediate="#{richPickListBean.attributes['immediate'].value}"
- itemClass="#{richPickListBean.attributes['itemClass'].value}"
- listHeight="#{richPickListBean.attributes['listHeight'].value}"
- listWidth="#{richPickListBean.attributes['listWidth'].value}"
- maxListHeight="#{richPickListBean.attributes['maxListHeight'].value}"
- minListHeight="#{richPickListBean.attributes['minListHeight'].value}"
- onadditem="#{richPickListBean.attributes['onadditem'].value}"
- onblur="#{richPickListBean.attributes['onblur'].value}"
- onchange="#{richPickListBean.attributes['onchange'].value}"
- onclick="#{richPickListBean.attributes['onclick'].value}"
- ondblclick="#{richPickListBean.attributes['ondblclick'].value}"
- onfocus="#{richPickListBean.attributes['onfocus'].value}"
- onkeydown="#{richPickListBean.attributes['onkeydown'].value}"
- onkeypress="#{richPickListBean.attributes['onkeypress'].value}"
- onkeyup="#{richPickListBean.attributes['onkeyup'].value}"
- onlistclick="#{richPickListBean.attributes['onlistclick'].value}"
- onlistdblclick="#{richPickListBean.attributes['onlistdblclick'].value}"
- onlistkeydown="#{richPickListBean.attributes['onlistkeydown'].value}"
- onlistkeypress="#{richPickListBean.attributes['onlistkeypress'].value}"
- onlistkeyup="#{richPickListBean.attributes['onlistkeyup'].value}"
- onlistmousedown="#{richPickListBean.attributes['onlistmousedown'].value}"
- onlistmousemove="#{richPickListBean.attributes['onlistmousemove'].value}"
- onlistmouseout="#{richPickListBean.attributes['onlistmouseout'].value}"
- onlistmouseover="#{richPickListBean.attributes['onlistmouseover'].value}"
- onlistmouseup="#{richPickListBean.attributes['onlistmouseup'].value}"
- onmousedown="#{richPickListBean.attributes['onmousedown'].value}"
- onmousemove="#{richPickListBean.attributes['onmousemove'].value}"
- onmouseout="#{richPickListBean.attributes['onmouseout'].value}"
- onmouseover="#{richPickListBean.attributes['onmouseover'].value}"
- onmouseup="#{richPickListBean.attributes['onmouseup'].value}"
- onremoveitem="#{richPickListBean.attributes['onremoveitem'].value}"
- onsourceclick="#{richPickListBean.attributes['onsourceclick'].value}"
- onsourcedblclick="#{richPickListBean.attributes['onsourcedblclick'].value}"
- onsourcekeydown="#{richPickListBean.attributes['onsourcekeydown'].value}"
- onsourcekeypress="#{richPickListBean.attributes['onsourcekeypress'].value}"
- onsourcekeyup="#{richPickListBean.attributes['onsourcekeyup'].value}"
- onsourcemousedown="#{richPickListBean.attributes['onsourcemousedown'].value}"
- onsourcemousemove="#{richPickListBean.attributes['onsourcemousemove'].value}"
- onsourcemouseout="#{richPickListBean.attributes['onsourcemouseout'].value}"
- onsourcemouseover="#{richPickListBean.attributes['onsourcemouseover'].value}"
- onsourcemouseup="#{richPickListBean.attributes['onsourcemouseup'].value}"
- ontargetclick="#{richPickListBean.attributes['ontargetclick'].value}"
- ontargetdblclick="#{richPickListBean.attributes['ontargetdblclick'].value}"
- ontargetkeydown="#{richPickListBean.attributes['ontargetkeydown'].value}"
- ontargetkeypress="#{richPickListBean.attributes['ontargetkeypress'].value}"
- ontargetkeyup="#{richPickListBean.attributes['ontargetkeyup'].value}"
- ontargetmousedown="#{richPickListBean.attributes['ontargetmousedown'].value}"
- ontargetmousemove="#{richPickListBean.attributes['ontargetmousemove'].value}"
- ontargetmouseout="#{richPickListBean.attributes['ontargetmouseout'].value}"
- ontargetmouseover="#{richPickListBean.attributes['ontargetmouseover'].value}"
- ontargetmouseup="#{richPickListBean.attributes['ontargetmouseup'].value}"
- orderable="#{richPickListBean.attributes['orderable'].value}"
- removeAllText="#{richPickListBean.attributes['removeAllText'].value}"
- removeText="#{richPickListBean.attributes['removeText'].value}"
- rendered="#{richPickListBean.attributes['rendered'].value}"
- required="#{richPickListBean.attributes['required'].value}"
- requiredMessage="#{richPickListBean.attributes['requiredMessage'].value}"
- selectItemClass="#{richPickListBean.attributes['selectItemClass'].value}"
- showButton="#{richPickListBean.attributes['showButton'].value}"
- sourceCaption="#{richPickListBean.attributes['sourceCaption'].value}"
- style="#{richPickListBean.attributes['style'].value}"
- styleClass="#{richPickListBean.attributes['styleClass'].value}"
- targetCaption="#{richPickListBean.attributes['targetCaption'].value}"
- validator="#{richPickListBean.validatePickListValue}"
- value="#{richPickListBean.value}"
- valueChangeListener="#{richBean.valueChangeListenerImproved}" >
-
- <f:selectItems value="#{richPickListBean.validationOptions}" />
-
- </rich:pickList>
- <rich:message id="msg" for="pickList"/>
-
- <br/><br/>
- <h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;"/>
- <a4j:commandButton id="a4jButton"
value="a4j:commandButton" render="output" />
-
- <br/><br/>
- output: <h:outputText id="output"
value="#{richPickListBean.value}"/>
+ <rich:pickList id="pickList"
addAllText="#{richPickListBean.attributes['addAllText'].value}"
+ addText="#{richPickListBean.attributes['addText'].value}"
+
columnClasses="#{richPickListBean.attributes['columnClasses'].value}"
+
columnVar="#{richPickListBean.attributes['columnVar'].value}"
+
disabled="#{richPickListBean.attributes['disabled'].value}"
+
disabledClass="#{richPickListBean.attributes['disabledClass'].value}"
+
downBottomText="#{richPickListBean.attributes['downBottomText'].value}"
+
downText="#{richPickListBean.attributes['downText'].value}"
+
headerClass="#{richPickListBean.attributes['headerClass'].value}"
+
immediate="#{richPickListBean.attributes['immediate'].value}"
+
itemClass="#{richPickListBean.attributes['itemClass'].value}"
+
listHeight="#{richPickListBean.attributes['listHeight'].value}"
+
listWidth="#{richPickListBean.attributes['listWidth'].value}"
+
maxListHeight="#{richPickListBean.attributes['maxListHeight'].value}"
+
minListHeight="#{richPickListBean.attributes['minListHeight'].value}"
+
onadditems="#{richPickListBean.attributes['onadditems'].value}"
+ onblur="#{richPickListBean.attributes['onblur'].value}"
onchange="#{richPickListBean.attributes['onchange'].value}"
+ onclick="#{richPickListBean.attributes['onclick'].value}"
+
ondblclick="#{richPickListBean.attributes['ondblclick'].value}"
+ onfocus="#{richPickListBean.attributes['onfocus'].value}"
+
onkeydown="#{richPickListBean.attributes['onkeydown'].value}"
+
onkeypress="#{richPickListBean.attributes['onkeypress'].value}"
+ onkeyup="#{richPickListBean.attributes['onkeyup'].value}"
+
onlistclick="#{richPickListBean.attributes['onlistclick'].value}"
+
onlistdblclick="#{richPickListBean.attributes['onlistdblclick'].value}"
+
onlistkeydown="#{richPickListBean.attributes['onlistkeydown'].value}"
+
onlistkeypress="#{richPickListBean.attributes['onlistkeypress'].value}"
+
onlistkeyup="#{richPickListBean.attributes['onlistkeyup'].value}"
+
onlistmousedown="#{richPickListBean.attributes['onlistmousedown'].value}"
+
onlistmousemove="#{richPickListBean.attributes['onlistmousemove'].value}"
+
onlistmouseout="#{richPickListBean.attributes['onlistmouseout'].value}"
+
onlistmouseover="#{richPickListBean.attributes['onlistmouseover'].value}"
+
onlistmouseup="#{richPickListBean.attributes['onlistmouseup'].value}"
+
onmousedown="#{richPickListBean.attributes['onmousedown'].value}"
+
onmousemove="#{richPickListBean.attributes['onmousemove'].value}"
+
onmouseout="#{richPickListBean.attributes['onmouseout'].value}"
+
onmouseover="#{richPickListBean.attributes['onmouseover'].value}"
+
onmouseup="#{richPickListBean.attributes['onmouseup'].value}"
+
onremoveitems="#{richPickListBean.attributes['onremoveitems'].value}"
+
onsourceclick="#{richPickListBean.attributes['onsourceclick'].value}"
+
onsourcedblclick="#{richPickListBean.attributes['onsourcedblclick'].value}"
+
onsourcekeydown="#{richPickListBean.attributes['onsourcekeydown'].value}"
+
onsourcekeypress="#{richPickListBean.attributes['onsourcekeypress'].value}"
+
onsourcekeyup="#{richPickListBean.attributes['onsourcekeyup'].value}"
+
onsourcemousedown="#{richPickListBean.attributes['onsourcemousedown'].value}"
+
onsourcemousemove="#{richPickListBean.attributes['onsourcemousemove'].value}"
+
onsourcemouseout="#{richPickListBean.attributes['onsourcemouseout'].value}"
+
onsourcemouseover="#{richPickListBean.attributes['onsourcemouseover'].value}"
+
onsourcemouseup="#{richPickListBean.attributes['onsourcemouseup'].value}"
+
ontargetclick="#{richPickListBean.attributes['ontargetclick'].value}"
+
ontargetdblclick="#{richPickListBean.attributes['ontargetdblclick'].value}"
+
ontargetkeydown="#{richPickListBean.attributes['ontargetkeydown'].value}"
+
ontargetkeypress="#{richPickListBean.attributes['ontargetkeypress'].value}"
+
ontargetkeyup="#{richPickListBean.attributes['ontargetkeyup'].value}"
+
ontargetmousedown="#{richPickListBean.attributes['ontargetmousedown'].value}"
+
ontargetmousemove="#{richPickListBean.attributes['ontargetmousemove'].value}"
+
ontargetmouseout="#{richPickListBean.attributes['ontargetmouseout'].value}"
+
ontargetmouseover="#{richPickListBean.attributes['ontargetmouseover'].value}"
+
ontargetmouseup="#{richPickListBean.attributes['ontargetmouseup'].value}"
+
orderable="#{richPickListBean.attributes['orderable'].value}"
+
removeAllText="#{richPickListBean.attributes['removeAllText'].value}"
+
removeText="#{richPickListBean.attributes['removeText'].value}"
+
rendered="#{richPickListBean.attributes['rendered'].value}"
+
required="#{richPickListBean.attributes['required'].value}"
+
requiredMessage="#{richPickListBean.attributes['requiredMessage'].value}"
+
selectItemClass="#{richPickListBean.attributes['selectItemClass'].value}"
+
showButton="#{richPickListBean.attributes['showButton'].value}"
+
sourceCaption="#{richPickListBean.attributes['sourceCaption'].value}"
+ style="#{richPickListBean.attributes['style'].value}"
+
styleClass="#{richPickListBean.attributes['styleClass'].value}"
+
targetCaption="#{richPickListBean.attributes['targetCaption'].value}"
+ upText="#{richPickListBean.attributes['upText'].value}"
+
upTopText="#{richPickListBean.attributes['upTopText'].value}"
validator="#{richPickListBean.validatePickListValue}"
+ value="#{richPickListBean.value}"
valueChangeListener="#{richBean.valueChangeListenerImproved}">
- </ui:define>
+ <f:selectItems value="#{richPickListBean.validationOptions}"
/>
- <ui:define name="outOfTemplateAfter">
+ </rich:pickList>
+ <rich:message id="msg" for="pickList" />
+
+ <br />
+ <br />
+ <h:commandButton id="hButton" value="h:commandButton"
style="margin-right: 10px;" />
+ <a4j:commandButton id="a4jButton"
value="a4j:commandButton" render="output" />
+
+ <br />
+ <br />
+ output: <h:outputText id="output"
value="#{richPickListBean.value}" />
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
Attributes for pickList:
<metamer:attributes value="#{richPickListBean.attributes}"
id="attributes" />
- </ui:define>
+ </ui:define>
- </ui:composition>
+</ui:composition>
</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java 2011-08-23
08:46:49 UTC (rev 22664)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/RichPickListComponentAttribute.java 2011-08-26
11:21:29 UTC (rev 22665)
@@ -25,13 +25,13 @@
/**
* Rich Pick List component attributes bean
- *
+ *
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
- *
+ *
* @version $Revision$
*/
public class RichPickListComponentAttribute extends AbstractComponentAttributes {
-
+
public void setAddAllText(String addAllText) {
setProperty("addAllText", addAllText);
}
@@ -60,6 +60,14 @@
setProperty("disabledClass", disabledClass);
}
+ public void setDownBottomText(String downBottomText) {
+ setProperty("downBottomText", downBottomText);
+ }
+
+ public void setDownText(String downText) {
+ setProperty("downText", downText);
+ }
+
public void setHeaderClass(String headerClass) {
setProperty("headerClass", headerClass);
}
@@ -88,8 +96,8 @@
setProperty("minListHeight", minListHeight);
}
- public void setOnadditem(String onadditem) {
- setProperty("onadditem", onadditem);
+ public void setOnadditems(String onadditems) {
+ setProperty("onadditems", onadditems);
}
public void setOnblur(String onblur) {
@@ -184,8 +192,8 @@
setProperty("onmouseup", onmouseup);
}
- public void setOnremoveitem(String onremoveitem) {
- setProperty("onremoveitem", onremoveitem);
+ public void setOnremoveitems(String onremoveitems) {
+ setProperty("onremoveitems", onremoveitems);
}
public void setOnsourceclick(String onsourceclick) {
@@ -267,7 +275,7 @@
public void setOntargetmouseup(String ontargetmouseup) {
setProperty("ontargetmouseup", ontargetmouseup);
}
-
+
public void setOrderable(Boolean orderable) {
setProperty("orderable", orderable);
}
@@ -316,6 +324,14 @@
setProperty("targetCaption", targetCaption);
}
+ public void setUpText(String upText) {
+ setProperty("upText", upText);
+ }
+
+ public void setUpTopText(String upTopText) {
+ setProperty("upTopText", upTopText);
+ }
+
public void setValidator(String validator) {
setProperty("validator", validator);
}
@@ -331,5 +347,5 @@
public void setValueChangeListener(String valueChangeListener) {
setProperty("valueChangeListener", valueChangeListener);
}
-
+
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java 2011-08-23
08:46:49 UTC (rev 22664)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richPickList/TestPickList.java 2011-08-26
11:21:29 UTC (rev 22665)
@@ -22,6 +22,7 @@
package org.richfaces.tests.metamer.ftest.richPickList;
import static java.text.MessageFormat.format;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
@@ -31,122 +32,129 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.utils.URLUtils;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
import org.testng.annotations.Test;
/**
* Test for rich:pickList on page faces/components/richPickList/simple.xhtml.
- *
+ *
* @author <a href="mailto:jjamrich@redhat.com">Jan Jamrich</a>
- *
+ *
* @version $Revision$
*/
public class TestPickList extends AbstractMetamerTest {
-
+
private RichPickListComponentAttribute attributes = new
RichPickListComponentAttribute();
-
+
private JQueryLocator phaseListenerFormat = jq("div#phasesPanel
li:eq({0})");
-
+
private JQueryLocator hSubmit = pjq("input[id$=hButton]");
private JQueryLocator a4jSubmit = pjq("input[id$=a4jButton]");
-
+
private JQueryLocator pickListTop = pjq("div.rf-pick[id$=pickList]");
private JQueryLocator output = pjq("span[id$=output]");
private JQueryLocator pickListMsgBox = pjq("span.rf-msg >
span[id$=msg:form:pickList] > span.rf-msg-det");
private JQueryLocator targetCaptionLocator = pjq("div[id$=pickListTargetList]
> div.rf-pick-target-caption");
private JQueryLocator sourceCaptionLocator = pjq("div[id$=pickListSourceList]
> div.rf-pick-source-caption");
-
+
private JQueryLocator pickListCtrl = pjq("div.rf-pick-lst-scrl");
private JQueryLocator pickListOrderingControlsContainer =
pjq("table[id$=pickListTarget] td:eq(1)");
- private JQueryLocator pickListOrderingCtrlFormat =
- pickListOrderingControlsContainer.getDescendant(jq("tr td
button:contains({0})"));
-
+ private JQueryLocator pickListOrderingCtrlFormat = pickListOrderingControlsContainer
+ .getDescendant(jq("tr td button:contains({0})"));
+
private JQueryLocator pickListSrcItems =
pjq("div[id$=pickListSourceItems]");
private JQueryLocator pickListSrcItem =
pickListSrcItems.getChild(jq("div[id$=pickListItem{0}]"));
private JQueryLocator pickListSrcItemByText =
pickListSrcItems.getChild(jq("div.rf-pick-opt:contains({0})"));
-
+
private JQueryLocator pickListTargetItems =
pjq("div[id$=pickListTargetItems]");
private JQueryLocator pickListTargetItem =
pickListTargetItems.getChild(jq("div[id$=pickListItem{0}]"));
private JQueryLocator pickListTargetItemByText =
pickListTargetItems.getChild(jq("div.rf-pick-opt:contains({0})"));
-
+
// after click on 'add' button, item is moved to 'staging' container
(not child of #pickListTargetItems)
private JQueryLocator pickListTrgtItemsStage = pjq("div[id$=pickListTargetList]
div.rf-pick-lst-scrl");
private JQueryLocator pickListTrgtItemStage =
pickListTrgtItemsStage.getChild(jq("div[id$=pickListItem{0}]"));
- private JQueryLocator pickListTrgtItemStageByText =
pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:contains({0})"));
-
+ private JQueryLocator pickListTrgtItemStageByText = pickListTrgtItemsStage
+ .getChild(jq("div.rf-pick-opt:contains({0})"));
+
private JQueryLocator addBtn = pjq("button.rf-pick-add");
private JQueryLocator addAllBtn = pjq("button.rf-pick-add-all");
private JQueryLocator removeBtn = pjq("button.rf-pick-rem");
private JQueryLocator removeAllBtn = pjq("button.rf-pick-rem-all");
-
+
private Attribute classAttr = new Attribute("class");
private Attribute disabledAttr = new Attribute("disabled");
private Attribute styleAttr = new Attribute("style");
-
+
private String STYLE_CLASS_ITEM_DISABLED = "rf-pick-opt-dis";
private String STYLE_CLASS_BTN_DISABLED = "rf-pick-btn-dis";
private String STYLE_CLASS_ITEM_SELECTED = "rf-pick-sel";
private String STYLE_CLASS_ORD_BTN_DISABLED = "rf-ord-btn-dis";
-
+
private String phaseListenerLogFormat = "*3 value changed: {0} -> {1}";
@Override
public URL getTestUrl() {
return URLUtils.buildUrl(contextPath,
"faces/components/richPickList/simple.xhtml");
}
-
+
private void addItem(int id) {
selenium.click(pickListSrcItem.format(id));
selenium.click(addBtn);
}
-
+
private void addItem(String value) {
selenium.click(pickListSrcItemByText.format(value));
selenium.click(addBtn);
}
-
+
private void removeItem(int id) {
-
- if (selenium.isElementPresent(pickListTrgtItemStage.format(id))){
+
+ if (selenium.isElementPresent(pickListTrgtItemStage.format(id))) {
selenium.click(pickListTrgtItemStage.format(id));
} else {
// if doesn't exist at this point, there we don't know what happens
selenium.click(pickListTargetItem.format(id));
}
-
+
selenium.click(removeBtn);
}
-
+
+ private void removeItem(String value) {
+ selenium.click(pickListTargetItemByText.format(value));
+ selenium.click(removeBtn);
+ }
+
private void addAllItems() {
selenium.click(addAllBtn);
}
-
- private void removeAllItems(){
+
+ private void removeAllItems() {
selenium.click(removeAllBtn);
}
-
+
private String getOrderBtnClass(String label) {
- return selenium.getAttribute(
- pickListOrderingCtrlFormat.format(label).getAttribute(classAttr));
+ return
selenium.getAttribute(pickListOrderingCtrlFormat.format(label).getAttribute(classAttr));
}
-
+
@Test
public void testAddAllText() {
String label = "xxx";
- attributes.setAddAllText(label);
- assertTrue(label.equals(selenium.getText(addAllBtn)));
+ attributes.setAddAllText(label);
+ assertTrue(label.equals(selenium.getText(addAllBtn)));
}
@Test
public void testAddText() {
String label = "xxx";
- attributes.setAddText(label);
+ attributes.setAddText(label);
assertTrue(label.equals(selenium.getText(addBtn)));
}
-
+
// @Test
public void testColumnClasses() {
// TODO JJa 2011-08-05: ask Brian about this attr:
@@ -161,35 +169,34 @@
@Test
public void testDisabled() {
-
+
// add first item [idx=0], then submit and disable
addItem(0);
selenium.click(hSubmit);
-
+
attributes.setDisabled(Boolean.TRUE);
-
+
// check if source items are disabled (check second - first item after 0 item
added)
- String pickListSourceItemClass = selenium.getAttribute(
- pickListSrcItem.format(1).getAttribute(classAttr));
+ String pickListSourceItemClass =
selenium.getAttribute(pickListSrcItem.format(1).getAttribute(classAttr));
assertTrue(pickListSourceItemClass.contains(STYLE_CLASS_ITEM_DISABLED));
-
+
// all buttons should be disabled
assertTrue(selenium.getAttribute(addBtn.getAttribute(classAttr)).contains(STYLE_CLASS_BTN_DISABLED));
assertTrue("disabled".equals(selenium.getAttribute(addBtn.getAttribute(disabledAttr))));
-
+
assertTrue(selenium.getAttribute(addAllBtn.getAttribute(classAttr)).contains(STYLE_CLASS_BTN_DISABLED));
assertTrue("disabled".equals(selenium.getAttribute(addAllBtn.getAttribute(disabledAttr))));
-
+
assertTrue(selenium.getAttribute(removeBtn.getAttribute(classAttr)).contains(STYLE_CLASS_BTN_DISABLED));
assertTrue("disabled".equals(selenium.getAttribute(removeBtn.getAttribute(disabledAttr))));
-
+
assertTrue(selenium.getAttribute(removeAllBtn.getAttribute(classAttr)).contains(STYLE_CLASS_BTN_DISABLED));
assertTrue("disabled".equals(selenium.getAttribute(removeAllBtn.getAttribute(disabledAttr))));
-
+
// check item added to target list if disabled (remember - item index in id
didn't change)
-
assertTrue(selenium.getAttribute(pickListTargetItem.format(0).getAttribute(classAttr))
- .contains(STYLE_CLASS_ITEM_DISABLED));
-
+
assertTrue(selenium.getAttribute(pickListTargetItem.format(0).getAttribute(classAttr)).contains(
+ STYLE_CLASS_ITEM_DISABLED));
+
}
@Test
@@ -198,18 +205,34 @@
String disabledClass = "my-cool-disabled-class";
attributes.setDisabledClass(disabledClass);
attributes.setDisabled(Boolean.TRUE);
-
+
String found = selenium.getAttribute(pickListTop.getAttribute(classAttr));
assertTrue(found != null);
assertTrue(found.contains(disabledClass), "Following class " + found +
" doesn't coitains " + disabledClass);
}
@Test
+ public void testDownBottomText() {
+ attributes.setDownBottomText("xxx");
+ attributes.setOrderable(Boolean.TRUE);
+
assertEquals(selenium.getText(pickListOrderingControlsContainer.getDescendant(jq("button:eq(3)"))),
"xxx",
+ "Button's text did not change.");
+ }
+
+ @Test
+ public void testDownText() {
+ attributes.setDownText("xxx");
+ attributes.setOrderable(Boolean.TRUE);
+
assertEquals(selenium.getText(pickListOrderingControlsContainer.getDescendant(jq("button:eq(2)"))),
"xxx",
+ "Button's text did not change.");
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-11335")
public void testHeaderClass() {
String headerClass = "my-cool-header-class";
attributes.setHeaderClass(headerClass);
-
+
String found = selenium.getAttribute(pickListTop.getAttribute(classAttr));
assertTrue(found != null);
assertTrue(found.contains(headerClass));
@@ -220,18 +243,18 @@
attributes.setImmediate(Boolean.TRUE);
addItem("richfaces");
selenium.click(a4jSubmit);
-
+
// for immediate submit is record in 3rd line
- waitModel.until(textEquals.locator(phaseListenerFormat.format(2))
- .text(format(phaseListenerLogFormat, "[]",
"[richfaces]")));
-
+ waitModel.until(textEquals.locator(phaseListenerFormat.format(2)).text(
+ format(phaseListenerLogFormat, "[]", "[richfaces]")));
+
}
@Test
public void testItemClass() {
String itemClass = "xxx";
attributes.setItemClass(itemClass);
-
+
String classVal =
selenium.getAttribute(pickListSrcItemByText.format("richfaces").getAttribute(classAttr));
assertTrue(classVal != null);
assertTrue(classVal.contains(itemClass));
@@ -241,9 +264,9 @@
public void testListHeight() {
String listHeight = "333";
attributes.setListHeight(listHeight);
-
+
String found = selenium.getAttribute(pickListCtrl.getAttribute(styleAttr));
-
+
assertTrue(found != null);
assertTrue(found.contains(listHeight));
}
@@ -252,9 +275,9 @@
public void testListWidth() {
String listWidth = "222";
attributes.setListWidth(listWidth);
-
+
String found = selenium.getAttribute(pickListCtrl.getAttribute(styleAttr));
-
+
assertTrue(found != null);
assertTrue(found.contains(listWidth));
}
@@ -263,9 +286,9 @@
public void testMaxListHeight() {
String maxListHeight = "345";
attributes.setMaxListHeight(maxListHeight);
-
+
String found = selenium.getAttribute(pickListCtrl.getAttribute(styleAttr));
-
+
assertTrue(found != null);
assertTrue(found.contains(maxListHeight));
}
@@ -274,349 +297,356 @@
public void testMinListHeight() {
String minListHeight = "234";
attributes.setMinListHeight(minListHeight);
-
+
String found = selenium.getAttribute(pickListCtrl.getAttribute(styleAttr));
-
+
assertTrue(found != null);
assertTrue(found.contains(minListHeight));
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11322")
- public void testOnadditem() {
- testFireEvent(new Event("additem"), pickListTop);
+ public void testOnadditems() {
+ attributes.setOnadditems("metamerEvents += \"additems \"");
+ addItem("North Carolina");
+ waitGui.failWith("Attribute onadditems does not work
correctly").until(
+ new EventFiredCondition(new Event("additems")));
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnblur() {
- testFireEvent(new Event("blur"), pickListTop);
+ testFireEvent(Event.BLUR, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnchange() {
- testFireEvent(new Event("change"), pickListTop);
+ attributes.setOnchange("metamerEvents += \"change \"");
+ addItem("North Carolina");
+ waitGui.failWith("Attribute onchange does not work correctly").until(
+ new EventFiredCondition(new Event("change")));
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnclick() {
- testFireEvent(new Event("click"), pickListTop);
+ testFireEvent(Event.CLICK, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOndblclick() {
- testFireEvent(new Event("dblclick"), pickListTop);
+ testFireEvent(Event.DBLCLICK, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnfocus() {
- testFireEvent(new Event("focus"), pickListTop);
+ testFireEvent(Event.FOCUS, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnkeydown() {
- testFireEvent(new Event("keydown"), pickListTop);
+ testFireEvent(Event.KEYDOWN, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnkeypress() {
- testFireEvent(new Event("keypress"), pickListTop);
+ testFireEvent(Event.KEYPRESS, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnkeyup() {
- testFireEvent(new Event("keyup"), pickListTop);
+ testFireEvent(Event.KEYUP, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistclick() {
- testFireEvent(new Event("listclick"), pickListTop);
+ testFireEvent(Event.CLICK, pickListTop, "listclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistdblclick() {
- testFireEvent(new Event("listdblclick"), pickListTop);
+ testFireEvent(Event.DBLCLICK, pickListTop, "listdblclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistkeydown() {
- testFireEvent(new Event("listkeydown"), pickListTop);
+ testFireEvent(Event.KEYDOWN, pickListTop, "listkeydown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistkeypress() {
- testFireEvent(new Event("listkeypress"), pickListTop);
+ testFireEvent(Event.KEYPRESS, pickListTop, "listkeypress");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistkeyup() {
- testFireEvent(new Event("listkeyup"), pickListTop);
+ testFireEvent(Event.KEYUP, pickListTop, "listkeyup");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistmousedown() {
- testFireEvent(new Event("listmousedown"), pickListTop);
+ testFireEvent(Event.MOUSEDOWN, pickListTop, "listmousedown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistmousemove() {
- testFireEvent(new Event("listmousemove"), pickListTop);
+ testFireEvent(Event.MOUSEMOVE, pickListTop, "listmousemove");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistmouseout() {
- testFireEvent(new Event("listmouseout"), pickListTop);
+ testFireEvent(Event.MOUSEOUT, pickListTop, "listmouseout");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistmouseover() {
- testFireEvent(new Event("listmouseover"), pickListTop);
+ testFireEvent(Event.MOUSEOVER, pickListTop, "listmouseover");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnlistmouseup() {
- testFireEvent(new Event("listmouseup"), pickListTop);
+ testFireEvent(Event.MOUSEUP, pickListTop, "listmouseup");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnmousedown() {
- testFireEvent(new Event("mousedown"), pickListTop);
+ testFireEvent(Event.MOUSEDOWN, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnmousemove() {
- testFireEvent(new Event("mousemove"), pickListTop);
+ testFireEvent(Event.MOUSEMOVE, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnmouseout() {
- testFireEvent(new Event("mouseout"), pickListTop);
+ testFireEvent(Event.MOUSEOUT, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnmouseover() {
- testFireEvent(new Event("mouseover"), pickListTop);
+ testFireEvent(Event.MOUSEOVER, pickListTop);
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnmouseup() {
- testFireEvent(new Event("mouseup"), pickListTop);
+ testFireEvent(Event.MOUSEUP, pickListTop);
}
@Test
- @IssueTracking("https://issues.jboss.org/browse/RF-11322")
- public void testOnremoveitem() {
- testFireEvent(new Event("emoveitem"), pickListTop);
+ public void testOnremoveitems() {
+ attributes.setOnremoveitems("metamerEvents += \"removeitems
\"");
+ addItem("North Carolina");
+ addItem("Hawaii");
+ addItem("Arizona");
+ removeItem("Hawaii");
+ waitGui.failWith("Attribute onremoveitems does not work
correctly").until(
+ new EventFiredCondition(new Event("removeitems")));
+
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourceclick() {
- testFireEvent(new Event("sourceclick"), pickListTop);
+ testFireEvent(Event.CLICK, pickListTop, "sourceclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcedblclick() {
- testFireEvent(new Event("sourcedblclick"), pickListTop);
+ testFireEvent(Event.DBLCLICK, pickListTop, "sourcedblclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcekeydown() {
- testFireEvent(new Event("sourcekeydown"), pickListTop);
+ testFireEvent(Event.KEYDOWN, pickListTop, "sourcekeydown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcekeypress() {
- testFireEvent(new Event("sourcekeypress"), pickListTop);
+ testFireEvent(Event.KEYPRESS, pickListTop, "sourcekeypress");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcekeyup() {
- testFireEvent(new Event("sourcekeyup"), pickListTop);
+ testFireEvent(Event.KEYUP, pickListTop, "sourcekeyup");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcemousedown() {
- testFireEvent(new Event("sourcemousedown"), pickListTop);
+ testFireEvent(Event.MOUSEDOWN, pickListTop, "sourcemousedown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcemousemove() {
- testFireEvent(new Event("sourcemousemove"), pickListTop);
+ testFireEvent(Event.MOUSEMOVE, pickListTop, "sourcemousemove");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcemouseout() {
- testFireEvent(new Event("sourcemouseout"), pickListTop);
+ testFireEvent(Event.MOUSEOUT, pickListTop, "sourcemouseout");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcemouseover() {
- testFireEvent(new Event("sourcemouseover"), pickListTop);
+ testFireEvent(Event.MOUSEOVER, pickListTop, "sourcemouseover");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOnsourcemouseup() {
- testFireEvent(new Event("sourcemouseup"), pickListTop);
+ testFireEvent(Event.MOUSEUP, pickListTop, "sourcemouseup");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetclick() {
- testFireEvent(new Event("targetclick"), pickListTop);
+ testFireEvent(Event.CLICK, pickListTop, "targetclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetdblclick() {
- testFireEvent(new Event("targetdblclick"), pickListTop);
+ testFireEvent(Event.DBLCLICK, pickListTop, "targetdblclick");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetkeydown() {
- testFireEvent(new Event("targetkeydown"), pickListTop);
+ testFireEvent(Event.KEYDOWN, pickListTop, "targetkeydown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetkeypress() {
- testFireEvent(new Event("targetkeypress"), pickListTop);
+ testFireEvent(Event.KEYPRESS, pickListTop, "targetkeypress");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetkeyup() {
- testFireEvent(new Event("targetkeyup"), pickListTop);
+ testFireEvent(Event.KEYUP, pickListTop, "targetkeyup");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetmousedown() {
- testFireEvent(new Event("targetmousedown"), pickListTop);
+ testFireEvent(Event.MOUSEDOWN, pickListTop, "targetmousedown");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetmousemove() {
- testFireEvent(new Event("targetmousemove"), pickListTop);
+ testFireEvent(Event.MOUSEMOVE, pickListTop, "targetmousemove");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetmouseout() {
- testFireEvent(new Event("targetmouseout"), pickListTop);
+ testFireEvent(Event.MOUSEOUT, pickListTop, "targetmouseout");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetmouseover() {
- testFireEvent(new Event("targetmouseover"), pickListTop);
+ testFireEvent(Event.MOUSEOVER, pickListTop, "targetmouseover");
}
@Test
@IssueTracking("https://issues.jboss.org/browse/RF-11322")
public void testOntargetmouseup() {
- testFireEvent(new Event("targetmouseup"), pickListTop);
+ testFireEvent(Event.MOUSEUP, pickListTop, "targetmouseup");
}
-
+
@Test
public void testOrderable() {
-
+
// firstly check ordering controls doesn't appear near pickList if not
"orderable"
attributes.setOrderable(Boolean.FALSE);
assertFalse(selenium.isElementPresent(pickListOrderingControlsContainer));
-
+
// then make sure that controls appear near pickList when allow ordering
behavior
attributes.setOrderable(Boolean.TRUE);
assertTrue(selenium.isElementPresent(pickListOrderingControlsContainer));
-
+
// then add some items to target list
addItem("Alaska");
addItem("California");
addItem("Delaware");
-
+
// all items should remain selected and in this case ordering controls should be
disabled
- String classAttrVal = selenium.getAttribute(
-
pickListTrgtItemStageByText.format("Alaska").getAttribute(classAttr));
-
+ String classAttrVal =
selenium.getAttribute(pickListTrgtItemStageByText.format("Alaska")
+ .getAttribute(classAttr));
+
assertTrue(classAttrVal != null);
assertTrue(classAttrVal.contains(STYLE_CLASS_ITEM_SELECTED));
-
- classAttrVal = selenium.getAttribute(
-
pickListTrgtItemStageByText.format("California").getAttribute(classAttr));
-
+
+ classAttrVal =
selenium.getAttribute(pickListTrgtItemStageByText.format("California").getAttribute(classAttr));
+
assertTrue(classAttrVal != null);
assertTrue(classAttrVal.contains(STYLE_CLASS_ITEM_SELECTED));
-
- classAttrVal = selenium.getAttribute(
-
pickListTrgtItemStageByText.format("Delaware").getAttribute(classAttr));
-
+
+ classAttrVal =
selenium.getAttribute(pickListTrgtItemStageByText.format("Delaware").getAttribute(classAttr));
+
assertTrue(classAttrVal != null);
assertTrue(classAttrVal.contains(STYLE_CLASS_ITEM_SELECTED));
-
+
// so check ordering controls if they are disabled
assertTrue(getOrderBtnClass("First").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertTrue(getOrderBtnClass("Up").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertTrue(getOrderBtnClass("Down").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertTrue(getOrderBtnClass("Last").contains(STYLE_CLASS_ORD_BTN_DISABLED));
-
+
// now is time to select one item. This should cause ordering controls enable
selenium.click(pickListTrgtItemStageByText.format("Alaska"));
-
+
// since it was first item, "Down" and "Last" buttons should
be enabled
assertTrue(getOrderBtnClass("First").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertTrue(getOrderBtnClass("Up").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertFalse(getOrderBtnClass("Down").contains(STYLE_CLASS_ORD_BTN_DISABLED));
assertFalse(getOrderBtnClass("Last").contains(STYLE_CLASS_ORD_BTN_DISABLED));
-
+
// move "Alaska" to last
selenium.click(pickListOrderingCtrlFormat.format("Last"));
-
+
// verify that "Alaska" is last item (select 3rd item, and verify
text)
- assertTrue("Alaska".equals(
-
selenium.getText(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:eq(2)")))));
-
+
assertTrue("Alaska".equals(selenium.getText(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:eq(2)")))));
+
// then move "Alaska" one step "up"
selenium.click(pickListOrderingCtrlFormat.format("Up"));
- assertTrue("Alaska".equals(
-
selenium.getText(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:eq(1)")))));
-
+
assertTrue("Alaska".equals(selenium.getText(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt:eq(1)")))));
+
// and then verify if all items are submitted in user defined order as well
- selenium.click(a4jSubmit);
+ selenium.click(a4jSubmit);
waitModel.until(textEquals.locator(output).text("[California, Alaska,
Delaware]"));
-
+
}
@Test
@@ -629,7 +659,7 @@
@Test
public void testRemoveText() {
String label = "xxx";
- attributes.setRemoveText(label);
+ attributes.setRemoveText(label);
assertTrue(label.equals(selenium.getText(removeBtn)));
}
@@ -645,12 +675,12 @@
attributes.setRequired(Boolean.TRUE);
addItem("richfaces");
selenium.click(a4jSubmit);
-
+
assertFalse(selenium.isElementPresent(pickListMsgBox));
-
+
removeAllItems();
- selenium.click(a4jSubmit);
-
+ selenium.click(a4jSubmit);
+
waitModel.until(elementPresent.locator(pickListMsgBox));
assertTrue(selenium.isElementPresent(pickListMsgBox));
}
@@ -660,10 +690,10 @@
public void testRequiredMessage() {
String requiredMessage = "Test validation message";
attributes.setRequiredMessage(requiredMessage);
-
+
attributes.setRequired(Boolean.TRUE);
selenium.click(a4jSubmit);
-
+
assertEquals(selenium.getText(pickListMsgBox), requiredMessage);
}
@@ -671,9 +701,9 @@
public void testSelectItemClass() {
String selectItemClass = "my-select-item-class";
attributes.setSelectItemClass(selectItemClass);
-
+
selenium.click(pickListSrcItemByText.format("richfaces"));
-
+
String classVal =
selenium.getAttribute(pickListSrcItemByText.format("richfaces").getAttribute(classAttr));
assertTrue(classVal.contains(selectItemClass));
}
@@ -688,7 +718,7 @@
public void testSourceCaption() {
String sourceCaption = "This is source";
attributes.setSourceCaption(sourceCaption);
-
+
waitModel.until(textEquals.locator(sourceCaptionLocator).text(sourceCaption));
}
@@ -698,7 +728,7 @@
}
@Test
- public void testStyleClass() {
+ public void testStyleClass() {
testStyleClass(pickListTop, "styleClass");
}
@@ -706,19 +736,35 @@
public void testTargetCaption() {
String targetCaption = "This is target";
attributes.setTargetCaption(targetCaption);
-
+
waitModel.until(elementPresent.locator(targetCaptionLocator));
assertTrue(targetCaption.equals(selenium.getText(targetCaptionLocator)));
}
@Test
+ public void testUpText() {
+ attributes.setUpText("xxx");
+ attributes.setOrderable(Boolean.TRUE);
+
assertEquals(selenium.getText(pickListOrderingControlsContainer.getDescendant(jq("button:eq(1)"))),
"xxx",
+ "Button's text did not change.");
+ }
+
+ @Test
+ public void testUpTopText() {
+ attributes.setUpTopText("xxx");
+ attributes.setOrderable(Boolean.TRUE);
+
assertEquals(selenium.getText(pickListOrderingControlsContainer.getDescendant(jq("button:eq(0)"))),
"xxx",
+ "Button's text did not change.");
+ }
+
+ @Test
@IssueTracking("https://issues.jboss.org/browse/RF-11337")
public void testValidator() {
addAllItems();
selenium.click(a4jSubmit);
-
+
// following message is predefined by validator
- waitModel.until(textEquals.locator(pickListMsgBox).text("PickList don't
like '@' char!"));
+ waitModel.until(textEquals.locator(pickListMsgBox).text("PickList don't
like '@' char!"));
}
@Test
@@ -726,9 +772,9 @@
public void testValidatorMessage() {
String validationMessage = "We are sorry, but @ is not allowed to join
us!";
attributes.setValidatorMessage(validationMessage);
- addAllItems();
+ addAllItems();
selenium.click(a4jSubmit);
-
+
// verify our own validation message
waitModel.until(textEquals.locator(pickListMsgBox).text(validationMessage));
}
@@ -737,81 +783,81 @@
public void testValue() {
addItem("richfaces"); // "richfaces"
selenium.click(a4jSubmit);
-
+
waitModel.until(textEquals.locator(output).text("[richfaces]"));
}
@Test
public void testValueChangeListener() {
- addItem("richfaces"); //
-
+ addItem("richfaces"); //
+
selenium.click(a4jSubmit);
-
+
// valueChangeListener output as 4th record
- waitModel.until(textEquals.locator(phaseListenerFormat.format(3))
- .text(format(phaseListenerLogFormat, "[]",
"[richfaces]")));
-
+ waitModel.until(textEquals.locator(phaseListenerFormat.format(3)).text(
+ format(phaseListenerLogFormat, "[]", "[richfaces]")));
+
addItem("Alabama");
selenium.click(a4jSubmit);
-
+
// valueChangeListener output as 4th record
- waitModel.until(textEquals.locator(phaseListenerFormat.format(3))
- .text(format(phaseListenerLogFormat, "[richfaces]",
"[richfaces, Alabama]")));
+ waitModel.until(textEquals.locator(phaseListenerFormat.format(3)).text(
+ format(phaseListenerLogFormat, "[richfaces]", "[richfaces,
Alabama]")));
}
-
+
/**
* Verify that addBtn is disabled until item from source items picked
*/
@Test
public void testDisableAddBtn() {
int itemIdx = 0;
-
+
String addBtnClass = selenium.getAttribute(addBtn.getAttribute(classAttr));
-
+
// assert that button is visually disabled
assertTrue(addBtnClass != null);
assertTrue(addBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
-
+
selenium.click(pickListSrcItem.format(itemIdx));
-
+
addBtnClass = selenium.getAttribute(addBtn.getAttribute(classAttr));
-
+
assertFalse(addBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
-
+
}
-
+
/**
* Verify that removeBtn is disabled until item from target items picked
*/
@Test
public void testDisableRemoveBtn() {
int itemIdx = 0;
-
+
addAllItems();
-
+
String removeBtnClass =
selenium.getAttribute(removeBtn.getAttribute(classAttr));
-
+
// assert that button is visually disabled
assertTrue(removeBtnClass != null);
assertTrue(removeBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
-
+
selenium.click(pickListTrgtItemStage.format(itemIdx));
-
+
removeBtnClass = selenium.getAttribute(removeBtn.getAttribute(classAttr));
-
+
assertFalse(removeBtnClass.contains(STYLE_CLASS_BTN_DISABLED));
}
-
+
/**
* Verify addAll button working correctly
*/
@Test
- public void testAddAllBtn(){
+ public void testAddAllBtn() {
addAllItems();
-
+
waitModel.until(countEquals.count(54).locator(pickListTrgtItemsStage.getChild(jq("div.rf-pick-opt"))));
}
-
+
/**
* Verify removeAll button working correctly
*/
@@ -819,19 +865,19 @@
public void testRemoveAllBtn() {
int itemAtIdx = 50;
addAllItems();
-
+
// validator doesn't allow '@', so remove it before save
removeItem(itemAtIdx);
-
+
selenium.click(hSubmit);
waitModel.until(countEquals.count(53).locator(pickListTargetItems.getChild(jq("div.rf-pick-opt"))));
-
+
removeAllItems();
// nothing should remain in target container
waitModel.until(countEquals.count(0).locator(pickListTargetItems.getChild(jq("div.rf-pick-opt"))));
-
+
}
-
+
/**
* Verify submit by JSF submit button
*/
@@ -839,19 +885,19 @@
public void testSaveJSF() {
int itemIdx = 0;
addItem(itemIdx);
-
+
// verify that item "added" to target list really appears in target
(staging) container.
waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
-
+
// submit by JSF submit btn:
selenium.click(hSubmit);
-
+
// now item moved to target and submitted should appear in target (not staging)
waitModel.until(elementPresent.locator(pickListTargetItem.format(itemIdx)));
-
+
// todo check output!
}
-
+
/**
* Verify submit by ajax button
*/
@@ -859,84 +905,85 @@
public void testSaveAjax() {
int itemIdx = 0;
addItem(itemIdx);
-
+
// verify that item "added" to target list really appears in target
(staging) container.
waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
-
+
// submit by ajax btn:
selenium.click(a4jSubmit);
-
- // and here is difference between jsf and ajax submit.
+
+ // and here is difference between jsf and ajax submit.
// With ajax, submitted item doesn'e move from stage to target
waitModel.until(elementPresent.locator(pickListTrgtItemStage.format(itemIdx)));
-
+
// now call rerenderAll on whole page
selenium.click(rerenderAllIcon);
-
+
// now item moved to target and submitted should appear in target (not staging)
waitModel.until(elementPresent.locator(pickListTargetItem.format(itemIdx)));
-
+
// todo check output!
}
-
+
/**
- * Verify that item keep selected even moved from source to target,
- * or back. If selected Alaska from sources, and then added to target,
- * it should remain selected in target list
+ * Verify that item keep selected even moved from source to target, or back. If
selected Alaska from sources, and
+ * then added to target, it should remain selected in target list
+ *
* @return
*/
@Test
public void testKeepSelected() {
int itemIdx = 0;
-
+
String classBeforeSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
- assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
+ assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item shouldn't be selected before any click made! Current
class(es) found: " + classBeforeSelect);
-
+
selenium.click(pickListSrcItem.format(itemIdx));
-
+
String pickedItemText = selenium.getText(pickListSrcItem.format(itemIdx));
-
+
String classAfterSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterSelect.contains(STYLE_CLASS_ITEM_SELECTED),
- "pickList item should be selected after click on item was made. Current
class(es) found: " + classAfterSelect);
-
+ "pickList item should be selected after click on item was made. Current
class(es) found: "
+ + classAfterSelect);
+
// now move selected item to target list
selenium.click(addBtn);
-
- waitGui.until(elementPresent.locator(jq("div[id$=pickListTargetList]
div.rf-pick-lst-scrl > div[id$=pickListItem0]")));
-
+
+ waitGui.until(elementPresent
+ .locator(jq("div[id$=pickListTargetList] div.rf-pick-lst-scrl >
div[id$=pickListItem0]")));
+
// and check if item remain selected
String classAfterMove =
selenium.getAttribute(pickListTrgtItemStage.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterMove.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item should keep selected after move to target list. Current
class(es) found: " + classAfterMove);
-
+
// verify that the same text is within item with the same ID index
assertEquals(selenium.getText(pickListTrgtItemStage.format(itemIdx)),
pickedItemText);
}
-
+
/**
- * Verify that selected item is moved to appropriate list
- * after click on add/remove button
+ * Verify that selected item is moved to appropriate list after click on add/remove
button
*/
@Test
public void testMoveItem() {
int itemIdx = 5;
-
+
// select item
selenium.click(pickListSrcItem.format(itemIdx));
-
+
String pickedItemText = selenium.getText(pickListSrcItem.format(itemIdx));
-
+
// add item to target list
selenium.click(addBtn);
-
+
// item index doesn't change when moved to target list
assertTrue(selenium.isElementPresent(pickListTrgtItemStage.format(itemIdx)));
// verify that the same text is within item with the same ID index
assertEquals(selenium.getText(pickListTrgtItemStage.format(itemIdx)),
pickedItemText);
}
-
+
/**
* Verify that item get selected when click on it
*/
@@ -944,18 +991,18 @@
public void testGetSelected() {
// this item will be selected and verified appropriate class change/add
int itemIdx = 0;
-
+
String classBeforeSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
- assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
+ assertFalse(classBeforeSelect.contains(STYLE_CLASS_ITEM_SELECTED),
"pickList item shouldn't be selected before any click made! Current
class(es) found: " + classBeforeSelect);
-
+
selenium.click(pickListSrcItem.format(itemIdx));
-
+
String classAfterSelect =
selenium.getAttribute(pickListSrcItem.format(itemIdx).getAttribute(classAttr));
assertTrue(classAfterSelect.contains(STYLE_CLASS_ITEM_SELECTED),
- "pickList item should be selected after click on item was made. Current
class(es) found: " + classAfterSelect);
+ "pickList item should be selected after click on item was made. Current
class(es) found: "
+ + classAfterSelect);
}
-
}