Author: andrei_exadel
Date: 2008-05-27 12:21:24 -0400 (Tue, 27 May 2008)
New Revision: 8786
Removed:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonDescription.xhtml
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkDescription.xhtml
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java
Log:
ajax link test
Deleted:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonDescription.xhtml
===================================================================
---
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonDescription.xhtml 2008-05-27
16:00:11 UTC (rev 8785)
+++
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandButton/ajaxButtonDescription.xhtml 2008-05-27
16:21:24 UTC (rev 8786)
@@ -1,13 +0,0 @@
-<html>
-<table border="1" style="border-color: #F1EEE9"
cellpadding="5" cellspacing="0">
-<tr><th></th><th>Action</th><th>Result</th></tr>
-<tr><td>1</td><td>Click 1st button</td><td>Input
value == 3</td></tr>
-<tr><td>2</td><td>Click 1st button</td><td>Input
value == 6</td></tr>
-<tr><td>3</td><td>Click 2nd button</td><td>Input
value == 6</td></tr>
-<tr><td>4</td><td>Click 3td button</td><td>Input
value == 6</td></tr>
-<tr><td>5</td><td>Click 4th button</td><td>Input
value == 1</td></tr>
-<tr><td>6</td><td>Click 5th button</td><td>Input
value == 2</td></tr>
-<tr><td>7</td><td>Click 1st button</td><td>Input
value == 5</td></tr>
-<tr><td>8</td><td>Click 3th button</td><td>Input
value == 5</td></tr>
-</table>
-</html>
\ No newline at end of file
Deleted:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkDescription.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/src/main/webapp/pages/ajaxCommandLink/ajaxLinkTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java 2008-05-27
16:00:11 UTC (rev 8785)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/testng/AjaxCommandLinkTest.java 2008-05-27
16:21:24 UTC (rev 8786)
@@ -3,11 +3,13 @@
import org.richfaces.RichSeleniumTest;
import org.richfaces.SeleniumTestBase;
import org.richfaces.Templates;
+import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
+
public class AjaxCommandLinkTest extends SeleniumTestBase implements RichSeleniumTest {
public AjaxCommandLinkTest() {
@@ -39,54 +41,88 @@
}
private void _testAjaxCommandLinkComponent(Templates template) {
- renderPage(getTestUrl(), template);
-
- String parentId = getParentId() + "_form:";
-
- String LinkId = parentId + "l1";
- String inputId = parentId + "_value";
-
- writeStatus("Click link 1 : ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "12345");
-
- writeStatus("Click link 1 again: ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "123452345");
-
- LinkId = parentId + "l2";
-
- writeStatus("Click link 2 : ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "1234523455");
-
- LinkId = parentId + "l3";
-
- writeStatus("Click link 3 : ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "1234523455");
-
- LinkId = parentId + "l4";
-
- writeStatus("Click link 4 : ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "12345234555");
-
- LinkId = parentId + "l5";
-
- writeStatus("Click link 5 : ");
- clickById(LinkId);
- waitForAjaxCompletion();
- AssertValueEquals(inputId, "12345234555");
-
+ renderPage(getTestUrl(), template);
+
+ String parentId = getParentId() + "_form:";
+
+ String linkId = parentId + "l1";
+ boolean ajaxSingle = false;
+ boolean immediate = false;
+ writeStatus("Click link 1");
+ setValidation(true);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, ajaxSingle, immediate, true, true, true, true);
+
+ linkId = parentId + "l2";
+ ajaxSingle = false;
+ immediate = false;
+ writeStatus("Click link 2");
+ setValidation(false);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, false, ajaxSingle, immediate, false, false, false, false);
+
+ linkId = parentId + "l3";
+ ajaxSingle = false;
+ immediate = true;
+ writeStatus("Click link 3");
+ setValidation(true);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, ajaxSingle, immediate, true, true, true, false);
+
+ linkId = parentId + "l4";
+ ajaxSingle = true;
+ immediate = true;
+ writeStatus("Click link 4");
+ setValidation(false);
+ clickById(linkId);
+ waitForAjaxCompletion();
+ waitForOnCompleteHndler();
+ checkButton(linkId, true, ajaxSingle, immediate, true, true, true, false);
+
+
}
+
+ private void setValidation(boolean success) {
+ StringBuffer buffer = new StringBuffer("setValidation(");
+ buffer.append(success);
+ buffer.append(");");
+ runScript(buffer.toString());
+ }
+
+ private void waitForOnCompleteHndler () {
+ waiteForCondition("_onCompleteHandler == true;", 3000);
+ runScript("_onCompleteHandler = false;");
+ }
+
+ private void checkButton(String id, boolean testData, boolean ajaxSingle, boolean
immediate, boolean testAction, boolean testActionListener, boolean testFListener, boolean
testInput) {
+ writeStatus("Checking link...");
+ StringBuffer buffer = new StringBuffer("checkLink('");
+ buffer.append(id);
+ buffer.append("',");
+ buffer.append(testData);
+ buffer.append(",");
+ buffer.append(testAction);
+ buffer.append(",");
+ buffer.append(testActionListener);
+ buffer.append(",");
+ buffer.append(testFListener);
+ buffer.append(",");
+ buffer.append(testInput);
+ buffer.append(");");
+ String result = runScript(buffer.toString());
+ if (result != null && result.length() > 0) {
+ Assert.fail("<a4j:commandLink> [ajaxSingle="+ajaxSingle+" ;
immediate="+immediate+"] test failure caused by " + result);
+ }
+
+ }
- public String getTestUrl() {
+ public String getTestUrl() {
return "/faces/pages/ajaxCommandLink/ajaxLinkTest.xhtml";
}