Author: dsvyatobatsko
Date: 2008-11-25 14:04:46 -0500 (Tue, 25 Nov 2008)
New Revision: 11378
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/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4819
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-11-25
19:00:47 UTC (rev 11377)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/tree/TreeTestBean.java 2008-11-25
19:04:46 UTC (rev 11378)
@@ -278,4 +278,25 @@
setRichModel(false);
}
+ public void initServerMode() {
+ setSwitchType("server");
+ setToggleOnClick(false);
+ setAjaxSubmitSelection(false);
+ setRichModel(true);
+ }
+
+ public void initAjaxMode() {
+ setSwitchType("ajax");
+ setToggleOnClick(false);
+ setAjaxSubmitSelection(false);
+ setRichModel(true);
+ }
+
+ public void initClientMode() {
+ setSwitchType("client");
+ setToggleOnClick(false);
+ setAjaxSubmitSelection(false);
+ setRichModel(true);
+ }
+
}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-11-25
19:00:47 UTC (rev 11377)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-11-25
19:04:46 UTC (rev 11378)
@@ -725,11 +725,12 @@
/**
* Return true if element is visible
- *
+ * @deprecated replaced by <code>isVisible(String locator)</code>.
* @param id -
* DOM element id
* @return
*/
+ @Deprecated
public boolean isVisibleById(String id) {
return selenium.isVisible("id=" + id);
}
@@ -758,6 +759,17 @@
}
/**
+ * Returns true if element with given locator is visible.
+ *
+ * @param locator
+ * an element locator
+ * @return true if element with given locator is visible, otherwise - false
+ */
+ public boolean isVisible(String locator) {
+ return selenium.isVisible(locator);
+ }
+
+ /**
* Invokes JS method on client.
*
* @param id -
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-11-25
19:00:47 UTC (rev 11377)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TreeTest.java 2008-11-25
19:04:46 UTC (rev 11378)
@@ -19,6 +19,9 @@
private final static String INIT_AJAX_CORE_TEST =
"#{treeBean.initAjaxCoreTest}";
private final static String INIT_AJAX_CORE_TEST_WITH_SWING_MODEL =
"#{treeBean.initAjaxCoreTestWithSwingModel}";
private final static String INIT_AJAX_SUBMIT_SELECTION =
"#{treeBean.initAjaxSubmitSelectionTest}";
+ private final static String INIT_SERVER_MODE =
"#{treeBean.initServerMode}";
+ private final static String INIT_AJAX_MODE = "#{treeBean.initAjaxMode}";
+ private final static String INIT_CLIENT_MODE =
"#{treeBean.initClientMode}";
static {
params.put("parameter1", "value1");
@@ -342,6 +345,109 @@
}
}
+ @Test
+ public void testServerMode(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_SERVER_MODE);
+ tester.reset();
+ tester.clickLoad();
+ tester.startTracing();
+ writeStatus("Check server mode: a component is submitted, proper listeners
are invoked");
+ writeStatus("Navigate to the first child. Node must be exposed, model -
updated, listeners - invoked");
+ String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ selenium.click("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td/div/a");
+ waitForPageToLoad();
+ tester.checkUpdateModel(true);
+ tester.checkNodeExpandedListener(true);
+ tester.startTracing();
+ writeStatus("Navigate to the second child. Node must be exposed, model -
updated, listeners - invoked");
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ waitForPageToLoad();
+ tester.checkUpdateModel(true);
+ tester.checkNodeExpandedListener(true);
+ tester.startTracing();
+ writeStatus("Set tree to invalid state and try to collapse node. Model is
not updated, no listeners are invoked");
+ type("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[3]/input", "");
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ waitForPageToLoad();
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ tester.startTracing();
+ writeStatus("The same with external validation failure");
+ type("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
+ tester.setExtrenalValidationFailed();
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ waitForPageToLoad();
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ }
+
+ @Test
+ public void testAjaxMode(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_AJAX_MODE);
+ tester.reset();
+ tester.clickLoad();
+ tester.startTracing();
+ writeStatus("Check ajax mode: a component is submitted, proper listeners are
invoked");
+ writeStatus("Navigate to the first child. Node must be exposed, model -
updated, listeners - invoked");
+ String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(true);
+ tester.checkNodeExpandedListener(true);
+ tester.startTracing();
+ writeStatus("Navigate to the second child. Node must be exposed, model -
updated, listeners - invoked");
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(true);
+ tester.checkNodeExpandedListener(true);
+ tester.startTracing();
+ writeStatus("Set tree to invalid state and try to collapse node. Model is
not updated, no listeners are invoked");
+ type("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[3]/input", "");
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ tester.startTracing();
+ writeStatus("The same with external validation failure");
+ type("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[3]/input", "New");
+ tester.setExtrenalValidationFailed();
+ clickAjaxCommandAndWait("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ }
+
+ @Test
+ public void testClientMode(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_CLIENT_MODE);
+ tester.reset();
+ tester.clickLoad();
+ tester.startTracing();
+ writeStatus("Check client mode: all the time node is exposed, model stays
untouched, no listeners are invoked");
+ writeStatus("Navigate to the first child.");
+ String compId = getAutoTester(this).getClientId(AutoTester.COMPONENT_ID);
+ selenium.click("//*[@id='"+ compId +
":childs']/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ writeStatus("Navigate to the second child.");
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ writeStatus("Set tree to invalid state and try to collapse node. Now all is
allowed");
+ type("//*[@id='"+ compId +
":childs']/div/div/table[1]/tbody/tr/td[3]/input", "");
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ Assert.assertFalse(isVisible("//*[@id='"+ compId +
":childs']/div/div"), "Node has not been collapsed");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ writeStatus("The same with external validation failure");
+ selenium.click("//*[@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();
+ selenium.click("//*[@id='"+ compId +
":childs']/div/table[1]/tbody/tr/td/div/a");
+ Assert.assertFalse(isVisible("//*[@id='"+ compId +
":childs']/div/div"), "Node has not been collapsed");
+ tester.checkUpdateModel(false);
+ tester.checkNodeExpandedListener(false);
+ }
+
@Override
public void sendAjax() {
AutoTester tester = getAutoTester(this);