Author: sergeyhalipov
Date: 2008-05-16 15:23:08 -0400 (Fri, 16 May 2008)
New Revision: 8626
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.
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-16
17:13:48 UTC (rev 8625)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/OrderingListTestBean.java 2008-05-16
19:23:08 UTC (rev 8626)
@@ -24,10 +24,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -128,7 +125,35 @@
public void setName(String name) {
this.name = name;
}
+
+ public String toString() {
+ return this.getClass().getSimpleName() + " [" + name + "]";
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Item other = (Item) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+
+ return true;
+ }
}
-
+
}
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-16
17:13:48 UTC (rev 8625)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/orderingList/orderingListTest.xhtml 2008-05-16
19:23:08 UTC (rev 8626)
@@ -30,19 +30,20 @@
<f:facet name="header">
<h:outputText value="Ajax Action" />
</f:facet>
- <a4j:commandButton value="Ajax Action"
reRender="actionResult"
- action="#{orderingListBean.action}" id="#{item.name}_ajax"
/>
+ <a4j:commandButton value="Ajax Action"
reRender="actionResult,messages"
+ action="#{item.action}" id="#{item.name}_ajax" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Server Action" />
</f:facet>
- <h:commandLink value="Server Action"
action="#{orderingListBean.action}" id="#{item.name}_server" />
+ <h:commandLink value="Server Action" action="#{item.action}"
id="#{item.name}_server" />
</h:column>
</rich:orderingList>
<br/>
<h:outputText value="#{orderingListBean.actionResult}"
id="actionResult" />
+ <rich:messages id="messages" />
<br/>
</h:form>
</ui:define>
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-16
17:13:48 UTC (rev 8625)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/OrderingListTest.java 2008-05-16
19:23:08 UTC (rev 8626)
@@ -31,14 +31,30 @@
import org.testng.annotations.Test;
public class OrderingListTest extends SeleniumTestBase implements RichSeleniumTest {
+ private String firstButton;
+ private String firstButtonDisabled;
+ private String upButton;
+ private String upButtonDisabled;
+
+ private String downButton;
+ private String downButtonDisabled;
+
+ private String lastButton;
+ private String lastButtonDisabled;
+
+ private String firstRow;
+
+ private String actionResult;
+ private String ajax;
+ private String server;
+
public OrderingListTest() {
super("http", "localhost", "8080");
}
public OrderingListTest(String protocol, String host, String port) {
super(protocol, host, port);
- // TODO Auto-generated constructor stub
}
/**
@@ -66,14 +82,45 @@
private void _testOrderingListComponent(Templates template) {
renderPage(getTestUrl(), template);
+ initFields();
- String firstRowPrefix = getParentId() + "_form:orderingList:0:";
- String textId = firstRowPrefix + "output";
+ writeStatus("Check if all buttons are disabled first time");
+ checkButtons(true, true, true, true);
- checkButtons(true, true, true, true);
- clickById(textId);
+ writeStatus("Click on first row");
+ clickById(firstRow);
checkButtons(true, true, false, false);
+ writeStatus("Click on down button");
+ Assert.assertEquals(selenium.getElementIndex("id=" + firstRow), 0);
+ clickById(downButton);
+ checkButtons(false, false, false, false);
+ Assert.assertEquals(selenium.getElementIndex("id=" + firstRow), 1);
+
+ writeStatus("Click on last button");
+ clickById(lastButton);
+ checkButtons(false, false, true, true);
+ Assert.assertEquals(selenium.getElementIndex("id=" + firstRow), 3);
+
+ writeStatus("Click on first button");
+ clickById(firstButton);
+ 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);
+
+ writeStatus("Click on ajax button");
+ clickById(ajax);
+ waitForAjaxCompletion();
+ AssertTextEquals(actionResult, "item0");
+
+ writeStatus("Click on server link");
+ clickCommandAndWait(server);
+ AssertTextEquals(actionResult, "item1");
}
public String getTestUrl() {
@@ -81,19 +128,6 @@
}
private void checkButtons(boolean firstDisabled, boolean upDisabled, boolean
downDisabled, boolean lastDisabled) {
- String parentId = getParentId() + "_form:orderingList";
- String firstButton = parentId + "first";
- String firstButtonDisabled = parentId + "disfirst";
-
- String upButton = parentId + "up";
- String upButtonDisabled = parentId + "disup";
-
- String downButton = parentId + "down";
- String downButtonDisabled = parentId + "disdown";
-
- String lastButton = parentId + "last";
- String lastButtonDisabled = parentId + "dislast";
-
if (firstDisabled) {
Assert.assertTrue(isVisibleById(firstButtonDisabled));
Assert.assertFalse(isVisibleById(firstButton));
@@ -126,4 +160,25 @@
Assert.assertTrue(isVisibleById(lastButton));
}
}
+
+ private void initFields() {
+ String parentId = getParentId() + "_form:orderingList";
+
+ firstButton = parentId + "first";
+ firstButtonDisabled = parentId + "disfirst";
+
+ upButton = parentId + "up";
+ upButtonDisabled = parentId + "disup";
+
+ downButton = parentId + "down";
+ downButtonDisabled = parentId + "disdown";
+
+ lastButton = parentId + "last";
+ lastButtonDisabled = parentId + "dislast";
+
+ firstRow = parentId + ":0";
+ actionResult = getParentId() + "_form:actionResult";
+ ajax = firstRow + ":_ajax";
+ server = parentId + ":1:_server";
+ }
}