Author: ppitonak(a)redhat.com
Date: 2010-09-21 12:02:28 -0400 (Tue, 21 Sep 2010)
New Revision: 19288
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
* added new method for checking invoked phases of JSF lifecycle
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-09-21
16:00:08 UTC (rev 19287)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-09-21
16:02:28 UTC (rev 19288)
@@ -22,12 +22,15 @@
package org.richfaces.tests.metamer.ftest;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.net.URL;
+import javax.faces.event.PhaseId;
+
import org.jboss.test.selenium.AbstractTestCase;
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.encapsulated.JavaScript;
@@ -208,4 +211,25 @@
protected void showControls() {
selenium.getEval(new JavaScript("window.showControls()"));
}
+
+ /**
+ * Verifies that only given phases were executed. It uses the list of phases in the
header of the page.
+ * @param phases phases that are expected to have been executed
+ */
+ protected void assertPhases(PhaseId ... phases) {
+ JQueryLocator phasesItems = jq("div#phasesPanel li");
+ int count = selenium.getCount(phasesItems);
+
+ String phase;
+ int phaseNumber = 1;
+
+ for (int i = 0; i < count; i++) {
+ phase = selenium.getText(jq("div#phasesPanel li:eq(" + i +
")"));
+ // check that it is really name of a phase
+ if (!phase.startsWith("* ")) {
+ assertEquals(phase, phases[phaseNumber-1].toString(), "Phase nr.
" + phaseNumber);
+ phaseNumber++;
+ }
+ }
+ }
}
Show replies by date