Author: ppitonak(a)redhat.com
Date: 2010-09-21 07:02:45 -0400 (Tue, 21 Sep 2010)
New Revision: 19270
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/common.js
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jJSFunction/TestJSFunctionSimple.java
Log:
* new variable is added to each page for testing purpose
* new implementation of testing events of a4j:jsFunction
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/common.js
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/common.js 2010-09-21
07:26:59 UTC (rev 19269)
+++
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/common.js 2010-09-21
11:02:45 UTC (rev 19270)
@@ -1,4 +1,11 @@
/**
+ * Variable used in Selenium tests for testing JavaScript events. Each event adds its
name to this
+ * variable. E.g. if onbegin, onbeforedomupdate and oncomplete is set, successful result
will be
+ * "begin beforedomupdate complete ".
+ */
+metamerEvents = "";
+
+/**
* Hides the attributes of a component, header and footer of the page.
*/
function hideControls() {
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jJSFunction/TestJSFunctionSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jJSFunction/TestJSFunctionSimple.java 2010-09-21
07:26:59 UTC (rev 19269)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jJSFunction/TestJSFunctionSimple.java 2010-09-21
11:02:45 UTC (rev 19270)
@@ -31,9 +31,9 @@
import java.net.URL;
+import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.encapsulated.JavaScript;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.Test;
@@ -197,29 +197,24 @@
@Test
public void testEvents() {
- selenium.type(pjq("input[type=text][id$=onbeginInput]"),
"alert('begin')");
+ selenium.type(pjq("input[type=text][id$=onbeginInput]"),
"metamerEvents += \"begin \"");
selenium.waitForPageToLoad();
- selenium.type(pjq("input[type=text][id$=onbeforedomupdateInput]"),
"alert('beforedomupdate')");
+ selenium.type(pjq("input[type=text][id$=onbeforedomupdateInput]"),
"metamerEvents += \"beforedomupdate \"");
selenium.waitForPageToLoad();
- selenium.type(pjq("input[type=text][id$=oncompleteInput]"),
"alert('complete')");
+ selenium.type(pjq("input[type=text][id$=oncompleteInput]"),
"metamerEvents += \"complete \"");
selenium.waitForPageToLoad();
- JavaScriptCondition condition = new JavaScriptCondition() {
- public JavaScript getJavaScriptCondition() {
- return new JavaScript("selenium.isAlertPresent()");
- }
- };
+ selenium.getEval(new JavaScript("window.metamerEvents =
\"\";"));
+ String time1Value = selenium.getText(time1);
- guardXhr(selenium).click(link);
+ selenium.fireEvent(link, Event.CLICK);
+ waitGui.failWith("Page was not updated").waitForChange(time1Value,
retrieveText.locator(time1));
- waitGui.failWith("First alert was not displayed").until(condition);
- assertEquals(selenium.getAlert(), "begin", "Attribute onbegin does
not work");
+ String[] events = selenium.getEval(new
JavaScript("window.metamerEvents")).split(" ");
- waitGui.failWith("Second alert was not displayed").until(condition);
- assertEquals(selenium.getAlert(), "beforedomupdate", "Attribute
onbeforedomupdate does not work");
-
- waitGui.failWith("Third alert was not displayed").until(condition);
- assertEquals(selenium.getAlert(), "complete", "Attribute
oncomplete does not work");
+ assertEquals(events[0], "begin", "Attribute onbegin doesn't
work");
+ assertEquals(events[1], "beforedomupdate", "Attribute
onbeforedomupdate doesn't work");
+ assertEquals(events[2], "complete", "Attribute oncomplete
doesn't work");
}
@Test
Show replies by date