[richfaces-svn-commits] JBoss Rich Faces SVN: r11773 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Dec 15 09:16:31 EST 2008
Author: dsvyatobatsko
Date: 2008-12-15 09:16:31 -0500 (Mon, 15 Dec 2008)
New Revision: 11773
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
Log:
tree tests are refactored and extended + https://jira.jboss.org/jira/browse/RF-4834
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-12-15 14:02:17 UTC (rev 11772)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-12-15 14:16:31 UTC (rev 11773)
@@ -293,14 +293,14 @@
public void initAjaxCoreTest() {
setSwitchType("ajax");
setToggleOnClick(false);
- setAjaxSubmitSelection(false);
+ setAjaxSubmitSelection(true);
setRichModel(true);
}
public void initAjaxCoreTestWithSwingModel() {
setSwitchType("ajax");
setToggleOnClick(false);
- setAjaxSubmitSelection(false);
+ setAjaxSubmitSelection(true);
setRichModel(false);
}
@@ -331,6 +331,13 @@
}
}
+ public void initKeyboardNavigationTest() {
+ setSwitchType("ajax");
+ setToggleOnClick(false);
+ setAjaxSubmitSelection(false);
+ setRichModel(true);
+ }
+
private TreeStateAdvisor advisor;
/**
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-12-15 14:02:17 UTC (rev 11772)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-12-15 14:16:31 UTC (rev 11773)
@@ -43,6 +43,7 @@
private final static String INIT_AJAX_MODE = "#{treeBean.initAjaxMode}";
private final static String INIT_CLIENT_MODE = "#{treeBean.initClientMode}";
private final static String INIT_ADVISOR_TEST = "#{treeBean.initStateAdvisorTest}";
+ private final static String INIT_KEYBOARD_NAVIGATION_TEST = "#{treeBean.initKeyboardNavigationTest}";
private final static String TEAR_DOWN_METHOD = "#{treeBean.tearDown}";
private final static String INIT_DRAG_AND_DROP_TEST = "#{treeBean.initDragAndDropTest}";
private final static String DRAG_AND_DROP_TEST_URL = "pages/tree/dragAndDropTest.xhtml";
@@ -84,14 +85,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
tester.setExtrenalValidationFailed();
tester.startTracing();
writeStatus("Test ajaxSingle attribute");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
@Test
@@ -104,14 +107,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("Set a new invalid value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "");
tester.startTracing();
writeStatus("Test ajaxSingle attribute in case of invalid component state");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
}
@Test
@@ -124,14 +129,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("Set a new value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
tester.startTracing();
writeStatus("Test immediate attribute");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(true);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
@Test
@@ -144,6 +151,8 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("set a new value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
@@ -151,9 +160,9 @@
tester.setExtrenalValidationFailed();
tester.startTracing();
writeStatus("Test immediate attribute with external validation failed");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
//
@@ -170,14 +179,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
tester.setExtrenalValidationFailed();
tester.startTracing();
writeStatus("Test ajaxSingle attribute");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
//@Test
@@ -190,14 +201,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("Set a new invalid value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "");
tester.startTracing();
writeStatus("Test ajaxSingle attribute in case of invalid component state");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
}
//@Test
@@ -210,14 +223,16 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("Set a new value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
tester.startTracing();
writeStatus("Test immediate attribute");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(true);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
//@Test
@@ -230,6 +245,8 @@
writeStatus("Navigate to the first child");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
+ writeStatus("Check node expanded events are delivered");
+ tester.checkNodeExpandedListener(true);
clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
writeStatus("set a new value for the child");
type("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
@@ -237,9 +254,9 @@
tester.setExtrenalValidationFailed();
tester.startTracing();
writeStatus("Test immediate attribute with external validation failed");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
- tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
}
@Test
@@ -248,23 +265,25 @@
tester.renderPage(template, INIT_TOGGLE_ON_CLICK_SERVER_MODE);
tester.reset();
tester.clickLoad();
- writeStatus("Try to toggle a node by click with server swith type");
+ writeStatus("Try to toggle a node by click with server switch type");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
- selenium.click("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNode("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
waitForPageToLoad();
writeStatus("Check the node is expanded and proper listeners are invoked");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has not been expanded");
tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
tester.checkUpdateModel(true);
tester.startTracing();
writeStatus("Test the same in case of external validation failure");
writeStatus("Set external validation to fail");
tester.setExtrenalValidationFailed();
- selenium.click("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNode("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
waitForPageToLoad();
writeStatus("Check the node is not collapsed and no listeners are invoked due to external validation error");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has been collapsed");
tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
tester.checkUpdateModel(false);
}
@@ -276,19 +295,21 @@
tester.clickLoad();
writeStatus("Try to toggle a node by click with ajax swith type");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
writeStatus("Check the node is expanded and proper listeners are invoked");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has not been expanded");
tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
tester.checkUpdateModel(true);
tester.startTracing();
writeStatus("Test the same in case of external validation failure");
writeStatus("Set external validation to fail");
tester.setExtrenalValidationFailed();
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
writeStatus("Check the node is not collapsed and no listeners are invoked thanks to external validation error");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has been collapsed");
tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
tester.checkUpdateModel(false);
}
@@ -300,23 +321,25 @@
tester.clickLoad();
writeStatus("Try to toggle a node by click with client swith type");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
- selenium.click("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNode("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
writeStatus("Check the node is expanded and no listeners are invoked");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has not been expanded");
tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
tester.checkUpdateModel(false);
tester.startTracing();
writeStatus("Test the same in case of external validation failure");
writeStatus("Set external validation to fail");
tester.setExtrenalValidationFailed();
- selenium.click("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNode("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
writeStatus("Check the node is collapsed and no listeners are invoked anyway");
Assert.assertTrue(isPresent("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]"), "Node has not been collapsed");
tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
tester.checkUpdateModel(false);
}
- //@Test
+ @Test
public void testAjaxSubmitSelection(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, INIT_AJAX_SUBMIT_SELECTION);
@@ -326,24 +349,28 @@
tester.startTracing();
writeStatus("the form has to be submitted and proper listeners are invoked at every node click");
String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(true);
+ tester.checkNodeSelectedListener(true);
tester.startTracing();
selenium.click("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(true);
tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
tester.startTracing();
selenium.click("//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td/div/a");
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]");
tester.checkUpdateModel(true);
tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
tester.startTracing();
writeStatus("Set external validation to fail and click on node. No listeners must be invoked");
tester.setExtrenalValidationFailed();
- clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/div/div/table[2]/tbody/tr/td[3]");
+ clickTreeNodeAndWait("//*[@id='"+ compId + ":childs']/div/div/table[2]/tbody/tr/td[3]");
tester.checkUpdateModel(false);
tester.checkNodeExpandedListener(false);
+ tester.checkNodeSelectedListener(false);
}
@Test
@@ -544,12 +571,72 @@
assertClassAttributeContains(aNodeXpath, "highlighted-class", "highlightedClass attribute was not output to client");
}
+ @Test
+ public void testKeyboardNavigation(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_KEYBOARD_NAVIGATION_TEST);
+ tester.reset();
+ tester.clickLoad();
+ writeStatus("Check keyboard navigation for component");
+
+ String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ String firstNodeXpath = "//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td[3]";
+ String secondNodeXpath = "//*[@id='"+ compId + ":childs']/div/table[1]/tbody/tr/td[3]";
+ String thirdNodeXpath = "//*[@id='"+ compId + ":childs']/div/div/table[1]/tbody/tr/td[3]";
+
+ writeStatus("Select first node and press right arrow. Check the node is expanded and proper events are delivered");
+ clickTreeNode(firstNodeXpath);
+ selenium.keyDown(firstNodeXpath, "\\39");//right
+ waitForAjaxCompletion();
+ Assert.assertTrue(isPresent(secondNodeXpath), "Node has not been expanded");
+ tester.checkNodeExpandedListener(true);
+
+ tester.startTracing();
+ //it looks as if a focus is gone as the result of start tracing try to restore one
+ clickTreeNode(firstNodeXpath);
+
+ writeStatus("Move down to the second node and press right arrow. Check the same");
+ selenium.keyDown(firstNodeXpath, "\\40");//down
+ selenium.keyDown(secondNodeXpath, "\\39");
+ waitForAjaxCompletion();
+ Assert.assertTrue(isPresent(thirdNodeXpath), "Node has not been expanded");
+ tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
+
+ tester.startTracing();
+ //it looks as if a focus is gone as the result of start tracing try to restore one
+ clickTreeNode(secondNodeXpath);
+
+ writeStatus("Press left. Check the node is collapsed and proper events are delivered");
+ selenium.keyDown(secondNodeXpath, "\\37");//left
+ waitForAjaxCompletion();
+ Assert.assertFalse(isPresent(thirdNodeXpath), "Node has not been collapsed");
+ tester.checkNodeExpandedListener(true);
+
+ tester.startTracing();
+ //it looks as if a focus is gone as the result of start tracing try to restore one
+ clickTreeNode(secondNodeXpath);
+
+ writeStatus("Move up to the first node and press left arrow. Check the same");
+ selenium.keyDown(secondNodeXpath, "\\38");//up
+ selenium.keyDown(firstNodeXpath, "\\37");
+ waitForAjaxCompletion();
+ Assert.assertFalse(isPresent(secondNodeXpath), "Node has not been collapsed");
+ tester.checkNodeExpandedListener(true);
+ tester.checkNodeSelectedListener(true);
+
+ //l37
+ //u38
+ //r39
+ //d40
+ }
+
@Override
public void sendAjax() {
AutoTester tester = getAutoTester(this);
- //String compId = tester.getClientId(AutoTester.COMPONENT_ID);
- //clickAjaxCommandAndWait("//*[@id='"+ compId + ":childs']/table[1]/tbody/tr/td/div/a");
- tester.clickAjaxSubmit();
+ String compId = tester.getClientId(AutoTester.COMPONENT_ID);
+ String xpath = "//*[@id='" + compId + ":childs']/table[1]/tbody/tr/td[3]";
+ clickTreeNodeAndWait(xpath);
}
@Override
@@ -562,6 +649,18 @@
return "pages/tree/treeAutoTest.xhtml";
}
+ private void clickTreeNode(String locator){
+ //workaround: selenium triggerMouseEvent method (only in IE) ignores mouse event button property unless
+ //it is supplied with some specific parameters (e.g. event coordinates) while it is highly expected by tree node handlers
+ selenium.mouseDownAt(locator, "1,1");
+ selenium.clickAt(locator, "1,1");
+ }
+
+ private void clickTreeNodeAndWait(String locator){
+ clickTreeNode(locator);
+ waitForAjaxCompletion();
+ }
+
/**
* Test an icon.
*
More information about the richfaces-svn-commits
mailing list