Author: ppitonak(a)redhat.com
Date: 2010-10-21 09:29:47 -0400 (Thu, 21 Oct 2010)
New Revision: 19637
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
Log:
* refactoring
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java 2010-10-21
13:29:47 UTC (rev 19637)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.jboss.test.selenium.waiting;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+
+/**
+ * JavaScript condition that verifies that an event was fired, i.e. variable
metamerEvents contains event name.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class EventFiredCondition implements JavaScriptCondition {
+
+ Event event;
+
+ public EventFiredCondition(final Event event) {
+ this.event = event;
+ }
+
+ public JavaScript getJavaScriptCondition() {
+ return new JavaScript("window.metamerEvents.indexOf(\"" +
event.getEventName() + "\") != -1");
+ }
+}
Property changes on:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/waiting/EventFiredCondition.java
___________________________________________________________________
Name: svn:keywords
+ Revision
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-10-21
12:51:37 UTC (rev 19636)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-10-21
13:29:47 UTC (rev 19637)
@@ -19,7 +19,6 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
*******************************************************************************/
-
package org.richfaces.tests.metamer.ftest;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
@@ -38,7 +37,7 @@
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
import org.richfaces.tests.metamer.TemplatesList;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
@@ -55,26 +54,9 @@
public abstract class AbstractMetamerTest extends AbstractTestCase {
/**
- * JavaScript condition that verifies that an event was fired, i.e. variable
metamerEvents contains event name.
- */
- private class EventFiredCondition implements JavaScriptCondition {
-
- Event event;
-
- public EventFiredCondition(final Event event) {
- this.event = event;
- }
-
- public JavaScript getJavaScriptCondition() {
- return new JavaScript("window.metamerEvents.indexOf(\"" +
event.getEventName() + "\") != -1");
- }
- }
-
- /**
* timeout in miliseconds
*/
public static final long TIMEOUT = 5000;
-
@Inject
@Templates({"plain", "richDataTable1,redDiv",
"richDataTable2,redDiv", "a4jRepeat1", "a4jRepeat2",
"hDataTable1",
"hDataTable2", "uiRepeat1", "uiRepeat2"})
@@ -158,7 +140,7 @@
selenium.fireEvent(element, event);
waitGui.failWith(event.getEventName() + " attribute did not change
correctly").until(
- new EventFiredCondition(event));
+ new EventFiredCondition(event));
}
/**
@@ -176,7 +158,7 @@
selenium.waitForPageToLoad();
AttributeLocator<?> styleAttr = element.getAttribute(Attribute.STYLE);
- assertEquals(selenium.getAttribute(styleAttr), value, "Attribute
style");
+ assertTrue(selenium.getAttribute(styleAttr).contains(value), "Attribute
style should contain \"" + value + "\"");
}
/**
@@ -211,23 +193,23 @@
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) {
+ 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);
+ assertEquals(phase, phases[phaseNumber - 1].toString(), "Phase nr.
" + phaseNumber);
phaseNumber++;
}
}