Author: dsvyatobatsko
Date: 2009-03-06 11:40:45 -0500 (Fri, 06 Mar 2009)
New Revision: 12873
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/PickListTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/pickList/pickListAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/pickList/pickListTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java
Log:
RF-6162, RF-6167, RF-6171, RF-6177
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/PickListTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/PickListTestBean.java 2009-03-06
16:33:55 UTC (rev 12872)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/PickListTestBean.java 2009-03-06
16:40:45 UTC (rev 12873)
@@ -43,6 +43,8 @@
private List<String> result;
+ private boolean switchByClick = false;
+
public PickListTestBean() {
reset();
}
@@ -121,6 +123,27 @@
this.result = result;
}
+ /**
+ * Gets value of switchByClick field.
+ * @return value of switchByClick field
+ */
+ public boolean isSwitchByClick() {
+ return switchByClick;
+ }
+
+ /**
+ * Set a new value for switchByClick field.
+ * @param switchByClick a new value for switchByClick field
+ */
+ public void setSwitchByClick(boolean switchByClick) {
+ this.switchByClick = switchByClick;
+ }
+
+ public void initSwitchByClickTest() {
+ reset();
+ setSwitchByClick(true);
+ }
+
public void reset() {
options = new ArrayList<SelectItem>();
for (String player : ITEMS) {
@@ -131,6 +154,8 @@
result = new ArrayList<String>();
result.add(ITEMS.get(0));
result.add(ITEMS.get(1));
+
+ switchByClick = false;
}
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/pickList/pickListAutoTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/pickList/pickListTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java 2009-03-06
16:33:55 UTC (rev 12872)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PickListTest.java 2009-03-06
16:40:45 UTC (rev 12873)
@@ -20,11 +20,11 @@
*/
package org.richfaces.testng;
+import static org.ajax4jsf.bean.PickListTestBean.ITEMS;
+
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.ajax4jsf.template.Template;
import org.richfaces.AutoTester;
@@ -32,7 +32,6 @@
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
-import static org.ajax4jsf.bean.PickListTestBean.ITEMS;
public class PickListTest extends SeleniumTestBase {
@@ -41,24 +40,17 @@
private static final String COPY_ALL_BTN = "copyAll";
private static final String REMOVE_BTN = "remove";
private static final String REMOVE_ALL_BTN = "removeAll";
- private static final String SRC_ELEM_PREFIX = ":source::";
private final static String RESET_METHOD = "#{pickListBean.reset}";
+ private final static String INIT_SWITCH_BY_CLICK_TEST =
"#{pickListBean.initSwitchByClickTest}";
+
private final static String I18N_TEST_URL =
"pages/pickList/testI18N.xhtml";
private final static String LAYOUT_TEST_URL =
"pages/pickList/layoutTest.xhtml";
private final static String FACETS_TEST_URL =
"pages/pickList/testFacets.xhtml";
- private static Map<String, String> params = new HashMap<String,
String>();
-
- static {
- params.put("parameter1", "value1");
- params.put("parameter2", "value2");
- params.put("parameter3", "value3");
- }
-
@Test
public void testPickListComponent(Template template) {
renderPage(template, RESET_METHOD);
@@ -100,14 +92,24 @@
writeStatus("Try to move the first item and check state thereafter");
- String srcElemPrefix = parentId + PICK_LIST + SRC_ELEM_PREFIX;
- fireMouseEvent(srcElemPrefix + "0", "click", 0, 0, false);
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
clickById(copyElemId);
Assert.assertEquals(getNumberOfChildren(srcListId), 5);
Assert.assertEquals(getNumberOfChildren(destListId), 3);
Assert.assertEquals(selenium.getText("xpath=//tbody[@id='" +
destListId + "']/tr[3]"), "LEONTIEV");
+ writeStatus("Check multiple selection");
+ selenium.controlKeyDown();
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[2]");
+ selenium.controlKeyUp();
+
+ clickById(copyElemId);
+
+ Assert.assertEquals(getNumberOfChildren(srcListId), 3);
+ Assert.assertEquals(getNumberOfChildren(destListId), 5);
+
writeStatus("Test 'MOVE ALL' button");
clickById(copyAllElemId);
@@ -134,34 +136,146 @@
}
@Test
- public void testValueChangeEventFiredAndModelUpdatedOnSubmit(Template template) {
- AutoTester tester = getAutoTester(this);
- tester.renderPage(template, RESET_METHOD);
- String resultId = tester.getClientId("result");
+ public void testJSAPI(Template template) {
+ renderPage(template, RESET_METHOD);
- writeStatus("Check ValueChangeListeners invoked on submit and model binding
is updated on value changed");
+ writeStatus("Check JavaScript API. It is not declared, but it is");
- List<String> expected = Arrays.asList("ZHURIK",
"MELESHKO");
- AssertTextEquals(resultId, expected.toString());
+ String parentId = getParentId() + "_form:";
+ String pickListId = parentId + PICK_LIST;
- tester.testSubmit();
+ String destListId = parentId + PICK_LIST + "tlTbody";
+ String srcListId = parentId + PICK_LIST + "tbody";
- AssertTextEquals(resultId, ITEMS.toString(), "Model binding is not
updated");
+ Assert.assertEquals(getNumberOfChildren(srcListId), 6);
+ Assert.assertEquals(getNumberOfChildren(destListId), 2);
+
+ assertButtonEnabled(COPY_ALL_BTN);
+ assertButtonDisabled(COPY_BTN);
+ assertButtonDisabled(REMOVE_BTN);
+ assertButtonEnabled(REMOVE_ALL_BTN);
+
+ writeStatus("Check copy js function");
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
+ invokeFromComponent(pickListId, "copy", null);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 5);
+ Assert.assertEquals(getNumberOfChildren(destListId), 3);
+
+ writeStatus("Check remove js function");
+ selenium.click("//tbody[@id='" + destListId +
"']/tr[1]");
+ invokeFromComponent(pickListId, "remove", null);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 6);
+ Assert.assertEquals(getNumberOfChildren(destListId), 2);
+
+ writeStatus("Check copyAll js function");
+ invokeFromComponent(pickListId, "copyAll", null);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 0);
+ Assert.assertEquals(getNumberOfChildren(destListId), 8);
+ assertButtonDisabled(COPY_ALL_BTN);
+ assertButtonDisabled(COPY_BTN);
+ assertButtonDisabled(REMOVE_BTN);
+ assertButtonEnabled(REMOVE_ALL_BTN);
+
+ writeStatus("Check removeAll js function");
+ invokeFromComponent(pickListId, "removeAll", null);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 8);
+ Assert.assertEquals(getNumberOfChildren(destListId), 0);
+ assertButtonEnabled(COPY_ALL_BTN);
+ assertButtonDisabled(COPY_BTN);
+ assertButtonDisabled(REMOVE_BTN);
+ assertButtonDisabled(REMOVE_ALL_BTN);
}
@Test
- public void testSubmitWithExternalValidationFailed(Template template ) {
+ public void testSwitchByClickAttribute(Template template) {
+ renderPage(template, INIT_SWITCH_BY_CLICK_TEST);
+
+ writeStatus("Check 'switchByClick' attribute");
+
+ String parentId = getParentId() + "_form:";
+ String destListId = parentId + PICK_LIST + "tlTbody";
+ String srcListId = parentId + PICK_LIST + "tbody";
+
+ assertButtonEnabled(COPY_ALL_BTN);
+ assertButtonDisabled(COPY_BTN);
+ assertButtonDisabled(REMOVE_BTN);
+ assertButtonEnabled(REMOVE_ALL_BTN);
+
+ writeStatus("Try to move an item by click and check state
thereafter");
+
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
+
+ Assert.assertEquals(getNumberOfChildren(srcListId), 5);
+ Assert.assertEquals(getNumberOfChildren(destListId), 3);
+ Assert.assertEquals(selenium.getText("xpath=//tbody[@id='" +
destListId + "']/tr[3]"), "LEONTIEV");
+ }
+
+ @Test
+ public void testKeyboardNavigation(Template template) {
+ renderPage(template, RESET_METHOD);
+
+ writeStatus("Check keyboard navigation");
+
+ String pickListId = getParentId() + "_form:" + PICK_LIST;
+ String focusKeeper = pickListId + "focusKeeper";
+ String destListId = pickListId + "tlTbody";
+ String srcListId = pickListId + "tbody";
+ String copyElemId = pickListId + COPY_BTN;
+ String removeAllElemId = pickListId + REMOVE_ALL_BTN;
+
+ writeStatus("Check Up arrow");
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[6]");
+ selenium.keyDown(focusKeeper, "\\38");//up
+ clickById(copyElemId);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 5);
+ Assert.assertEquals(getNumberOfChildren(destListId), 3);
+ Assert.assertEquals(selenium.getText("xpath=//tbody[@id='" +
destListId + "']/tr[3]"), "KOSTITSYN");
+
+ writeStatus("Check Down arrow");
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
+ selenium.keyDown(focusKeeper, "\\40");//down
+ clickById(copyElemId);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 4);
+ Assert.assertEquals(getNumberOfChildren(destListId), 4);
+ Assert.assertEquals(selenium.getText("xpath=//tbody[@id='" +
destListId + "']/tr[4]"), "KOVAL");
+
+ writeStatus("Check SHIFT + click");
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[1]");
+ selenium.shiftKeyDown();
+ selenium.click("//tbody[@id='" + srcListId +
"']/tr[4]");
+ selenium.shiftKeyUp();
+ clickById(copyElemId);
+ Assert.assertEquals(getNumberOfChildren(srcListId), 0);
+ Assert.assertEquals(getNumberOfChildren(destListId), 8);
+
+ clickById(removeAllElemId);
+
+ writeStatus("Check CTRL + A shortcut");
+
+ selenium.controlKeyDown();
+ selenium.keyDown(focusKeeper, "A");
+ selenium.controlKeyUp();
+
+ clickById(copyElemId);
+
+ Assert.assertEquals(getNumberOfChildren(srcListId), 0);
+ Assert.assertEquals(getNumberOfChildren(destListId), 8);
+ }
+
+ @Test
+ public void testValueChangeEventFiredAndModelUpdatedOnSubmit(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, RESET_METHOD);
- writeStatus("Test component's form submission with an invalid element in
it");
String resultId = tester.getClientId("result");
+ writeStatus("Check ValueChangeListeners invoked on submit and model binding
is updated on value changed");
+
List<String> expected = Arrays.asList("ZHURIK",
"MELESHKO");
AssertTextEquals(resultId, expected.toString());
- tester.testSubmitWithExternalValidationFailed();
+ tester.testSubmit();
- AssertTextEquals(resultId, expected.toString(), "Model has to be
untouched");
+ AssertTextEquals(resultId, ITEMS.toString(), "Model binding is not
updated");
}
@Test