Author: andrei_exadel
Date: 2009-02-10 13:07:29 -0500 (Tue, 10 Feb 2009)
New Revision: 12620
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestNavigationPage.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxCommandLink/testListenerAndNavigation.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java
Log:
RF-6043
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-02-10
16:43:44 UTC (rev 12619)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-02-10
18:07:29 UTC (rev 12620)
@@ -53,6 +53,8 @@
public static final String PROCESS_INPUT_CHANGE_LISTENER =
"ProcessInputChangeListener";
public static final String ACTION_LISTENER_STATUS = "ActionListener";
+
+ public static final String ACTION_STATUS = "Action1";
public static final String NESTED_ACTION_LISTENER_STATUS =
"NestedListener";
@@ -75,6 +77,8 @@
public static final String REQUIRED_MESSAGE = "Required message";
public static final String AUTOTEST_BEAN_NAME = "autoTestBean";
+
+ public static final String NAVIGATION_ACTION = "autoTestNavigation";
// private String input = INPUT_TEXT;
@@ -154,6 +158,11 @@
setStatus(getStatus() + ACTION_LISTENER_STATUS);
}
+ public String action () {
+ setStatus(getStatus() + ACTION_STATUS);
+ return NAVIGATION_ACTION;
+ }
+
public void processInputChangeListener(ValueChangeEvent event) {
if (processSet) {
setStatus(getStatus() + PROCESS_INPUT_CHANGE_LISTENER);
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-02-10
16:43:44 UTC (rev 12619)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-02-10
18:07:29 UTC (rev 12620)
@@ -349,4 +349,11 @@
<to-view-id>/pages/ajaxSupport/successNavigation.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
+ <navigation-rule>
+ <from-view-id>/*</from-view-id>
+ <navigation-case>
+ <from-outcome>autoTestNavigation</from-outcome>
+ <to-view-id>/layout/autotest/autoTestNavigationPage.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
</faces-config>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestNavigationPage.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestNavigationPage.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestNavigationPage.xhtml 2009-02-10
18:07:29 UTC (rev 12620)
@@ -0,0 +1,15 @@
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+ <ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <p id="_auto_test_navigation">Navigation successfully</p>
+ <script>
+ window.done=true;
+ </script>
+ </ui:define>
+ </ui:composition>
+</html>
\ No newline at end of file
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxCommandLink/testListenerAndNavigation.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxCommandLink/testListenerAndNavigation.xhtml
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxCommandLink/testListenerAndNavigation.xhtml 2009-02-10
18:07:29 UTC (rev 12620)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <a4j:commandLink id="componentId"
+ action="#{autoTestBean.action}"
+ actionListener="#{autoTestBean.actionListener}"
+ immediate="#{autoTestBean.immediate}"
+ ajaxSingle="#{autoTestBean.ajaxSingle}"
+ value="Link"
+ >
+ <f:actionListener type="org.ajax4jsf.autotest.bean.AutoTestListener"
/>
+ </a4j:commandLink>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-02-10
16:43:44 UTC (rev 12619)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-02-10
18:07:29 UTC (rev 12620)
@@ -72,7 +72,16 @@
public AutoTester(SeleniumTestBase base) {
this.base = base;
}
+
+ private void navigate() {
+ base.navigate();
+
base.waiteForCondition("document.getElementById('_auto_test_navigation') !=
null", 10000);
+ if (!"Navigation
successfully".equals(base.getTextById("_auto_test_navigation"))) {
+ Assert.fail("Navigation has not been occurred");
+ }
+ }
+
public void renderPage(Template template, String resetMethodName) {
base.renderAutoTestPage(template, resetMethodName);
}
@@ -124,7 +133,16 @@
checkActionListener(true);
checkUpdateModel(true);
}
+
+ public void testActionAndNavigation() {
+ reset();
+ clickLoad();
+ navigate();
+
+ checkAction(true);
+ }
+
public void testExtrenalValidationFailure() {
reset();
clickLoad();
@@ -583,6 +601,15 @@
}
}
+ public void checkAction(boolean passed) {
+ String status = getStatus();
+ if (passed && status != null &&
status.indexOf(AutoTestBean.ACTION_STATUS) == -1) {
+ Assert.fail("Action has been skipped");
+ } else if (!passed && status != null &&
status.indexOf(AutoTestBean.ACTION_STATUS) != -1) {
+ Assert.fail(status);
+ }
+ }
+
public void checkProcessInputChangeListener(boolean passed) {
String status = getStatus();
if (passed && status != null &&
status.indexOf(AutoTestBean.PROCESS_INPUT_CHANGE_LISTENER) == -1) {
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 2009-02-10
16:43:44 UTC (rev 12619)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-02-10
18:07:29 UTC (rev 12620)
@@ -1234,7 +1234,14 @@
*/
public void sendAjax() {
}
-
+
+ /**
+ * Control action that should force ajax request that navigate to other page.
+ * This method should NOT wait for ajax completion
+ * This method should be overridden for auto test
+ */
+ public void navigate() {
+ }
/**
* This call back has to move auto test component into invalid state.
* Used for auto testing only.
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java 2009-02-10
16:43:44 UTC (rev 12619)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java 2009-02-10
18:07:29 UTC (rev 12620)
@@ -34,6 +34,8 @@
public class AjaxCommandLinkTest extends SeleniumTestBase {
+ static final String TEST_NAVIGATION_URL =
"/pages/ajaxCommandLink/testListenerAndNavigation.xhtml";
+
private static Map<String, String> parameter = new HashMap<String,
String>();
private static Map<String, String> styleAttributes = new HashMap<String,
String>();
static {
@@ -77,6 +79,17 @@
}
@Test
+ public void testNavigation(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(TEST_NAVIGATION_URL, template, null);
+
+ tester.testActionAndNavigation();
+ tester.checkActionListener(true);
+ tester.checkNestedActionListener(true);
+
+ }
+
+ @Test
public void testHTMLAttributes(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, null);
@@ -231,5 +244,10 @@
public void sendAjax() {
clickAjaxCommandAndWait(getAutoTester(this).getClientId(AutoTester.COMPONENT_ID));
}
+
+ @Override
+ public void navigate() {
+ clickById(getAutoTester(this).getClientId(AutoTester.COMPONENT_ID));
+ }
}