Author: andrei_exadel
Date: 2008-07-14 08:12:00 -0400 (Mon, 14 Jul 2008)
New Revision: 9567
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java
Log:
List shuttle test refactoring
Modified:
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
===================================================================
---
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-07-14
11:10:59 UTC (rev 9566)
+++
trunk/test-applications/seleniumTest/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-07-14
12:12:00 UTC (rev 9567)
@@ -10,6 +10,7 @@
public class ListShuttleBean {
private List<ListShuttleItem> items = null;
private List<ListShuttleItem> freeItems = null;
+ private boolean controlsVisible = true;
public ListShuttleBean() {
init();
}
@@ -21,8 +22,13 @@
ListShuttleItem item = new ListShuttleItem(i + 1, "Item" + (i + 1));
freeItems.add(item);
}
+ controlsVisible = true;
}
+ public void hide(ActionEvent event) {
+ controlsVisible = false;
+ }
+
public void reset(ActionEvent event) {
init();
}
@@ -41,4 +47,18 @@
public void setFreeItems(List<ListShuttleItem> freeItems) {
this.freeItems = freeItems;
}
+
+ /**
+ * @return the controlsVisible
+ */
+ public boolean isControlsVisible() {
+ return controlsVisible;
+ }
+
+ /**
+ * @param controlsVisible the controlsVisible to set
+ */
+ public void setControlsVisible(boolean controlsVisible) {
+ this.controlsVisible = controlsVisible;
+ }
}
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml 2008-07-14
11:10:59 UTC (rev 9566)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml 2008-07-14
12:12:00 UTC (rev 9567)
@@ -19,7 +19,12 @@
targetValue="#{listShuttle.items}" var="items"
listHeight="300"
listWidth="300" sourceCaptionLabel="Available Items"
targetCaptionLabel="Currently Active Items"
- converter="listShuttleconverter">
+ converter="listShuttleconverter"
+ moveControlsVisible="#{listShuttle.controlsVisible}"
+ fastMoveControlsVisible="#{listShuttle.controlsVisible}"
+ fastOrderControlsVisible="#{listShuttle.controlsVisible}"
+ orderControlsVisible="#{listShuttle.controlsVisible}"
+ >
<rich:column width="18">
<h:outputLink value="#">
<h:outputText
value="#{items.numder}"></h:outputText>
@@ -30,7 +35,8 @@
</rich:column>
</rich:listShuttle>
<a4j:commandLink id="reset" value="Reset"
actionListener="#{listShuttle.reset}"
reRender="ls"></a4j:commandLink><br/>
- <a4j:commandLink id="submit" value="Submit"
reRender="ls"></a4j:commandLink>
+ <a4j:commandLink id="submit" value="Submit"
reRender="ls"></a4j:commandLink><br/>
+ <a4j:commandLink id="hide" value="Hide Controls"
actionListener="#{listShuttle.hide}"
reRender="ls"></a4j:commandLink>
</h:form>
</ui:define>
</ui:composition>
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-07-14
11:10:59 UTC (rev 9566)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-07-14
12:12:00 UTC (rev 9567)
@@ -27,6 +27,7 @@
String lastId ;
String submitId;
String resetId;
+ String hideId;
@Test(dataProvider = "templates")
@@ -48,6 +49,7 @@
lastId = parentId + "lslast";
submitId = parentId + "submit";
resetId = parentId + "reset";
+ hideId = parentId + "hide";
}
@@ -56,20 +58,33 @@
renderPage(template);
init();
reset();
+
+ _checkVisibility(true);
// Check count
_assertTableRowsCount(availebleListId, 5);
_assertTableRowsCount(targetListId, 0);
// Copy all and check count
- clickById(copyAllId);
- _assertTableRowsCount(availebleListId, 0);
- _assertTableRowsCount(targetListId, 5);
+ try {
+ clickById(copyAllId);
+ _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
- clickById(removeAllId);
- _assertTableRowsCount(availebleListId, 5);
- _assertTableRowsCount(targetListId, 0);
+ try {
+ clickById(removeAllId);
+ _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
@@ -81,49 +96,84 @@
_assertTableRowsCount(availebleListId, 2);
_assertTableRowsCount(targetListId, 3);
}catch (Exception e) {
- Assert.fail("Copy does nto work. cause: " + 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
- _checkItemText("1Item1", targetListId, 0);
- _checkItemText("2Item2", targetListId, 1);
- _checkItemText("3Item3", targetListId, 2);
+ _checkOrdering(targetListId, "1Item1", "2Item2",
"3Item3","");
// Move the first to to the last
_doItemAction(parentId + "ls:t0", downId, "Down");
- _checkItemText("2Item2", targetListId, 0);
- _checkItemText("1Item1", targetListId, 1);
- _checkItemText("3Item3", targetListId, 2);
+ _checkOrdering(targetListId, "2Item2", "1Item1",
"3Item3","Test failed. Down control does not work");
_doItemAction(parentId + "ls:t0", lastId, "Last");
- _checkItemText("2Item2", targetListId, 0);
- _checkItemText("3Item3", targetListId, 1);
- _checkItemText("1Item1", targetListId, 2);
+ _checkOrdering(targetListId, "2Item2", "3Item3",
"1Item1","Test failed. Last control does not work");
_doItemAction(parentId + "ls:t2", firstId, "first");
- _checkItemText("3Item3", targetListId, 0);
- _checkItemText("2Item2", targetListId, 1);
- _checkItemText("1Item1", targetListId, 2);
+ _checkOrdering(targetListId, "3Item3", "2Item2",
"1Item1","Test failed. First control does not work");
_doItemAction(parentId + "ls:t0", upId, "Up");
- _checkItemText("3Item3", targetListId, 0);
- _checkItemText("1Item1", targetListId, 1);
- _checkItemText("2Item2", targetListId, 2);
+ _checkOrdering(targetListId, "3Item3", "1Item1",
"2Item2","Test failed. Up control does not work");
_doItemAction(parentId + "ls:t1", removeId, "Remove");
+ _checkOrdering(targetListId, "3Item3", "1Item1", null,"Test
failed. Remove control does not work");
+
_assertTableRowsCount(targetListId, 2);
- _checkItemText("3Item3", targetListId, 0);
- _checkItemText("1Item1", targetListId, 1);
+
+ hideControls();
+ _checkVisibility(false);
-
}
+ private void hideControls() {
+ clickAjaxCommandAndWait(hideId);
+ }
+ private void _checkVisibility(boolean isVisible) {
+ if (isVisible) {
+ AssertVisible(copyAllId);
+ AssertVisible(parentId + "lsdisremoveAll");
+ AssertVisible(parentId + "lsdisremove");
+ AssertVisible(parentId + "lsdisremove");
+
+ AssertVisible(parentId + "lsdisfirst");
+ AssertVisible(parentId + "lsdisup");
+ AssertVisible(parentId + "lsdisdown");
+ AssertVisible(parentId + "lsdislast");
+ }else {
+ AssertNotRendered(copyAllId);
+ AssertNotRendered(removeAllId);
+ AssertNotRendered(copyId);
+ AssertNotRendered(removeId);
+ AssertNotRendered(firstId);
+ AssertNotRendered(lastId);
+ AssertNotRendered(downId);
+ AssertNotRendered(upId);
+ }
+ }
+
+ private void _checkOrdering (String listId, String first, String second, String fird,
String errorMessage) {
+ try {
+ if (first != null)
+ _checkItemText(first, listId, 0);
+ if (second != null) {
+ _checkItemText(second, listId, 1);
+ }
+ if (fird != null) {
+ _checkItemText(fird, listId, 2);
+ }
+ }catch (Exception e) {
+ writeStatus(errorMessage, true);
+ Assert.fail(errorMessage + e.getMessage());
+ }
+ }
+
private void reset() {
clickAjaxCommandAndWait(resetId);
}
@@ -138,12 +188,12 @@
try {
r = Integer.parseInt(l);
if (r != rows) {
- writeStatus("List shuttle test failed. Incorrect list item count in table id:
" + tbId, true);
- Assert.fail("List shuttle test failed. Incorrect list item count in table id:
" + tbId);
+ writeStatus("Incorrect list item count in table id: " + tbId, true);
+ Assert.fail("Incorrect list item count in table id: " + tbId);
}
}catch (Exception e) {
- writeStatus("List shuttle test failed. cause: " + e.getMessage(), true);
- Assert.fail("List shuttle test failed. cause: " + e);
+ writeStatus("List shuttle test failed. Cause: " + e.getMessage(), true);
+ Assert.fail("List shuttle test failed. Cause: " + e);
}
}
@@ -172,7 +222,7 @@
clickById(itemId);
}catch (Exception e) {
writeStatus("Selection item id: " + itemId + " failed.");
- Assert.fail("List shuttle test failed. No item was found. Item id: " +
itemId);
+ Assert.fail("No item was found. Item id: " + itemId);
}
}
@@ -189,7 +239,7 @@
AssertTextEquals(id, text, "Invalid item's text");
}catch (Exception e) {
writeStatus("Invalid item text. Item id: " + id);
- Assert.fail("List shuttle test failed. Item id: " + id);
+ Assert.fail("Invalid item text. Item id: " + id);
}
}