Author: konstantin.mishin
Date: 2008-10-14 10:41:55 -0400 (Tue, 14 Oct 2008)
New Revision: 10747
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java
Log:
JS API is present and works
component with rendered = false is not present on the page
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-10-14
14:39:36 UTC (rev 10746)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-10-14
14:41:55 UTC (rev 10747)
@@ -17,6 +17,7 @@
private boolean showButtonLabels;
private boolean switchByClick;
+ private boolean rendered;
public ListShuttleBean() {
init();
@@ -27,6 +28,7 @@
targetRequired = false;
showButtonLabels = true;
switchByClick = false;
+ rendered = true;
items = new ArrayList<ListShuttleItem>();
freeItems = new ArrayList<ListShuttleItem>();
for (int i = 0; i < 5; i++) {
@@ -104,4 +106,12 @@
public void setSwitchByClick(boolean switchByClick) {
this.switchByClick = switchByClick;
}
+
+ public boolean getRendered() {
+ return rendered;
+ }
+
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-10-14
14:39:36 UTC (rev 10746)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-10-14
14:41:55 UTC (rev 10747)
@@ -18,6 +18,8 @@
String parentId;
+ String lsId;
+
String availebleListId;
String targetListId;
@@ -56,9 +58,12 @@
String switchByClickId;
+ String renderedId;
+
private void init(Template template) {
renderPage(template, initMethod);
parentId = getParentId() + "_form:";
+ lsId = parentId + "ls";
availebleListId = parentId + "lstbody";
targetListId = parentId + "lstlTbody";
copyAllId = parentId + "lscopyAll";
@@ -78,10 +83,101 @@
targetRequiredId = attrFormId + ":targetRequiredId";
showButtonLabelsId = attrFormId + ":showButtonLabelsId";
switchByClickId = attrFormId + ":switchByClickId";
- }
+ renderedId = attrFormId + ":renderedId";
+ }
+ /**
+ * component with rendered = false is not present on the page
+ */
+ @Test
+ public void testRendered(Template template) {
+ init(template);
+ Assert.assertTrue(selenium.isElementPresent(lsId), "ListShuttle must be
rendered.");
+ selenium.click(renderedId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+
+ Assert.assertFalse(selenium.isElementPresent(lsId), "ListShuttle mustn't
be rendered.");
+ }
+
+ /**
+ * JS API is present and works
+ */
+ // @Test
+ public void testJSAPI(Template template) {
+ //TODO JS API has some bugs. This test case should be completed after fixing
theirs.
+ init(template);
+ selenium.runScript("var listShuttle = ($('" + lsId +
"')).component;");
+ // Check count
+ _assertTableRowsCount(availebleListId, 5);
+ _assertTableRowsCount(targetListId, 0);
+ // Copy all and check count
+ try {
+ selenium.runScript("listShuttle.copyAll();");
+ _assertTableRowsCount(availebleListId, 0);
+ _assertTableRowsCount(targetListId, 5);
+ } catch (Exception e) {
+ writeStatus("Test failed. Copy all does not work. Cause: " + e,
true);
+ Assert.fail("Test failed. Copy all does not work. Cause: " + e);
+ }
+ // Remove all and check count
+ try {
+ selenium.runScript("listShuttle.removeAll();");
+ _assertTableRowsCount(availebleListId, 5);
+ _assertTableRowsCount(targetListId, 0);
+ } catch (Exception e) {
+ writeStatus("Test failed. Remove all does not work. Cause: " + e,
true);
+ Assert.fail("Test failed. Remove all does not work. Cause: " + e);
+ }
+
+ try {
+ // Copy 1st & 2nd item
+ _selectItem(parentId + "ls:0");
+ selenium.runScript("listShuttle.copy();");
+ _selectItem(parentId + "ls:1");
+ selenium.runScript("listShuttle.copy();");
+ _selectItem(parentId + "ls:2");
+ selenium.runScript("listShuttle.copy();");
+ // Check count
+ _assertTableRowsCount(availebleListId, 2);
+ _assertTableRowsCount(targetListId, 3);
+ } catch (Exception e) {
+ writeStatus("Test failed. Copy does not work. Cause: " + e, true);
+ Assert.fail("Test failed. Copy does not work. cause: " + e);
+ }
+
+ // Check posting to server
+ _checkDataPost2Server(2, 3);
+
+ // Check ordering
+ _checkOrdering(targetListId, "1Item1", "2Item2",
"3Item3", "");
+
+ // Move the first to to the last
+ _selectItem(parentId + "ls:t0");
+ selenium.runScript("listShuttle.down();");
+ _checkOrdering(targetListId, "2Item2", "1Item1",
"3Item3", "Test failed. Down control does not work");
+
+ _selectItem(parentId + "ls:t0");
+ selenium.runScript("listShuttle.bottom();");
+ _checkOrdering(targetListId, "2Item2", "3Item3",
"1Item1", "Test failed. Last control does not work");
+
+ _selectItem(parentId + "ls:t2");
+ selenium.runScript("listShuttle.top();");
+ _checkOrdering(targetListId, "3Item3", "2Item2",
"1Item1", "Test failed. First control does not work");
+
+ _selectItem(parentId + "ls:t0");
+ selenium.runScript("listShuttle.up();");
+ _checkOrdering(targetListId, "3Item3", "1Item1",
"2Item2", "Test failed. Up control does not work");
+
+ _selectItem(parentId + "ls:t1");
+ selenium.runScript("listShuttle.remove();");
+ _checkOrdering(targetListId, "3Item3", "1Item1", null,
"Test failed. Remove control does not work");
+
+ _assertTableRowsCount(targetListId, 2);
+ }
+
/**
* Check 'switchByClick' attribute
*/