Author: lfryc(a)redhat.com
Date: 2010-07-10 16:48:22 -0400 (Sat, 10 Jul 2010)
New Revision: 17863
Added:
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/commandButton/
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/commandButton/CommandButtonTestCase.java
Removed:
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/CommandLinkTestCase.java
Modified:
root/tests/metamer/trunk/ftest/pom.xml
root/tests/metamer/trunk/ftest/src/test/resources/testng.xml
Log:
https://jira.jboss.org/browse/RFPL-466
* testng.xml refactored
* test case for button finished and moved
* AbstractTestappTestCase refactored
* one property added to pom.xml
* testng upgraded in pom.xml
* added test listener configuration to pom.xml
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 20:47:45 UTC (rev 17862)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-10 20:48:22 UTC (rev 17863)
@@ -12,6 +12,10 @@
<version>1.5.0-SNAPSHOT</version>
</parent>
+ <properties>
+ <context.path>/testapp</context.path>
+ </properties>
+
<repositories>
<repository>
<id>jboss-public-repository-group</id>
@@ -36,6 +40,12 @@
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
+ <properties>
+ <property>
+ <name>listener</name>
+
<value>org.jboss.test.selenium.listener.ConsoleStatusTestListener</value>
+ </property>
+ </properties>
</configuration>
</execution>
</executions>
@@ -47,7 +57,8 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>5.9</version>
+ <version>5.10</version>
+ <classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
<dependency>
Added:
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/AbstractTestappTestCase.java 2010-07-10
20:48:22 UTC (rev 17863)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.richfaces.tests.testapp;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.test.selenium.AbstractTestCase;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
+
+/**
+ * Abstract test case used as a basis for majority of test cases.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public abstract class AbstractTestappTestCase extends AbstractTestCase {
+
+ /**
+ * timeout in miliseconds
+ */
+ public static final long TIMEOUT = 5000;
+ private String[][] templates;
+
+ /**
+ * Returns the url to test page to be opened by Selenium
+ *
+ * @return absolute url to the test page to be opened by Selenium
+ */
+ public abstract String getTestUrl();
+
+ /**
+ * Data provider for templates.
+ *
+ * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
+ * plain template) if nothing is defined
+ */
+ @DataProvider(name = "templates")
+ protected Object[][] getTemplates() {
+ if (templates != null && templates.length > 0) {
+ return templates;
+ }
+
+ return new Object[][] {{"plain"}};
+ }
+
+ /**
+ * Loads and parses attribute "templates" from testng.xml.
+ *
+ * @param urlParams
+ */
+ @BeforeClass
+ @Parameters({"templates"})
+ public void initTemplates(@Optional String urlParams) {
+ if (urlParams == null) {
+ return;
+ }
+
+ String[] array = urlParams.split(" ");
+ templates = new String[array.length][];
+
+ for (int i = 0; i < array.length; i++) {
+ templates[i] = new String[1];
+ templates[i][0] = array[i];
+ }
+ }
+
+ /**
+ * Opens the tested page. If templates is not empty nor null, it appends url
parameter with templates.
+ *
+ * @param templates
+ * templates that will be used for test, e.g. "red_div"
+ */
+ @BeforeMethod
+ public void loadPage(Object[] templates) {
+ String urlParams = "";
+ if (templates != null && templates.length != 0) {
+ urlParams = "?templates=" + templates[0];
+ }
+ try {
+ selenium.open(new URL(getTestUrl() + urlParams));
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Invalidates session by clicking on a button on tested page.
+ */
+ public void invalidateSession() {
+ JQueryLocator invalidateButton = jq("#form input[value=Invalidate
Session]");
+ selenium.click(invalidateButton);
+ selenium.waitForPageToLoad(TIMEOUT);
+ }
+
+ /**
+ * Forces the current thread sleep for given time.
+ *
+ * @param millis
+ * number of miliseconds for which the thread will sleep
+ */
+ @Deprecated
+ protected void waitFor(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/CommandLinkTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/CommandLinkTestCase.java 2010-07-10
20:47:45 UTC (rev 17862)
+++
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/CommandLinkTestCase.java 2010-07-10
20:48:22 UTC (rev 17863)
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * 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.richfaces.tests.testapp;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.jq;
-import static org.jboss.test.selenium.locator.LocatorFactory.id;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.jboss.test.selenium.AbstractTestCase;
-import org.jboss.test.selenium.locator.Attribute;
-import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.IdLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-
-public class CommandLinkTestCase extends AbstractTestCase {
-
- private JQueryLocator input = jq("#form\\:input");
- private JQueryLocator button = jq("#form\\:commandButton");
- private IdLocator output1 = id("form:output1");
-// private JQueryLocator output1 = jq("#form\\:output1");
- private JQueryLocator output2 = jq("#form\\:output2");
- private JQueryLocator output3 = jq("#form\\:output3");
-
- private static final long TIMEOUT = 5000;
-
- @BeforeMethod
- public void init() throws MalformedURLException {
- selenium.open(new
URL("http://localhost:8080/testapp/faces/components/commandButton/simple.xhtml"));
- }
-
- @AfterMethod
- public void invalidateSession() {
- JQueryLocator invalidateButton = jq("#form input[value=Invalidate
Session]");
- selenium.click(invalidateButton);
- selenium.waitForPageToLoad(TIMEOUT);
- }
-
-// @Test
- public void testSimpleClick() {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
- }
-
-// @Test
- public void testSimpleClickUnicode() {
- selenium.typeKeys(input, "ľščťžýáíéňô");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
-
- output = selenium.getText(output2);
- assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
-
- output = selenium.getText(output3);
- assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
- }
-
-// @Test
- public void testAction() {
- JQueryLocator doubleStringAction =
jq("#form\\:attributes\\:actionInput\\:0");
- JQueryLocator first6CharsAction =
jq("#form\\:attributes\\:actionInput\\:1");
- JQueryLocator toUpperCaseAction =
jq("#form\\:attributes\\:actionInput\\:2");
-
- selenium.click(doubleStringAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output2);
- assertEquals(output, "RichFaces 4RichFaces 4", "output2 when
'RichFaces 4' in input and doubleStringAction selected");
-
- selenium.click(first6CharsAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output2);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
-
- selenium.click(toUpperCaseAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output2);
- assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
- }
-
-// @Test
- public void testActionListener() {
- JQueryLocator doubleStringActionListener =
jq("input[value=doubleStringActionListener]");
- JQueryLocator first6CharsActionListener =
jq("input[value=first6CharsActionListener]");
- JQueryLocator toUpperCaseActionListener =
jq("input[value=toUpperCaseActionListener]");
-
- selenium.click(doubleStringActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
- String output = selenium.getText(output3);
- assertEquals(output, "RichFaces 4RichFaces 4", "output2 when
'RichFaces 4' in input and doubleStringActionListener selected");
-
- selenium.click(first6CharsActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ň");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
- output = selenium.getText(output3);
- assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
-
- selenium.click(toUpperCaseActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4ě");
- selenium.click(button);
- waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
- output = selenium.getText(output3);
- assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseActionListener selected");
- }
-
- @Test
- public void testDisabled() {
- JQueryLocator disabledChecbox =
jq("#form\\:attributes\\:disabledInput");
- AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
-
- selenium.click(disabledChecbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String isDisabled = selenium.getAttribute(disabledAttribute);
- assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
- }
-
- private void waitFor(long millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-}
Copied:
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/commandButton/CommandButtonTestCase.java
(from rev 17862,
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/CommandLinkTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/commandButton/CommandButtonTestCase.java
(rev 0)
+++
root/tests/metamer/trunk/ftest/src/test/java/org/richfaces/tests/testapp/commandButton/CommandButtonTestCase.java 2010-07-10
20:48:22 UTC (rev 17863)
@@ -0,0 +1,262 @@
+/*******************************************************************************
+ * 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.richfaces.tests.testapp.commandButton;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.testapp.AbstractTestappTestCase;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/commandButton/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class CommandButtonTestCase extends AbstractTestappTestCase {
+
+ private JQueryLocator input = jq("#form\\:input");
+ private JQueryLocator button = jq("#form\\:commandButton");
+ private JQueryLocator output1 = jq("#form\\:output1");
+ private JQueryLocator output2 = jq("#form\\:output2");
+ private JQueryLocator output3 = jq("#form\\:output3");
+
+ @Override
+ public String getTestUrl() {
+ return contextPath.toString() +
"/faces/components/commandButton/simple.xhtml";
+ }
+
+ @Override
+ @AfterMethod
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSimpleClick(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "RichFaces 4", "output1 when 'RichFaces
4' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces 4'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4", "output3 when 'RichFaces
4' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSimpleClickUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéňô");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("ľščťžýáíéňô"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "ľščťžýáíéňô", "output1 when
'ľščťžýáíéňô' in input");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "ľščťžý", "output2 when 'ľščťžýáíéňô'
in input");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "ĽŠČŤŽÝÁÍÉŇÔ", "output3 when
'ľščťžýáíéňô' in input");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAction(String templates) {
+ JQueryLocator doubleStringAction =
jq("#form\\:attributes\\:actionInput\\:0");
+ JQueryLocator first6CharsAction =
jq("#form\\:attributes\\:actionInput\\:1");
+ JQueryLocator toUpperCaseAction =
jq("#form\\:attributes\\:actionInput\\:2");
+
+ selenium.click(doubleStringAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output2);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and doubleStringAction
selected");
+
+ selenium.click(first6CharsAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsAction selected");
+
+ selenium.click(toUpperCaseAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output2);
+ assertEquals(output, "RICHFACES 4Ě", "output2 when 'RichFaces
4ě' in input and toUpperCaseAction selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testActionListener(String templates) {
+ JQueryLocator doubleStringActionListener =
jq("input[value=doubleStringActionListener]");
+ JQueryLocator first6CharsActionListener =
jq("input[value=first6CharsActionListener]");
+ JQueryLocator toUpperCaseActionListener =
jq("input[value=toUpperCaseActionListener]");
+
+ selenium.click(doubleStringActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4"));
+ String output = selenium.getText(output3);
+ assertEquals(output, "RichFaces 4RichFaces 4",
+ "output2 when 'RichFaces 4' in input and
doubleStringActionListener selected");
+
+ selenium.click(first6CharsActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ň");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ň"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RichFa", "output2 when 'RichFaces
4ň' in input and first6CharsActionListener selected");
+
+ selenium.click(toUpperCaseActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4ě");
+ selenium.click(button);
+ waitGui.until(textEquals.locator(output1).text("RichFaces 4ě"));
+ output = selenium.getText(output3);
+ assertEquals(output, "RICHFACES 4Ě",
+ "output2 when 'RichFaces 4ě' in input and
toUpperCaseActionListener selected");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDisabled(String templates) {
+ JQueryLocator disabledChecbox =
jq("#form\\:attributes\\:disabledInput");
+ AttributeLocator disabledAttribute = button.getAttribute(new
Attribute("disabled"));
+
+ selenium.click(disabledChecbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String isDisabled = selenium.getAttribute(disabledAttribute);
+ assertEquals(isDisabled.toLowerCase(), "disabled", "The value of
attribute disabled");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ JQueryLocator onclickInput = jq("#form\\:attributes\\:onclickInput");
+ final AttributeLocator onclickAttribute = button.getAttribute(new
Attribute("onclick"));
+ final String value = "alert('onclick')";
+
+ selenium.type(onclickInput, value);
+ selenium.fireEvent(onclickInput, Event.BLUR);
+
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertEquals(selenium.getAttribute(onclickAttribute), value, "onclick
attribute did not change correctly");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ JQueryLocator blue = jq("table#form\\:attributes\\:styleClassInput
input[value=blue]");
+ JQueryLocator red = jq("table#form\\:attributes\\:styleClassInput
input[value=red]");
+ JQueryLocator wide = jq("table#form\\:attributes\\:styleClassInput
input[value=wide]");
+ JQueryLocator big = jq("table#form\\:attributes\\:styleClassInput
input[value=big]");
+ JQueryLocator none = jq("table#form\\:attributes\\:styleClassInput
input[value=]");
+
+ final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
+
+ selenium.click(blue);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "blue"), "Button's
class was not changed to 'blue'");
+
+ selenium.click(red);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "red"), "Button's
class was not changed to 'red'");
+
+ selenium.click(wide);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "wide"), "Button's
class was not changed to 'wide'");
+
+ selenium.click(big);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(button, "big"), "Button's
class was not changed to 'big'");
+
+ selenium.click(none);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ JQueryLocator styleInput = jq("#form\\:attributes\\:styleInput");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.fireEvent(styleInput, Event.BLUR);
+
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ JQueryLocator valueInput = jq("#form\\:attributes\\:valueInput");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.fireEvent(valueInput, Event.BLUR);
+
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
+ }
+
+ // functionality probably not implemented yet
+ // @Test(dataProvider = "templates")
+ public void testRender(String templates) {
+ JQueryLocator renderInput = jq("#form\\:attributes\\:renderInput");
+
+ selenium.typeKeys(renderInput, "output1");
+ selenium.fireEvent(renderInput, Event.BLUR);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "aaa");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("aaa"));
+
+ assertTrue(selenium.isElementPresent(output1), "output1 should be
visible");
+ assertFalse(selenium.isElementPresent(output2), "output2 should not be
visible");
+ assertFalse(selenium.isElementPresent(output3), "output3 should not be
visible");
+ }
+
+}
Modified: root/tests/metamer/trunk/ftest/src/test/resources/testng.xml
===================================================================
--- root/tests/metamer/trunk/ftest/src/test/resources/testng.xml 2010-07-10 20:47:45 UTC
(rev 17862)
+++ root/tests/metamer/trunk/ftest/src/test/resources/testng.xml 2010-07-10 20:48:22 UTC
(rev 17863)
@@ -1,9 +1,10 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="seleniumTest">
- <test name="CommandLinkTestCase">
+ <test name="SimpleComponents">
+ <parameter name="templates" value="plain red_div
red_div,blue_div "/>
<packages>
- <package name="org.richfaces.tests.testapp" />
+ <package name="org.richfaces.tests.testapp.commandButton" />
</packages>
</test>