Author: sergeyhalipov
Date: 2008-05-21 13:38:32 -0400 (Wed, 21 May 2008)
New Revision: 8681
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java
Log:
Selenium tests for ordering list component completed.
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java 2008-05-21
16:29:08 UTC (rev 8680)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java 2008-05-21
17:38:32 UTC (rev 8681)
@@ -24,6 +24,8 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import javax.faces.component.UIComponent;
@@ -42,6 +44,7 @@
for (int i = 0; i < 4; i++) {
items.add(new Item("item" + i));
}
+ selection = new HashSet<Item>();
}
public Object getActionResult() {
@@ -79,6 +82,18 @@
public void setItems(List<Item> items) {
this.items = items;
}
+
+ public String getSelectionString() {
+ StringBuffer buff = new StringBuffer();
+ for (Iterator<Item> it = selection.iterator(); it.hasNext();) {
+ Item item = it.next();
+ buff.append(item.getName());
+ if (it.hasNext()) {
+ buff.append(',');
+ }
+ }
+ return buff.toString();
+ }
private class ItemConverter implements Converter {
@@ -112,7 +127,7 @@
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("actionResult",
name);
return null;
}
-
+
public Item(String name) {
super();
this.name = name;
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml 2008-05-21
16:29:08 UTC (rev 8680)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml 2008-05-21
17:38:32 UTC (rev 8681)
@@ -18,7 +18,14 @@
captionLabel="Caption Label"
selection="#{orderingListBean.selection}"
- activeItem="#{orderingListBean.activeItem}" >
+ activeItem="#{orderingListBean.activeItem}"
+
+ onbottomclick="window.status = 'bottom';"
+ ondownclick="window.status = 'down';"
+ ontopclick="window.status = 'top';"
+ onupclick="window.status = 'up';"
+ onorderchanged="window.status += ' orderchanged';"
+ >
<h:column>
<f:facet name="header">
@@ -30,7 +37,7 @@
<f:facet name="header">
<h:outputText value="Ajax Action" />
</f:facet>
- <a4j:commandButton value="Ajax Action"
reRender="actionResult,messages"
+ <a4j:commandButton value="Ajax Action" reRender="results"
action="#{item.action}" id="#{item.name}_ajax" />
</h:column>
<h:column>
@@ -41,10 +48,14 @@
</h:column>
</rich:orderingList>
+ <br/>
+ <h:panelGroup id="results" >
+ <h:outputText value="#{orderingListBean.actionResult}"
id="actionResult" /><br />
+ <h:outputText value="#{orderingListBean.selectionString}"
id="selection" /><br />
+ <h:outputText value="#{orderingListBean.activeItem}"
id="activeItem" /><br />
+ <rich:messages id="messages" />
+ </h:panelGroup>
<br/>
- <h:outputText value="#{orderingListBean.actionResult}"
id="actionResult" />
- <rich:messages id="messages" />
- <br/>
</h:form>
</ui:define>
</ui:composition>
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java 2008-05-21
16:29:08 UTC (rev 8680)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java 2008-05-21
17:38:32 UTC (rev 8681)
@@ -45,9 +45,12 @@
private String firstRow;
- private String actionResult;
+ private String actionResultText;
private String ajax;
private String server;
+ private String thirdRow;
+ private String selectionText;
+ private String activeItemText;
public OrderingListTest() {
super("http", "localhost", "8080");
@@ -85,6 +88,16 @@
renderPage(getTestUrl(), template);
initFields();
+ _testButtons();
+ _testActions();
+ _testJSFunctions();
+ }
+
+ public String getTestUrl() {
+ return "/faces/pages/orderingList/orderingListTest.xhtml";
+ }
+
+ private void _testButtons() {
writeStatus("Check if all buttons are disabled first time");
checkButtons(true, true, true, true);
@@ -108,26 +121,73 @@
checkButtons(true, true, false, false);
Assert.assertEquals(selenium.getElementIndex("id=" + firstRow), 0);
- writeStatus("Unselect element");
- selenium.controlKeyDown();
- clickById(firstRow);
- selenium.controlKeyUp();
- checkButtons(true, true, true, true);
+ cleanSelection();
+ }
+
+ private void _testActions() {
+ writeStatus("Select two rows");
+ clickById(firstRow);
+ selenium.controlKeyDown();
+ clickById(thirdRow);
+ selenium.controlKeyUp();
+ checkButtons(true, true, false, false);
writeStatus("Click on ajax button");
clickById(ajax);
waitForAjaxCompletion();
- AssertTextEquals(actionResult, "item0");
+ AssertTextEquals(actionResultText, "item0");
+ AssertTextEquals(selectionText, "item0,item2");
+ AssertTextEquals(activeItemText, "Item [item2]");
+ writeStatus("Select one row");
+ clickById(firstRow);
+
writeStatus("Click on server link");
clickCommandAndWait(server);
- AssertTextEquals(actionResult, "item1");
+ AssertTextEquals(actionResultText, "item1");
+ AssertTextEquals(selectionText, "item0");
+ AssertTextEquals(activeItemText, "Item [item0]");
+ checkButtons(true, true, false, false);
+
+ cleanSelection();
}
- public String getTestUrl() {
- return "/faces/pages/orderingList/orderingListTest.xhtml";
+ private void _testJSFunctions() {
+ writeStatus("Select one row");
+ clickById(thirdRow);
+
+ writeStatus("Check if 'onupclick' event works");
+ clickById(upButton);
+ Assert.assertEquals(selenium.getEval("window.status"), "up
orderchanged");
+
+ writeStatus("Check if 'ondownclick' event works");
+ clickById(downButton);
+ Assert.assertEquals(selenium.getEval("window.status"), "down
orderchanged");
+
+ writeStatus("Check if 'ontopclick' event works");
+ clickById(firstButton);
+ Assert.assertEquals(selenium.getEval("window.status"), "top
orderchanged");
+
+ writeStatus("Check if 'onbottomclick' event works");
+ clickById(lastButton);
+ Assert.assertEquals(selenium.getEval("window.status"), "bottom
orderchanged");
+
+ cleanSelection();
}
+ private void cleanSelection() {
+ writeStatus("Unselect element");
+ clickById(firstRow);
+ selenium.controlKeyDown();
+ clickById(firstRow);
+ selenium.controlKeyUp();
+ checkButtons(true, true, true, true);
+
+ writeStatus("Submit empty selection to save it into server bean");
+ clickById(ajax);
+ waitForAjaxCompletion();
+ }
+
private void checkButtons(boolean firstDisabled, boolean upDisabled, boolean
downDisabled, boolean lastDisabled) {
if (firstDisabled) {
Assert.assertTrue(isVisibleById(firstButtonDisabled));
@@ -178,7 +238,11 @@
lastButtonDisabled = parentId + "dislast";
firstRow = parentId + ":0";
- actionResult = getParentId() + "_form:actionResult";
+ thirdRow = parentId + ":2";
+
+ actionResultText = getParentId() + "_form:actionResult";
+ selectionText = getParentId() + "_form:selection";
+ activeItemText = getParentId() + "_form:activeItem";
ajax = firstRow + ":_ajax";
server = parentId + ":1:_server";
}