From richfaces-svn-commits at lists.jboss.org Thu Oct 21 09:29:48 2010 Content-Type: multipart/mixed; boundary="===============1214232520243407460==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r19637 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest and 1 other directory. Date: Thu, 21 Oct 2010 09:29:48 -0400 Message-ID: <201010211329.o9LDTmhP024372@svn01.web.mwc.hst.phx2.redhat.com> --===============1214232520243407460== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/se= lenium/waiting/EventFiredCondition.java Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tes= ts/metamer/ftest/AbstractMetamerTest.java Log: * refactoring Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/tes= t/selenium/waiting/EventFiredCondition.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/s= elenium/waiting/EventFiredCondition.java (rev 0) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/s= elenium/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. variab= le metamerEvents contains event name. + * + * @author Pavol Pitonak + * @version $Revision$ + */ +public class EventFiredCondition implements JavaScriptCondition { + + Event event; + + public EventFiredCondition(final Event event) { + this.event =3D event; + } + + public JavaScript getJavaScriptCondition() { + return new JavaScript("window.metamerEvents.indexOf(\"" + event.ge= tEventName() + "\") !=3D -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/richfa= ces/tests/metamer/ftest/AbstractMetamerTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/AbstractMetamerTest.java 2010-10-21 12:51:37 UTC (rev 196= 36) +++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/te= sts/metamer/ftest/AbstractMetamerTest.java 2010-10-21 13:29:47 UTC (rev 196= 37) @@ -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. va= riable metamerEvents contains event name. - */ - private class EventFiredCondition implements JavaScriptCondition { - - Event event; - - public EventFiredCondition(final Event event) { - this.event =3D event; - } - - public JavaScript getJavaScriptCondition() { - return new JavaScript("window.metamerEvents.indexOf(\"" + even= t.getEventName() + "\") !=3D -1"); - } - } - - /** * timeout in miliseconds */ public static final long TIMEOUT =3D 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 =3D element.getAttribute(Attribute.S= TYLE); - assertEquals(selenium.getAttribute(styleAttr), value, "Attribute s= tyle"); + assertTrue(selenium.getAttribute(styleAttr).contains(value), "Attr= ibute 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 =3D jq("div#phasesPanel li"); int count =3D selenium.getCount(phasesItems); - = + String phase; int phaseNumber =3D 1; - = + for (int i =3D 0; i < count; i++) { phase =3D 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(), "Pha= se nr. " + phaseNumber); + assertEquals(phase, phases[phaseNumber - 1].toString(), "P= hase nr. " + phaseNumber); phaseNumber++; } } --===============1214232520243407460==--