Author: lfryc(a)redhat.com
Date: 2010-07-20 09:33:16 -0400 (Tue, 20 Jul 2010)
New Revision: 18159
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestCounter.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Removed:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java
Log:
new convention for tests: prefix Test* instead of suffix *TestCase - will improve
orientation across packages
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,137 +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.metamer.ftest.a4jActionListener;
-
-import org.jboss.test.selenium.encapsulated.JavaScript;
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-
-import java.net.URL;
-
-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.selenium.SeleniumCondition;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jActionListener/all.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JActionListenerTestCase extends AbstractMetamerTest {
-
- private ElementLocator invokeButtonType =
pjq("input[id$=invokeByTypeButton]");
- private ElementLocator invokeButtonBinding =
pjq("input[id$=invokeByBindingButton]");
- private ElementLocator invokeButtonMethod =
pjq("input[id$=invokeMethodButton]");
- private ElementLocator invokeButtonCC =
pjq("input[id$=invokeFromCCButton:button]");
- private JQueryLocator message = pjq("ul[id$=messages] li");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jActionListener/all.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerByType(String templates) {
- final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
- final String msg = "Implementation of ActionListener created and called:
"
- +
"org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
-
- selenium.click(invokeButtonType);
- waitGui.until(elementPresent.locator(message));
- final String output1 = selenium.getText(message);
-
- assertEquals(output1.replaceAll(hashCodeRegExp, ""), msg, "Message
after first invocation of listener by type.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
-
- // do the same once again
-
- selenium.click(invokeButtonType);
-
- waitModel.failWith("New object of class ActionListenerImpl should be
instantiated.").until(
- new SeleniumCondition() {
-
- public boolean isTrue() {
- return !output1.equals(selenium.getText(message));
- }
- });
-
- count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
-
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerByBinding(String templates) {
- final String msg = "Bound listener called";
-
- selenium.click(invokeButtonBinding);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener by
binding.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethod(String templates) {
- final String msg = "Method expression listener called";
-
- selenium.click(invokeButtonMethod);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener
method.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-
- @Test(dataProvider = "templates")
- public void testInvokeListenerMethodCC(String templates) {
- final String msg = "Method expression listener called from composite
component";
-
- selenium.click(invokeButtonCC);
- waitGui.until(elementPresent.locator(message));
- String output = selenium.getText(message);
-
- assertEquals(output, msg, "Message after first invocation of listener method
from composite component.");
-
- int count = selenium.getCount(message);
- assertEquals(count, 1, "Only one message should be displayed on the
page.");
- }
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/A4JActionListenerTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -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.metamer.ftest.a4jActionListener;
+
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+
+import java.net.URL;
+
+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.selenium.SeleniumCondition;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jActionListener/all.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestA4JActionListener extends AbstractMetamerTest {
+
+ private ElementLocator invokeButtonType =
pjq("input[id$=invokeByTypeButton]");
+ private ElementLocator invokeButtonBinding =
pjq("input[id$=invokeByBindingButton]");
+ private ElementLocator invokeButtonMethod =
pjq("input[id$=invokeMethodButton]");
+ private ElementLocator invokeButtonCC =
pjq("input[id$=invokeFromCCButton:button]");
+ private JQueryLocator message = pjq("ul[id$=messages] li");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jActionListener/all.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerByType(String templates) {
+ final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
+ final String msg = "Implementation of ActionListener created and called:
"
+ +
"org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
+
+ selenium.click(invokeButtonType);
+ waitGui.until(elementPresent.locator(message));
+ final String output1 = selenium.getText(message);
+
+ assertEquals(output1.replaceAll(hashCodeRegExp, ""), msg, "Message
after first invocation of listener by type.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+
+ // do the same once again
+
+ selenium.click(invokeButtonType);
+
+ waitModel.failWith("New object of class ActionListenerImpl should be
instantiated.").until(
+ new SeleniumCondition() {
+
+ public boolean isTrue() {
+ return !output1.equals(selenium.getText(message));
+ }
+ });
+
+ count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerByBinding(String templates) {
+ final String msg = "Bound listener called";
+
+ selenium.click(invokeButtonBinding);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener by
binding.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerMethod(String templates) {
+ final String msg = "Method expression listener called";
+
+ selenium.click(invokeButtonMethod);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener
method.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInvokeListenerMethodCC(String templates) {
+ final String msg = "Method expression listener called from composite
component";
+
+ selenium.click(invokeButtonCC);
+ waitGui.until(elementPresent.locator(message));
+ String output = selenium.getText(message);
+
+ assertEquals(output, msg, "Message after first invocation of listener method
from composite component.");
+
+ int count = selenium.getCount(message);
+ assertEquals(count, 1, "Only one message should be displayed on the
page.");
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,320 +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.metamer.ftest.a4jCommandButton;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-
-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.ElementLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jCommandButton/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JCommandButtonTestCase extends AbstractMetamerTest {
-
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator button = pjq("input[id$=a4jCommandButton]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jCommandButton/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- 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) {
- ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- 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) {
- ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener =
pjq("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) {
- ElementLocator disabledChecbox = pjq("input[id$=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) {
- testFireEvent(Event.CLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
- testFireEvent(Event.KEYUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
-
- selenium.type(renderInput, "output1");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "aaa");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output1).text("aaa"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
-
- selenium.type(renderInput, "output2 output3");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "bbb");
- selenium.click(button);
-
- waitGui.until(textEquals.locator(output2).text("bbb"));
-
- output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
-
- selenium.click(renderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(button), "Button should not be
displayed");
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator wide = pjq("input[name$=styleClassInput][value=wide]");
- ElementLocator big = pjq("input[name$=styleClassInput][value=big]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
-
- 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) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
- }
-
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
- }
-
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/A4JCommandButtonTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jCommandButton;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+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.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jCommandButton/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestA4JCommandButton extends AbstractMetamerTest {
+
+ private ElementLocator input = pjq("input[id$=input]");
+ private ElementLocator button = pjq("input[id$=a4jCommandButton]");
+ private ElementLocator output1 = pjq("span[id$=output1]");
+ private ElementLocator output2 = pjq("span[id$=output2]");
+ private ElementLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jCommandButton/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ 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) {
+ ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
+ ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ 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) {
+ ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
+ ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ ElementLocator toUpperCaseActionListener =
pjq("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) {
+ ElementLocator disabledChecbox = pjq("input[id$=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) {
+ testFireEvent(Event.CLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOneyup(String templates) {
+ testFireEvent(Event.KEYUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRender(String templates) {
+ ElementLocator renderInput = pjq("input[name$=renderInput]");
+
+ selenium.type(renderInput, "output1");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "aaa");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output1).text("aaa"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
+
+ selenium.type(renderInput, "output2 output3");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "bbb");
+ selenium.click(button);
+
+ waitGui.until(textEquals.locator(output2).text("bbb"));
+
+ output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+
+ selenium.click(renderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(button), "Button should not be
displayed");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator wide = pjq("input[name$=styleClassInput][value=wide]");
+ ElementLocator big = pjq("input[name$=styleClassInput][value=big]");
+ ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
+
+ 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) {
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ ElementLocator valueInput = pjq("input[id$=valueInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
+ }
+
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,336 +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.metamer.ftest.a4jCommandLink;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-
-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.ElementLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jCommandLink/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JCommandLinkTestCase extends AbstractMetamerTest {
-
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator link = pjq("a[id$=a4jCommandLink]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jCommandLink/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testSimpleClick(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
-
- 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(link);
-
- 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) {
- ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- selenium.click(doubleStringAction);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
- 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(link);
- 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(link);
- 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) {
- ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
-
- selenium.click(doubleStringActionListener);
- selenium.waitForPageToLoad(TIMEOUT);
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(link);
- 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(link);
- 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(link);
- 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) {
- ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
- ElementLocator newLink = pjq("span[id$=a4jCommandLink]");
-
- selenium.click(disabledChecbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertFalse(selenium.isElementPresent(link), link.getAsString()
- + " should not be on page when the link is disabled");
- assertTrue(selenium.isElementPresent(newLink), newLink.getAsString()
- + " should be on page when the link is disabled");
-
- }
-
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
- testFireEvent(Event.CLICK, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOneyup(String templates) {
- testFireEvent(Event.KEYUP, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, link);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, link);
- }
-
- @Test(dataProvider = "templates")
- public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
-
- selenium.type(renderInput, "output1");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "aaa");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output1).text("aaa"));
-
- String output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
-
- selenium.type(renderInput, "output2 output3");
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.typeKeys(input, "bbb");
- selenium.click(link);
-
- waitGui.until(textEquals.locator(output2).text("bbb"));
-
- output = selenium.getText(output1);
- assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output2);
- assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- output = selenium.getText(output3);
- assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
-
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
-
- selenium.click(renderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(link), "Button should not be
displayed");
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator bold = pjq("input[name$=styleClassInput][value=bold]");
- ElementLocator strike =
pjq("input[name$=styleClassInput][value=strike]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = link.getAttribute(new
Attribute("class"));
-
- selenium.click(bold);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(link, "bold"), "Button's
class was not changed to 'bold'");
-
- selenium.click(strike);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(link, "strike"), "Button's
class was not changed to 'strike'");
-
- selenium.click(none);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = link.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
- }
-
- @Test(dataProvider = "templates")
- public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getText(link), value, "Value of the button did not
change");
- }
-
- private void testFireEvent(Event event) {
- ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
- final String value = "alert('" + event.getEventName() +
"')";
-
- selenium.type(eventInput, value);
- selenium.fireEvent(eventInput, Event.BLUR);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.fireEvent(link, event);
-
- assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
- + " attribute did not change correctly");
- }
-
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/A4JCommandLinkTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jCommandLink;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+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.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jCommandLink/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestA4JCommandLink extends AbstractMetamerTest {
+
+ private ElementLocator input = pjq("input[id$=input]");
+ private ElementLocator link = pjq("a[id$=a4jCommandLink]");
+ private ElementLocator output1 = pjq("span[id$=output1]");
+ private ElementLocator output2 = pjq("span[id$=output2]");
+ private ElementLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jCommandLink/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testSimpleClick(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+
+ 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(link);
+
+ 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) {
+ ElementLocator doubleStringAction =
pjq("input[value=doubleStringAction]");
+ ElementLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ ElementLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ selenium.click(doubleStringAction);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+ 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(link);
+ 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(link);
+ 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) {
+ ElementLocator doubleStringActionListener =
pjq("input[value=doubleStringActionListener]");
+ ElementLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ ElementLocator toUpperCaseActionListener =
pjq("input[value=toUpperCaseActionListener]");
+
+ selenium.click(doubleStringActionListener);
+ selenium.waitForPageToLoad(TIMEOUT);
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(link);
+ 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(link);
+ 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(link);
+ 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) {
+ ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ ElementLocator newLink = pjq("span[id$=a4jCommandLink]");
+
+ selenium.click(disabledChecbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertFalse(selenium.isElementPresent(link), link.getAsString()
+ + " should not be on page when the link is disabled");
+ assertTrue(selenium.isElementPresent(newLink), newLink.getAsString()
+ + " should be on page when the link is disabled");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ testFireEvent(Event.CLICK, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOneyup(String templates) {
+ testFireEvent(Event.KEYUP, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, link);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRender(String templates) {
+ ElementLocator renderInput = pjq("input[name$=renderInput]");
+
+ selenium.type(renderInput, "output1");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "aaa");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output1).text("aaa"));
+
+ String output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'aaa' in input
and 'output1' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "", "output2 when 'aaa' in input and
'output1' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "", "output3 when 'aaa' in input and
'output1' set to be rerendered");
+
+ selenium.type(renderInput, "output2 output3");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.typeKeys(input, "bbb");
+ selenium.click(link);
+
+ waitGui.until(textEquals.locator(output2).text("bbb"));
+
+ output = selenium.getText(output1);
+ assertEquals(output, "aaa", "output1 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output2);
+ assertEquals(output, "bbb", "output2 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ output = selenium.getText(output3);
+ assertEquals(output, "BBB", "output3 when 'bbb' in input
and 'output2 output3' set to be rerendered");
+
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+
+ selenium.click(renderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(link), "Button should not be
displayed");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator bold = pjq("input[name$=styleClassInput][value=bold]");
+ ElementLocator strike =
pjq("input[name$=styleClassInput][value=strike]");
+ ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = link.getAttribute(new
Attribute("class"));
+
+ selenium.click(bold);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(link, "bold"), "Button's
class was not changed to 'bold'");
+
+ selenium.click(strike);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(link, "strike"), "Button's
class was not changed to 'strike'");
+
+ selenium.click(none);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isAttributePresent(classAttribute), "Button's class
was not removed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = link.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Style of the button
did not change");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testValue(String templates) {
+ ElementLocator valueInput = pjq("input[id$=valueInput]");
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getText(link), value, "Value of the button did not
change");
+ }
+
+ private void testFireEvent(Event event) {
+ ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() +
"Input]");
+ final String value = "alert('" + event.getEventName() +
"')";
+
+ selenium.type(eventInput, value);
+ selenium.fireEvent(eventInput, Event.BLUR);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.fireEvent(link, event);
+
+ assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
+ + " attribute did not change correctly");
+ }
+
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,234 +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.metamer.ftest.a4jLog;
-
-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.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jLog/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JLogTestCase extends AbstractMetamerTest {
-
- /**
- * Enumeration representing all possible levels for a4j:log.
- */
- public enum LogLevel {
- DEBUG, INFO, WARN, ERROR;
- }
-
- private ElementLocator input = pjq("input[id$=nameInput]");
- private ElementLocator submitButton = pjq("input[id$=submitButton]");
- private ElementLocator output = pjq("span[id$=out]");
-
- private ElementLocator log = pjq("div.rich-log");
- private ElementLocator levelSelect = pjq("div.rich-log select");
- private JQueryLocator logMsg = pjq("div.rich-log div.rich-log-contents
div");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath, "faces/components/a4jLog/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates")
- public void testSubmit(String templates) {
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testSubmitUnicode(String templates) {
- selenium.typeKeys(input, "ľščťžýáíéôúäň");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello
ľščťžýáíéôúäň!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testClearButton(String templates) {
- ElementLocator clearButton = pjq("div.rich-log button");
-
- selenium.typeKeys(input, "RichFaces 4");
- selenium.click(submitButton);
-
- waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
-
- int count = selenium.getCount(logMsg);
- assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
-
- // test clear
- selenium.click(clearButton);
- count = selenium.getCount(logMsg);
- assertEquals(count, 0, "There should be no messages in log after clear
button was clicked.");
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertFalse(selenium.isElementPresent(log), "Log should not be
displayed.");
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterDebug(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterInfo(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterWarn(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testDebugFilterError(String templates) {
- testLogging(LogLevel.DEBUG, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterDebug(String templates) {
- testLogging(LogLevel.INFO, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterInfo(String templates) {
- testLogging(LogLevel.INFO, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterWarn(String templates) {
- testLogging(LogLevel.INFO, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testInfoFilterError(String templates) {
- testLogging(LogLevel.INFO, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterDebug(String templates) {
- testLogging(LogLevel.WARN, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterInfo(String templates) {
- testLogging(LogLevel.WARN, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterWarn(String templates) {
- testLogging(LogLevel.WARN, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testWarnFilterError(String templates) {
- testLogging(LogLevel.WARN, LogLevel.ERROR);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterDebug(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.DEBUG);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterInfo(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.INFO);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterWarn(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.WARN);
- }
-
- @Test(dataProvider = "templates")
- public void testErrorFilterError(String templates) {
- testLogging(LogLevel.ERROR, LogLevel.ERROR);
- }
-
- private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
- ElementLocator logButton = pjq("input[id$=" +
logLevel.toString().toLowerCase() + "Button]");
- ElementLocator levelInput = pjq("input[type=radio][value=" +
filterLevel.toString().toLowerCase() + "]");
- ElementLocator msgType = logMsg.getChild(jq("span:eq(0)"));
- ElementLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
-
- if (filterLevel != LogLevel.DEBUG) {
- selenium.click(levelInput);
- selenium.waitForPageToLoad(TIMEOUT);
- }
-
- String selectedLevel = selenium.getSelectedLabel(levelSelect);
- assertEquals(selectedLevel, filterLevel.toString().toLowerCase(), "Log level
in select wasn't changed.");
-
- selenium.typeKeys(input, logLevel.toString());
- selenium.click(logButton);
-
- int count = selenium.getCount(logMsg);
- assertEquals(count, filterLevel.ordinal() <= logLevel.ordinal() ? 1 : 0,
- "There should be only one message in log.");
-
- if (count == 0) {
- return;
- }
-
- String output = selenium.getText(msgType).replaceAll("\\[.*\\]:$",
"");
- assertEquals(output, logLevel.toString().toLowerCase(), "Message type in
log.");
- output = selenium.getText(msgContent);
- assertEquals(output, logLevel.toString(), "Message content.");
-
- }
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/A4JLogTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jLog;
+
+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.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jLog/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestA4JLog extends AbstractMetamerTest {
+
+ /**
+ * Enumeration representing all possible levels for a4j:log.
+ */
+ public enum LogLevel {
+ DEBUG, INFO, WARN, ERROR;
+ }
+
+ private ElementLocator input = pjq("input[id$=nameInput]");
+ private ElementLocator submitButton = pjq("input[id$=submitButton]");
+ private ElementLocator output = pjq("span[id$=out]");
+
+ private ElementLocator log = pjq("div.rich-log");
+ private ElementLocator levelSelect = pjq("div.rich-log select");
+ private JQueryLocator logMsg = pjq("div.rich-log div.rich-log-contents
div");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/a4jLog/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSubmit(String templates) {
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testSubmitUnicode(String templates) {
+ selenium.typeKeys(input, "ľščťžýáíéôúäň");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello
ľščťžýáíéôúäň!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testClearButton(String templates) {
+ ElementLocator clearButton = pjq("div.rich-log button");
+
+ selenium.typeKeys(input, "RichFaces 4");
+ selenium.click(submitButton);
+
+ waitGui.until(textEquals.locator(output).text("Hello RichFaces 4!"));
+
+ int count = selenium.getCount(logMsg);
+ assertTrue(count > 0, "There should be at least one message in log after
submit button was clicked.");
+
+ // test clear
+ selenium.click(clearButton);
+ count = selenium.getCount(logMsg);
+ assertEquals(count, 0, "There should be no messages in log after clear
button was clicked.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertFalse(selenium.isElementPresent(log), "Log should not be
displayed.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterDebug(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterInfo(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterWarn(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDebugFilterError(String templates) {
+ testLogging(LogLevel.DEBUG, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterDebug(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterInfo(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterWarn(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testInfoFilterError(String templates) {
+ testLogging(LogLevel.INFO, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterDebug(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterInfo(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterWarn(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testWarnFilterError(String templates) {
+ testLogging(LogLevel.WARN, LogLevel.ERROR);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterDebug(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.DEBUG);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterInfo(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.INFO);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterWarn(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.WARN);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testErrorFilterError(String templates) {
+ testLogging(LogLevel.ERROR, LogLevel.ERROR);
+ }
+
+ private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
+ ElementLocator logButton = pjq("input[id$=" +
logLevel.toString().toLowerCase() + "Button]");
+ ElementLocator levelInput = pjq("input[type=radio][value=" +
filterLevel.toString().toLowerCase() + "]");
+ ElementLocator msgType = logMsg.getChild(jq("span:eq(0)"));
+ ElementLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
+
+ if (filterLevel != LogLevel.DEBUG) {
+ selenium.click(levelInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ }
+
+ String selectedLevel = selenium.getSelectedLabel(levelSelect);
+ assertEquals(selectedLevel, filterLevel.toString().toLowerCase(), "Log level
in select wasn't changed.");
+
+ selenium.typeKeys(input, logLevel.toString());
+ selenium.click(logButton);
+
+ int count = selenium.getCount(logMsg);
+ assertEquals(count, filterLevel.ordinal() <= logLevel.ordinal() ? 1 : 0,
+ "There should be only one message in log.");
+
+ if (count == 0) {
+ return;
+ }
+
+ String output = selenium.getText(msgType).replaceAll("\\[.*\\]:$",
"");
+ assertEquals(output, logLevel.toString().toLowerCase(), "Message type in
log.");
+ output = selenium.getText(msgContent);
+ assertEquals(output, logLevel.toString(), "Message content.");
+
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,307 +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.metamer.ftest.a4jOutputPanel;
-
-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.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-
-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.ElementLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Test case for page /faces/components/a4jOutputPanel/simple.xhtml
- *
- * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
- * @version $Revision$
- */
-public class A4JOutputPanelTestCase extends AbstractMetamerTest {
-
- private ElementLocator increaseCounterButton = pjq("input[id$=button]");
- private ElementLocator outputDiv = pjq("div[id$=outputPanel]");
- private ElementLocator outputSpan = pjq("span[id$=outputPanel]");
- private ElementLocator optionBlue =
pjq("input[name$=styleClassInput][value=blue-background]");
- private ElementLocator optionGray =
pjq("input[name$=styleClassInput][value=gray-background]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/a4jOutputPanel/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- /**
- * Data provider for templates, events and layout of output panel.
- *
- * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
- * plain template) if nothing is defined, JavaScript events that are defined
for output panel and layout of
- * panel (block or inline)
- */
- @DataProvider(name = "templatesEventsLayouts")
- private Object[][] getTemplatesEventsLayouts() {
- final int layoutsCount = 2;
- // list of templates, e.g. {{"plain"},
{"richDataTable1,redDiv"}}
- Object[][] templates = getTemplates();
- // list of events that will be tested
- Event[] events = new Event[]{Event.CLICK, Event.DBLCLICK, Event.KEYDOWN,
Event.KEYPRESS, Event.KEYUP,
- Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER,
Event.MOUSEUP};
-
- Object[][] result = new Object[templates.length * events.length *
layoutsCount][];
- int index = 0;
-
- for (int i = 0; i < templates.length; i++) {
- for (int j = 0; j < events.length; j++) {
- for (int k = 0; k < layoutsCount; k++) {
- index = i * events.length * layoutsCount + j * layoutsCount + k;
- result[index] = new Object[]{templates[i][0], events[j], k == 0 ?
"block" : "inline"};
- }
- }
- }
-
- return result;
- }
-
- @Test(dataProvider = "templatesEventsLayouts")
- public void testEvent(String templates, Event event, String type) {
- ElementLocator element = null;
-
- if ("inline".equals(type)) {
- // for inline layout set background to blue
- selenium.click(pjq("input[name$=layoutInput][value=inline]"));
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
-
- element = outputSpan;
- } else {
- // for inline layout set background to gray
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
-
- element = outputDiv;
- }
-
- testFireEvent(event, element);
- }
-
- @Test(dataProvider = "templates")
- public void testClick(String templates) {
- selenium.click(increaseCounterButton);
- waitGui.until(textEquals.locator(outputDiv).text("1"));
-
- selenium.click(increaseCounterButton);
- waitGui.until(textEquals.locator(outputDiv).text("2"));
- }
-
- @Test(dataProvider = "templates")
- public void testAjaxRendered(String templates) {
- ElementLocator ajaxRenderedCheckbox =
pjq("input[id$=ajaxRenderedInput]");
- ElementLocator reRenderAllImage = jq("div.header
img[id$=reRenderAllImage]");
-
- selenium.click(ajaxRenderedCheckbox);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.click(increaseCounterButton);
- selenium.click(increaseCounterButton);
-
- String output = selenium.getText(outputDiv);
- assertEquals(output, "0", "Output after two clicks when
ajaxRendered is set to false.");
-
- selenium.click(reRenderAllImage);
- waitGui.until(textEquals.locator(outputDiv).text("2"));
- }
-
- @Test(dataProvider = "templates")
- public void testDir(String templates) {
- ElementLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
- ElementLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
- ElementLocator optionNone = pjq("input[name$=dirInput][value=]");
- AttributeLocator attributeDir = outputDiv.getAttribute(new
Attribute("dir"));
-
- // right-to-left
- selenium.click(optionRtl);
- selenium.waitForPageToLoad(TIMEOUT);
- String attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "rtl", "Attribute dir after rtl was
set.");
-
- // left-to-right
- selenium.click(optionLtr);
- selenium.waitForPageToLoad(TIMEOUT);
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "ltr", "Attribute dir after ltr was
set.");
-
- // not specified
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeDir)) {
- attributeValue = selenium.getAttribute(attributeDir);
- assertEquals(attributeValue, "", "Attribute dir after none was
set.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testLang(String templates) {
- ElementLocator langInput = pjq("input[id$=langInput]");
- AttributeLocator attributeLang = outputDiv.getAttribute(new
Attribute("lang"));
-
- selenium.typeKeys(langInput, "en");
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeLang);
- assertEquals(attributeValue, "en", "Lang attribute");
-
- selenium.typeKeys(langInput, "sk");
- selenium.waitForPageToLoad(TIMEOUT);
-
- attributeValue = selenium.getAttribute(attributeLang);
- assertEquals(attributeValue, "sk", "Lang attribute");
- }
-
- @Test(dataProvider = "templates")
- public void testLayout(String templates) {
- ElementLocator optionBlock =
pjq("input[name$=layoutInput][value=block]");
- ElementLocator optionInline =
pjq("input[name$=layoutInput][value=inline]");
- ElementLocator optionNone =
pjq("input[name$=layoutInput][value=none]");
-
- assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered on
the beginning.");
- assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
on the beginning.");
-
- selenium.click(optionInline);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when inline is set.");
- assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when inline is set.");
-
- selenium.click(optionBlock);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered
when block is set.");
- assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
when block is set.");
-
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when none is set.");
- assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when none is set.");
- }
-
- @Test(dataProvider = "templates")
- public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
- assertFalse(selenium.isElementPresent(outputDiv), "Panel should not be
rendered.");
-
- selenium.click(increaseCounterButton);
- selenium.click(increaseCounterButton);
-
- selenium.click(renderedInput);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.isElementPresent(outputDiv), "Panel should be
rendered.");
-
- String counter = selenium.getText(outputDiv);
- assertEquals(counter, "2", "Counter after two clicks on
button.");
- }
-
- @Test(dataProvider = "templates")
- public void testStyle(String templates) {
- String style = "background-color: magenta; color: white; font-weight:
bold;";
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- AttributeLocator attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
-
- selenium.typeKeys(styleInput, style);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, style, "Value of attribute style.");
-
- selenium.typeKeys(styleInput, "");
- selenium.waitForPageToLoad(TIMEOUT);
-
- if (selenium.isAttributePresent(attributeStyle)) {
- attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, "", "Value of attribute
style.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
- ElementLocator optionNone =
pjq("input[name$=styleClassInput][value=]");
- AttributeLocator attributeClass = outputDiv.getAttribute(Attribute.CLASS);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "blue-background"),
"Panel should have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
-
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "gray-background"),
"Panel should have class gray-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
-
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeClass)) {
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
- }
- }
-
- @Test(dataProvider = "templates")
- public void testTitle(String templates) {
- String title = "a4j:outputPanel title";
- ElementLocator titleInput = pjq("input[id$=titleInput]");
- AttributeLocator attributeTitle = outputDiv.getAttribute(new
Attribute("title"));
-
- selenium.typeKeys(titleInput, title);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeTitle);
- assertEquals(attributeValue, title, "Value of attribute title.");
-
- selenium.typeKeys(titleInput, "");
- selenium.waitForPageToLoad(TIMEOUT);
-
- if (selenium.isAttributePresent(attributeTitle)) {
- attributeValue = selenium.getAttribute(attributeTitle);
- assertEquals(attributeValue, "", "Value of attribute
style.");
- }
- }
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/A4JOutputPanelTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,307 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jOutputPanel;
+
+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.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+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.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page /faces/components/a4jOutputPanel/simple.xhtml
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestA4JOutputPanel extends AbstractMetamerTest {
+
+ private ElementLocator increaseCounterButton = pjq("input[id$=button]");
+ private ElementLocator outputDiv = pjq("div[id$=outputPanel]");
+ private ElementLocator outputSpan = pjq("span[id$=outputPanel]");
+ private ElementLocator optionBlue =
pjq("input[name$=styleClassInput][value=blue-background]");
+ private ElementLocator optionGray =
pjq("input[name$=styleClassInput][value=gray-background]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/a4jOutputPanel/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ /**
+ * Data provider for templates, events and layout of output panel.
+ *
+ * @return array containing templates that should be used (defined in testng.xml) or
default array (containing only
+ * plain template) if nothing is defined, JavaScript events that are defined
for output panel and layout of
+ * panel (block or inline)
+ */
+ @DataProvider(name = "templatesEventsLayouts")
+ private Object[][] getTemplatesEventsLayouts() {
+ final int layoutsCount = 2;
+ // list of templates, e.g. {{"plain"},
{"richDataTable1,redDiv"}}
+ Object[][] templates = getTemplates();
+ // list of events that will be tested
+ Event[] events = new Event[]{Event.CLICK, Event.DBLCLICK, Event.KEYDOWN,
Event.KEYPRESS, Event.KEYUP,
+ Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER,
Event.MOUSEUP};
+
+ Object[][] result = new Object[templates.length * events.length *
layoutsCount][];
+ int index = 0;
+
+ for (int i = 0; i < templates.length; i++) {
+ for (int j = 0; j < events.length; j++) {
+ for (int k = 0; k < layoutsCount; k++) {
+ index = i * events.length * layoutsCount + j * layoutsCount + k;
+ result[index] = new Object[]{templates[i][0], events[j], k == 0 ?
"block" : "inline"};
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Test(dataProvider = "templatesEventsLayouts")
+ public void testEvent(String templates, Event event, String type) {
+ ElementLocator element = null;
+
+ if ("inline".equals(type)) {
+ // for inline layout set background to blue
+ selenium.click(pjq("input[name$=layoutInput][value=inline]"));
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.click(optionBlue);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ element = outputSpan;
+ } else {
+ // for inline layout set background to gray
+ selenium.click(optionGray);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ element = outputDiv;
+ }
+
+ testFireEvent(event, element);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testClick(String templates) {
+ selenium.click(increaseCounterButton);
+ waitGui.until(textEquals.locator(outputDiv).text("1"));
+
+ selenium.click(increaseCounterButton);
+ waitGui.until(textEquals.locator(outputDiv).text("2"));
+ }
+
+ @Test(dataProvider = "templates")
+ public void testAjaxRendered(String templates) {
+ ElementLocator ajaxRenderedCheckbox =
pjq("input[id$=ajaxRenderedInput]");
+ ElementLocator reRenderAllImage = jq("div.header
img[id$=reRenderAllImage]");
+
+ selenium.click(ajaxRenderedCheckbox);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ selenium.click(increaseCounterButton);
+ selenium.click(increaseCounterButton);
+
+ String output = selenium.getText(outputDiv);
+ assertEquals(output, "0", "Output after two clicks when
ajaxRendered is set to false.");
+
+ selenium.click(reRenderAllImage);
+ waitGui.until(textEquals.locator(outputDiv).text("2"));
+ }
+
+ @Test(dataProvider = "templates")
+ public void testDir(String templates) {
+ ElementLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
+ ElementLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
+ ElementLocator optionNone = pjq("input[name$=dirInput][value=]");
+ AttributeLocator attributeDir = outputDiv.getAttribute(new
Attribute("dir"));
+
+ // right-to-left
+ selenium.click(optionRtl);
+ selenium.waitForPageToLoad(TIMEOUT);
+ String attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "rtl", "Attribute dir after rtl was
set.");
+
+ // left-to-right
+ selenium.click(optionLtr);
+ selenium.waitForPageToLoad(TIMEOUT);
+ attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "ltr", "Attribute dir after ltr was
set.");
+
+ // not specified
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ if (selenium.isAttributePresent(attributeDir)) {
+ attributeValue = selenium.getAttribute(attributeDir);
+ assertEquals(attributeValue, "", "Attribute dir after none was
set.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testLang(String templates) {
+ ElementLocator langInput = pjq("input[id$=langInput]");
+ AttributeLocator attributeLang = outputDiv.getAttribute(new
Attribute("lang"));
+
+ selenium.typeKeys(langInput, "en");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeLang);
+ assertEquals(attributeValue, "en", "Lang attribute");
+
+ selenium.typeKeys(langInput, "sk");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ attributeValue = selenium.getAttribute(attributeLang);
+ assertEquals(attributeValue, "sk", "Lang attribute");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testLayout(String templates) {
+ ElementLocator optionBlock =
pjq("input[name$=layoutInput][value=block]");
+ ElementLocator optionInline =
pjq("input[name$=layoutInput][value=inline]");
+ ElementLocator optionNone =
pjq("input[name$=layoutInput][value=none]");
+
+ assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered on
the beginning.");
+ assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
on the beginning.");
+
+ selenium.click(optionInline);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when inline is set.");
+ assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when inline is set.");
+
+ selenium.click(optionBlock);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered
when block is set.");
+ assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered
when block is set.");
+
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Span should be rendered
when none is set.");
+ assertTrue(selenium.isElementPresent(outputSpan), "Span should be rendered
when none is set.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testRendered(String templates) {
+ ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertFalse(selenium.isElementPresent(outputDiv), "Panel should not be
rendered.");
+
+ selenium.click(increaseCounterButton);
+ selenium.click(increaseCounterButton);
+
+ selenium.click(renderedInput);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.isElementPresent(outputDiv), "Panel should be
rendered.");
+
+ String counter = selenium.getText(outputDiv);
+ assertEquals(counter, "2", "Counter after two clicks on
button.");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyle(String templates) {
+ String style = "background-color: magenta; color: white; font-weight:
bold;";
+ ElementLocator styleInput = pjq("input[id$=styleInput]");
+ AttributeLocator attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
+
+ selenium.typeKeys(styleInput, style);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeStyle);
+ assertEquals(attributeValue, style, "Value of attribute style.");
+
+ selenium.typeKeys(styleInput, "");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ if (selenium.isAttributePresent(attributeStyle)) {
+ attributeValue = selenium.getAttribute(attributeStyle);
+ assertEquals(attributeValue, "", "Value of attribute
style.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+ ElementLocator optionNone =
pjq("input[name$=styleClassInput][value=]");
+ AttributeLocator attributeClass = outputDiv.getAttribute(Attribute.CLASS);
+
+ selenium.click(optionBlue);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(outputDiv, "blue-background"),
"Panel should have class blue-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
+ "Panel should not have class gray-background set.");
+
+ selenium.click(optionGray);
+ selenium.waitForPageToLoad(TIMEOUT);
+ assertTrue(selenium.belongsClass(outputDiv, "gray-background"),
"Panel should have class gray-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
+ "Panel should not have class blue-background set.");
+
+ selenium.click(optionNone);
+ selenium.waitForPageToLoad(TIMEOUT);
+ if (selenium.isAttributePresent(attributeClass)) {
+ assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
+ "Panel should not have class blue-background set.");
+ assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
+ "Panel should not have class gray-background set.");
+ }
+ }
+
+ @Test(dataProvider = "templates")
+ public void testTitle(String templates) {
+ String title = "a4j:outputPanel title";
+ ElementLocator titleInput = pjq("input[id$=titleInput]");
+ AttributeLocator attributeTitle = outputDiv.getAttribute(new
Attribute("title"));
+
+ selenium.typeKeys(titleInput, title);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ String attributeValue = selenium.getAttribute(attributeTitle);
+ assertEquals(attributeValue, title, "Value of attribute title.");
+
+ selenium.typeKeys(titleInput, "");
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ if (selenium.isAttributePresent(attributeTitle)) {
+ attributeValue = selenium.getAttribute(attributeTitle);
+ assertEquals(attributeValue, "", "Value of attribute
style.");
+ }
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,155 +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.metamer.ftest.a4jPoll;
-
-import java.net.URL;
-
-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.ElementLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.testng.Assert.*;
-import static org.jboss.test.selenium.SystemProperties.isSeleniumDebug;
-import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
-import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
-
-/**
- * Tests the a4j:poll component.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class PollTestCase extends AbstractMetamerTest {
-
- private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
- private static final int[] TEST_INTERVAL_VALUES = new int[]{1000, 5000, 500};
- private static final int TEST_INTERVAL_ITERATIONS = 5;
- private static final int MAX_DEVIATION = 100;
- private static final int MAX_AVERAGE_DEVIATION = 50;
-
- ElementLocator attributeEnabled = id("form:attributes:enabledInput");
- ElementLocator attributeInterval = id("form:attributes:intervalInput");
- JQueryLocator time = pjq("span[id$=time]");
- AttributeLocator clientTime =
pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
- }
-
- @AfterMethod(alwaysRun = true)
- public void clearSession() {
- invalidateSession();
- }
-
- /**
- * <p>
- * Test the progress of polling for 3 different values from client side.
- * </p>
- *
- * <p>
- * It defines the new interval value first for each iteration and then enable
polling.
- * </p>
- *
- * <p>
- * Then, it waits for first poll event (zero iteration).
- * </p>
- *
- * <p>
- * For 5 following poll events it checks that runtime visible from client (output
from JavaScript's new
- * Date().getTime()) between the events haven't greater deviation from defined
interval than defined
- * {@link #MAX_DEVIATION}.
- * </p>
- *
- * <p>
- * Test also computes average value of deviation and checks that the average value of
all obtained particular
- * deviations isn't greater than {@link #MAX_AVERAGE_DEVIATION}.
- * </p>
- */
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testIntervalFromClientPerspective(String templates) {
-
- long total = 0;
- long count = 0;
- for (int interval : TEST_INTERVAL_VALUES) {
- selenium.type(attributeInterval, String.valueOf(interval));
- selenium.waitForPageToLoad();
-
- selenium.check(attributeEnabled);
- selenium.fireEvent(attributeEnabled, Event.CHANGE);
- selenium.waitForPageToLoad();
-
- selenium.getPageExtensions().install();
-
- long currentTime = getClientTime();
-
- for (int i = 0; i <= TEST_INTERVAL_ITERATIONS; i++) {
- long runtime = System.currentTimeMillis();
- selenium.getRequestInterceptor().clearRequestTypeDone();
- selenium.getRequestInterceptor().waitForRequestTypeChange();
- runtime -= getClientTime();
- if (i > 0) {
-
- long deviation = Math.abs(interval - Math.abs(runtime));
- if (isSeleniumDebug()) {
- System.out.println(format("deviation for interval {0}:
{1}", interval, deviation));
- }
- assertTrue(deviation <= MAX_DEVIATION, format(
- "Particular deviation ({2}) for interval {0} was greater
than {1}", interval, MAX_DEVIATION,
- deviation));
- total += deviation;
- count += 1;
- }
- currentTime += runtime;
- }
-
- selenium.uncheck(attributeEnabled);
- selenium.fireEvent(attributeEnabled, Event.CHANGE);
- selenium.waitForPageToLoad();
- }
-
- long averageDeviation = total / count;
-
- if (isSeleniumDebug()) {
- System.out.println(format("total average deviation: {0}",
averageDeviation));
- }
-
- assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
- "Average deviation ({1}) was greater than given maximum {0}",
MAX_AVERAGE_DEVIATION, averageDeviation));
- }
-
- /**
- * Returns the time of poll event (the time when arrived the response from server)
- * @return the time of poll event (the time when arrived the response from server)
- */
- private long getClientTime() {
- return asLong(selenium.getAttribute(clientTime));
- }
-
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/PollTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jPoll;
+
+import java.net.URL;
+
+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.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.testng.Assert.*;
+import static org.jboss.test.selenium.SystemProperties.isSeleniumDebug;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.jboss.test.selenium.utils.PrimitiveUtils.*;
+
+/**
+ * Tests the a4j:poll component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPoll extends AbstractMetamerTest {
+
+ private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
+ private static final int[] TEST_INTERVAL_VALUES = new int[]{1000, 5000, 500};
+ private static final int TEST_INTERVAL_ITERATIONS = 5;
+ private static final int MAX_DEVIATION = 100;
+ private static final int MAX_AVERAGE_DEVIATION = 50;
+
+ ElementLocator attributeEnabled = id("form:attributes:enabledInput");
+ ElementLocator attributeInterval = id("form:attributes:intervalInput");
+ JQueryLocator time = pjq("span[id$=time]");
+ AttributeLocator clientTime =
pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void clearSession() {
+ invalidateSession();
+ }
+
+ /**
+ * <p>
+ * Test the progress of polling for 3 different values from client side.
+ * </p>
+ *
+ * <p>
+ * It defines the new interval value first for each iteration and then enable
polling.
+ * </p>
+ *
+ * <p>
+ * Then, it waits for first poll event (zero iteration).
+ * </p>
+ *
+ * <p>
+ * For 5 following poll events it checks that runtime visible from client (output
from JavaScript's new
+ * Date().getTime()) between the events haven't greater deviation from defined
interval than defined
+ * {@link #MAX_DEVIATION}.
+ * </p>
+ *
+ * <p>
+ * Test also computes average value of deviation and checks that the average value of
all obtained particular
+ * deviations isn't greater than {@link #MAX_AVERAGE_DEVIATION}.
+ * </p>
+ */
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testIntervalFromClientPerspective(String templates) {
+
+ long total = 0;
+ long count = 0;
+ for (int interval : TEST_INTERVAL_VALUES) {
+ selenium.type(attributeInterval, String.valueOf(interval));
+ selenium.waitForPageToLoad();
+
+ selenium.check(attributeEnabled);
+ selenium.fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.waitForPageToLoad();
+
+ selenium.getPageExtensions().install();
+
+ long currentTime = getClientTime();
+
+ for (int i = 0; i <= TEST_INTERVAL_ITERATIONS; i++) {
+ long runtime = System.currentTimeMillis();
+ selenium.getRequestInterceptor().clearRequestTypeDone();
+ selenium.getRequestInterceptor().waitForRequestTypeChange();
+ runtime -= getClientTime();
+ if (i > 0) {
+
+ long deviation = Math.abs(interval - Math.abs(runtime));
+ if (isSeleniumDebug()) {
+ System.out.println(format("deviation for interval {0}:
{1}", interval, deviation));
+ }
+ assertTrue(deviation <= MAX_DEVIATION, format(
+ "Particular deviation ({2}) for interval {0} was greater
than {1}", interval, MAX_DEVIATION,
+ deviation));
+ total += deviation;
+ count += 1;
+ }
+ currentTime += runtime;
+ }
+
+ selenium.uncheck(attributeEnabled);
+ selenium.fireEvent(attributeEnabled, Event.CHANGE);
+ selenium.waitForPageToLoad();
+ }
+
+ long averageDeviation = total / count;
+
+ if (isSeleniumDebug()) {
+ System.out.println(format("total average deviation: {0}",
averageDeviation));
+ }
+
+ assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
+ "Average deviation ({1}) was greater than given maximum {0}",
MAX_AVERAGE_DEVIATION, averageDeviation));
+ }
+
+ /**
+ * Returns the time of poll event (the time when arrived the response from server)
+ * @return the time of poll event (the time when arrived the response from server)
+ */
+ private long getClientTime() {
+ return asLong(selenium.getAttribute(clientTime));
+ }
+
+}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jPush;
+
+import static org.testng.Assert.*;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.jboss.test.selenium.SeleniumGetter.*;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.jboss.test.selenium.SystemProperties;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.BeforeClass;
+
+/**
+ * Abstract test case for testing a4j:push component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public abstract class AbstractPushTest extends AbstractMetamerTest {
+
+ private static final int STATUS_CODE_OK = 200;
+
+ protected PushAttributes pushAttributes = new PushAttributes();
+
+ private ElementLocator outputCounter = pjq("span[id$=outputCounter]");
+
+ private HttpClient httpClient;
+ private HttpMethod pushMethod;
+
+ @Override
+ public URL getTestUrl() {
+ URL contextPath = SystemProperties.getContextPath();
+ return buildUrl(contextPath, "faces/components/a4jPush/simple.xhtml");
+ }
+
+ /**
+ * Initializes the HttpClient which triggers events in {@link #generatePushEvent()}.
+ */
+ @BeforeClass
+ public void initializeHttpClient() {
+ httpClient = new HttpClient();
+ URL eventProducerUrl = buildUrl(getTestUrl(), "event-producer.xhtml");
+ pushMethod = new GetMethod(eventProducerUrl.toString());
+ }
+
+ /**
+ * Returns the value of counter as pushed value
+ *
+ * @return the value of counter as pushed value
+ */
+ protected int getCounter() {
+ return getText(outputCounter).asInteger();
+ }
+
+ /**
+ * Push the event specified number times and then waits for observation of event by
client.
+ *
+ * @param numberOfPushes
+ * the number of events should be generated
+ */
+ protected void pushAndWait(int numberOfPushes) throws HttpException, IOException {
+ selenium.getPageExtensions().install();
+ selenium.getRequestInterceptor().clearRequestTypeDone();
+
+ for (int i = 0; i < numberOfPushes; i++) {
+ generatePushEvent();
+ }
+
+ selenium.getRequestInterceptor().waitForRequestTypeChange();
+ RequestType requestDone = selenium.getRequestInterceptor().getRequestTypeDone();
+
+ assertEquals(requestDone, RequestType.XHR);
+ }
+
+ /**
+ * <p>
+ * Generates the push event for all registered listeners from a4j:push test Simple
page.
+ * </p>
+ *
+ * <p>
+ * Internally use HttpClient to ping URL triggering push event in preRenderView
phase.
+ * </p>
+ */
+ private void generatePushEvent() throws HttpException, IOException {
+ httpClient.executeMethod(pushMethod);
+ assertEquals(pushMethod.getStatusCode(), STATUS_CODE_OK);
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,116 +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.metamer.ftest.a4jPush;
-
-import static org.testng.Assert.*;
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.jboss.test.selenium.SeleniumGetter.*;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.jboss.test.selenium.SystemProperties;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.jboss.test.selenium.request.RequestType;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.BeforeClass;
-
-/**
- * Abstract test case for testing a4j:push component.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public abstract class AbstractPushTestCase extends AbstractMetamerTest {
-
- private static final int STATUS_CODE_OK = 200;
-
- protected PushAttributes pushAttributes = new PushAttributes();
-
- private ElementLocator outputCounter = pjq("span[id$=outputCounter]");
-
- private HttpClient httpClient;
- private HttpMethod pushMethod;
-
- @Override
- public URL getTestUrl() {
- URL contextPath = SystemProperties.getContextPath();
- return buildUrl(contextPath, "faces/components/a4jPush/simple.xhtml");
- }
-
- /**
- * Initializes the HttpClient which triggers events in {@link #generatePushEvent()}.
- */
- @BeforeClass
- public void initializeHttpClient() {
- httpClient = new HttpClient();
- URL eventProducerUrl = buildUrl(getTestUrl(), "event-producer.xhtml");
- pushMethod = new GetMethod(eventProducerUrl.toString());
- }
-
- /**
- * Returns the value of counter as pushed value
- *
- * @return the value of counter as pushed value
- */
- protected int getCounter() {
- return getText(outputCounter).asInteger();
- }
-
- /**
- * Push the event specified number times and then waits for observation of event by
client.
- *
- * @param numberOfPushes
- * the number of events should be generated
- */
- protected void pushAndWait(int numberOfPushes) throws HttpException, IOException {
- selenium.getPageExtensions().install();
- selenium.getRequestInterceptor().clearRequestTypeDone();
-
- for (int i = 0; i < numberOfPushes; i++) {
- generatePushEvent();
- }
-
- selenium.getRequestInterceptor().waitForRequestTypeChange();
- RequestType requestDone = selenium.getRequestInterceptor().getRequestTypeDone();
-
- assertEquals(requestDone, RequestType.XHR);
- }
-
- /**
- * <p>
- * Generates the push event for all registered listeners from a4j:push test Simple
page.
- * </p>
- *
- * <p>
- * Internally use HttpClient to ping URL triggering push event in preRenderView
phase.
- * </p>
- */
- private void generatePushEvent() throws HttpException, IOException {
- httpClient.executeMethod(pushMethod);
- assertEquals(pushMethod.getStatusCode(), STATUS_CODE_OK);
- }
-}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,165 +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.metamer.ftest.a4jPush;
-
-import static org.jboss.test.selenium.utils.PrimitiveUtils.asLong;
-import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-
-import org.apache.commons.httpclient.HttpException;
-import org.jboss.test.selenium.locator.Attribute;
-import org.jboss.test.selenium.locator.AttributeLocator;
-import org.testng.annotations.Test;
-
-/**
- * Tests the interval attribute for a4j:push
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class IntervalTestCase extends AbstractPushTestCase {
-
- private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
- private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
- private static final long MAX_DEVIATION = 100;
- private static final long MAX_AVERAGE_DEVIATION = 75;
- private static final int DEFAULT_COUNTER_STEP = 2;
- private static final int ITERATION_COUNT = 3;
- private static final int MULTIPLE_PUSH_COUNT = 5;
-
- AttributeLocator clientTime =
pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
-
- private long startTime;
- private int counter;
- private int counterStep;
-
- private long deviationTotal = 0;
- private long deviationCount = 0;
-
- /**
- * <p>
- * For 3 different intervals, test that the interval between push event triggered and
event observered by client
- * haven't greater deviation than the specified interval.
- * </p>
- *
- * <p>
- * First set the given interval into the interval attribute.
- * </p>
- *
- * <p>
- * Then push and wait for result of update triggered by observation of push event.
- * </p>
- *
- * <p>
- * Then repeat push and wait 6 times with 1 event triggered and 5 events triggered in
sequence.
- * </p>
- */
- @Test
- public void testIntervalFromClientPerspective() throws HttpException, IOException {
- for (int interval : INTERVAL_VALUES) {
- counterStep = DEFAULT_COUNTER_STEP;
- pushAttributes.setInterval(interval);
-
- pushAndWait(1);
- for (int i = 0; i < ITERATION_COUNT; i++) {
- startIntervalAndCounter();
- pushAndWait(1);
- validateIntervalAndCounter(interval);
-
- startIntervalAndCounter();
- pushAndWait(MULTIPLE_PUSH_COUNT);
- validateIntervalAndCounter(interval);
- }
- }
-
- validateAverageDeviation();
- }
-
- /**
- * Remembers start of the time frame and current value of counter.
- */
- private void startIntervalAndCounter() {
- startTime = getClientTime();
- counter = getCounter();
- }
-
- /**
- * <p>
- * Obtains current value of counter and end of the time frame to compute the run
time.
- * </p>
- *
- * <p>
- * Validates that run time haven't greater deviation from given maximum {@link
#MAX_DEVIATION}.
- * </p>
- *
- * <p>
- * Remembers the deviation as part of total deviation for computing average value.
- * </p>
- *
- * <p>
- * Validates that counter have been increased by right value.
- * </p>
- */
- private void validateIntervalAndCounter(int interval) {
- long runTime = getClientTime() - startTime;
- long deviation = Math.abs(interval - runTime);
- assertTrue(deviation <= MAX_DEVIATION, format("Deviation ({0}) is greater
than defined maximum {1}", deviation,
- MAX_DEVIATION));
-
- if (seleniumDebug) {
- System.out.println(format("deviation for interval {0}: {1}",
interval, deviation));
- }
-
- deviationTotal += deviation;
- deviationCount += 1;
-
- int newCounter = getCounter();
- assertEquals(newCounter, counter + counterStep);
- counter = newCounter;
-
- }
-
- /**
- * Validates the average deviations from intervals.
- */
- private void validateAverageDeviation() {
- long averageDeviation = deviationTotal / deviationCount;
- if (seleniumDebug) {
- System.out.println("averageDeviation: " + averageDeviation);
- }
- assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
- "Average deviation for all the intervals ({0}) should not be greater
than defined maximum {1}",
- averageDeviation, MAX_AVERAGE_DEVIATION));
- }
-
- /**
- * Returns the time of push event (the time when arrived the response from server)
- *
- * @return the time of push event (the time when arrived the response from server)
- */
- private long getClientTime() {
- return asLong(selenium.getAttribute(clientTime));
- }
-}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,65 +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.metamer.ftest.a4jPush;
-
-import static org.testng.Assert.assertNotSame;
-import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
-
-import java.io.IOException;
-
-import org.apache.commons.httpclient.HttpException;
-import org.testng.annotations.Test;
-
-/**
- * Test case for simple usage of a4j:push component.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class SimpleTestCase extends AbstractPushTestCase {
- private static final long SIMPLE_INTERVAL = 2500;
-
- /**
- * <p>
- * Sets the interval to value {@link #SIMPLE_INTERVAL}.
- * </p>
- *
- * <p>
- * Then try to generate push event, wait for client observation.
- * </p>
- *
- * <p>
- * Validates that counter is changed between iterations.
- * </p>
- */
- @Test
- public void testSimple() throws HttpException, IOException {
- pushAttributes.setInterval(SIMPLE_INTERVAL);
-
- int beginCounter = getCounter();
- pushAndWait(1);
- int endCounter = getCounter();
-
- assertNotSame(beginCounter < endCounter, format(
- "The counter before push is greater {0} or equal the end counter
{1}", beginCounter, endCounter));
- }
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestCounter.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/SimpleTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestCounter.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestCounter.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jPush;
+
+import static org.testng.Assert.assertNotSame;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpException;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for simple usage of a4j:push component.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestCounter extends AbstractPushTest {
+ private static final long SIMPLE_INTERVAL = 2500;
+
+ /**
+ * <p>
+ * Sets the interval to value {@link #SIMPLE_INTERVAL}.
+ * </p>
+ *
+ * <p>
+ * Then try to generate push event, wait for client observation.
+ * </p>
+ *
+ * <p>
+ * Validates that counter is changed between iterations.
+ * </p>
+ */
+ @Test
+ public void testSimple() throws HttpException, IOException {
+ pushAttributes.setInterval(SIMPLE_INTERVAL);
+
+ int beginCounter = getCounter();
+ pushAndWait(1);
+ int endCounter = getCounter();
+
+ assertNotSame(beginCounter < endCounter, format(
+ "The counter before push is greater {0} or equal the end counter
{1}", beginCounter, endCounter));
+ }
+}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/IntervalTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * 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.metamer.ftest.a4jPush;
+
+import static org.jboss.test.selenium.utils.PrimitiveUtils.asLong;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpException;
+import org.jboss.test.selenium.locator.Attribute;
+import org.jboss.test.selenium.locator.AttributeLocator;
+import org.testng.annotations.Test;
+
+/**
+ * Tests the interval attribute for a4j:push
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestInterval extends AbstractPushTest {
+
+ private static final Attribute ATTRIBUTE_TITLE = new Attribute("title");
+ private static final int[] INTERVAL_VALUES = new int[]{1000, 5000, 500};
+ private static final long MAX_DEVIATION = 100;
+ private static final long MAX_AVERAGE_DEVIATION = 75;
+ private static final int DEFAULT_COUNTER_STEP = 2;
+ private static final int ITERATION_COUNT = 3;
+ private static final int MULTIPLE_PUSH_COUNT = 5;
+
+ AttributeLocator clientTime =
pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
+
+ private long startTime;
+ private int counter;
+ private int counterStep;
+
+ private long deviationTotal = 0;
+ private long deviationCount = 0;
+
+ /**
+ * <p>
+ * For 3 different intervals, test that the interval between push event triggered and
event observered by client
+ * haven't greater deviation than the specified interval.
+ * </p>
+ *
+ * <p>
+ * First set the given interval into the interval attribute.
+ * </p>
+ *
+ * <p>
+ * Then push and wait for result of update triggered by observation of push event.
+ * </p>
+ *
+ * <p>
+ * Then repeat push and wait 6 times with 1 event triggered and 5 events triggered in
sequence.
+ * </p>
+ */
+ @Test
+ public void testIntervalFromClientPerspective() throws HttpException, IOException {
+ for (int interval : INTERVAL_VALUES) {
+ counterStep = DEFAULT_COUNTER_STEP;
+ pushAttributes.setInterval(interval);
+
+ pushAndWait(1);
+ for (int i = 0; i < ITERATION_COUNT; i++) {
+ startIntervalAndCounter();
+ pushAndWait(1);
+ validateIntervalAndCounter(interval);
+
+ startIntervalAndCounter();
+ pushAndWait(MULTIPLE_PUSH_COUNT);
+ validateIntervalAndCounter(interval);
+ }
+ }
+
+ validateAverageDeviation();
+ }
+
+ /**
+ * Remembers start of the time frame and current value of counter.
+ */
+ private void startIntervalAndCounter() {
+ startTime = getClientTime();
+ counter = getCounter();
+ }
+
+ /**
+ * <p>
+ * Obtains current value of counter and end of the time frame to compute the run
time.
+ * </p>
+ *
+ * <p>
+ * Validates that run time haven't greater deviation from given maximum {@link
#MAX_DEVIATION}.
+ * </p>
+ *
+ * <p>
+ * Remembers the deviation as part of total deviation for computing average value.
+ * </p>
+ *
+ * <p>
+ * Validates that counter have been increased by right value.
+ * </p>
+ */
+ private void validateIntervalAndCounter(int interval) {
+ long runTime = getClientTime() - startTime;
+ long deviation = Math.abs(interval - runTime);
+ assertTrue(deviation <= MAX_DEVIATION, format("Deviation ({0}) is greater
than defined maximum {1}", deviation,
+ MAX_DEVIATION));
+
+ if (seleniumDebug) {
+ System.out.println(format("deviation for interval {0}: {1}",
interval, deviation));
+ }
+
+ deviationTotal += deviation;
+ deviationCount += 1;
+
+ int newCounter = getCounter();
+ assertEquals(newCounter, counter + counterStep);
+ counter = newCounter;
+
+ }
+
+ /**
+ * Validates the average deviations from intervals.
+ */
+ private void validateAverageDeviation() {
+ long averageDeviation = deviationTotal / deviationCount;
+ if (seleniumDebug) {
+ System.out.println("averageDeviation: " + averageDeviation);
+ }
+ assertTrue(averageDeviation <= MAX_AVERAGE_DEVIATION, format(
+ "Average deviation for all the intervals ({0}) should not be greater
than defined maximum {1}",
+ averageDeviation, MAX_AVERAGE_DEVIATION));
+ }
+
+ /**
+ * Returns the time of push event (the time when arrived the response from server)
+ *
+ * @return the time of push event (the time when arrived the response from server)
+ */
+ private long getClientTime() {
+ return asLong(selenium.getAttribute(clientTime));
+ }
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,290 +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.metamer.ftest.hCommandButton;
-
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-
-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.metamer.ftest.AbstractMetamerTest;
-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 HCommandButtonTestCase extends AbstractMetamerTest {
-
- private JQueryLocator input = pjq("input[id$=input]");
- private JQueryLocator button = pjq("input[id$=commandButton]");
- private JQueryLocator output1 = pjq("span[id$=output1]");
- private JQueryLocator output2 = pjq("span[id$=output2]");
- private JQueryLocator output3 = pjq("span[id$=output3]");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/commandButton/simple.xhtml");
- }
-
- @Override
- @AfterMethod(alwaysRun = true)
- public void invalidateSession() {
- super.invalidateSession();
- }
-
- @Test(dataProvider = "templates", groups = "client-side-perf")
- 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 =
pjq("input[value=doubleStringAction]");
- JQueryLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
- JQueryLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
-
- 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 =
pjq("input[value=doubleStringActionListener]");
- JQueryLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
- JQueryLocator toUpperCaseActionListener =
pjq("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 = pjq("input[id$=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");
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnblur(String templates) {
- testFireEvent(Event.BLUR, button);
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnchange(String templates) {
- testFireEvent(Event.CHANGE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnclick(String templates) {
- testFireEvent(Event.CLICK, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOndblclick(String templates) {
- testFireEvent(Event.DBLCLICK, button);
- }
-
- // not implemented in Mojarra
- // @Test(dataProvider = "templates")
- public void testOnfocus(String templates) {
- testFireEvent(Event.FOCUS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeydown(String templates) {
- testFireEvent(Event.KEYDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeypress(String templates) {
- testFireEvent(Event.KEYPRESS, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnkeyup(String templates) {
- testFireEvent(Event.KEYUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousedown(String templates) {
- testFireEvent(Event.MOUSEDOWN, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmousemove(String templates) {
- testFireEvent(Event.MOUSEMOVE, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseout(String templates) {
- testFireEvent(Event.MOUSEOUT, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseover(String templates) {
- testFireEvent(Event.MOUSEOVER, button);
- }
-
- @Test(dataProvider = "templates")
- public void testOnmouseup(String templates) {
- testFireEvent(Event.MOUSEUP, button);
- }
-
- @Test(dataProvider = "templates")
- public void testStyleClass(String templates) {
-
- JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
- JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
- JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
-
- final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
-
- 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 = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
- final String value = "font-size: 20px;";
-
- selenium.type(styleInput, value);
- 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 = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
- final String value = "new label";
-
- selenium.type(valueInput, value);
- selenium.waitForPageToLoad(TIMEOUT);
-
- assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
- }
-
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/HCommandButtonTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.metamer.ftest.hCommandButton;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+
+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.metamer.ftest.AbstractMetamerTest;
+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 TestHCommandButton extends AbstractMetamerTest {
+
+ private JQueryLocator input = pjq("input[id$=input]");
+ private JQueryLocator button = pjq("input[id$=commandButton]");
+ private JQueryLocator output1 = pjq("span[id$=output1]");
+ private JQueryLocator output2 = pjq("span[id$=output2]");
+ private JQueryLocator output3 = pjq("span[id$=output3]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/commandButton/simple.xhtml");
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ 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 =
pjq("input[value=doubleStringAction]");
+ JQueryLocator first6CharsAction =
pjq("input[value=first6CharsAction]");
+ JQueryLocator toUpperCaseAction =
pjq("input[value=toUpperCaseAction]");
+
+ 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 =
pjq("input[value=doubleStringActionListener]");
+ JQueryLocator first6CharsActionListener =
pjq("input[value=first6CharsActionListener]");
+ JQueryLocator toUpperCaseActionListener =
pjq("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 = pjq("input[id$=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");
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnblur(String templates) {
+ testFireEvent(Event.BLUR, button);
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnchange(String templates) {
+ testFireEvent(Event.CHANGE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnclick(String templates) {
+ testFireEvent(Event.CLICK, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOndblclick(String templates) {
+ testFireEvent(Event.DBLCLICK, button);
+ }
+
+ // not implemented in Mojarra
+ // @Test(dataProvider = "templates")
+ public void testOnfocus(String templates) {
+ testFireEvent(Event.FOCUS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeydown(String templates) {
+ testFireEvent(Event.KEYDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeypress(String templates) {
+ testFireEvent(Event.KEYPRESS, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnkeyup(String templates) {
+ testFireEvent(Event.KEYUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousedown(String templates) {
+ testFireEvent(Event.MOUSEDOWN, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmousemove(String templates) {
+ testFireEvent(Event.MOUSEMOVE, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseout(String templates) {
+ testFireEvent(Event.MOUSEOUT, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseover(String templates) {
+ testFireEvent(Event.MOUSEOVER, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testOnmouseup(String templates) {
+ testFireEvent(Event.MOUSEUP, button);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testStyleClass(String templates) {
+
+ JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
+ JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
+ JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
+
+ final AttributeLocator classAttribute = button.getAttribute(new
Attribute("class"));
+
+ 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 = pjq("input[id$=styleInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("style"));
+ final String value = "font-size: 20px;";
+
+ selenium.type(styleInput, value);
+ 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 = pjq("input[id$=valueInput]");
+ final AttributeLocator attribute = button.getAttribute(new
Attribute("value"));
+ final String value = "new label";
+
+ selenium.type(valueInput, value);
+ selenium.waitForPageToLoad(TIMEOUT);
+
+ assertEquals(selenium.getAttribute(attribute), value, "Value of the button
did not change");
+ }
+
+}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java 2010-07-20
13:31:25 UTC (rev 18158)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -1,141 +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.metamer.ftest.richExtendedDataTable;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URL;
-
-import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.locator.ElementLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.testng.annotations.Test;
-
-/**
- * Test of DataScroller tied to Extended Data Table
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class ScrollerTestCase extends AbstractMetamerTest {
-
- private static final int TOTAL_ROW_COUNT = 50;
- private static final Integer[] ROW_COUNT_VALUES =
- new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1, 2
* TOTAL_ROW_COUNT};
- DataScroller dataScroller1 = new
DataScroller(pjq("span.rf-ds[id$=scroller1]"));
- DataScroller dataScroller2 = new
DataScroller(pjq("span.rf-ds[id$=scroller2]"));
- DataTable table = new DataTable(pjq("div.rf-edt[id$=richEDT]"));
- ElementLocator attributeRowsInput = id("form:attributes:rowsInput");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath,
"faces/components/richExtendedDataTable/scroller.xhtml");
- }
-
- /**
- * Tests row count for scroller in footer of the EDT.
- *
- * @see {@link #testRowCount(DataScroller)}
- */
- @Test(dataProvider = "templates", groups = "client-side-perf")
- public void testRowCountFooterScroller(String templates) {
- testRowCount(dataScroller2);
- }
-
- /**
- * Tests row count for scroller outside of the EDT.
- *
- * @see {@link #testRowCount(DataScroller)}
- */
- @Test(dataProvider = "templates")
- public void testRowCountOutsideTable(String templates) {
- testRowCount(dataScroller1);
- }
-
- /**
- * <p>
- * Test the data scroller functionality for different values of row count
- * </p>
- *
- * <p>
- * If desired, sets the value of 'rows' first for each iteration.
- * </p>
- *
- * <p>
- * Then goes to first page and verifies that there is valid number of rows.
- * </p>
- *
- * <p>
- * Verifies that on the first page is less than total number of rows if the scroller
has several pages.
- * </p>
- *
- * <p>
- * If the scroller has pages enabled, goes to last page and verifies that this is
valid number of pages visible in
- * scroller and the number of rows is valid.
- * </p>
- *
- * <p>
- */
- private void testRowCount(DataScroller dataScroller) {
- for (Integer rowsPerPage : ROW_COUNT_VALUES) {
- if (rowsPerPage != null) {
- selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
- selenium.waitForPageToLoad();
- }
-
- dataScroller.gotoFirstPage();
- int rowCountPreset = Integer.valueOf(selenium.getValue(attributeRowsInput));
- int rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, Math.min(TOTAL_ROW_COUNT, rowCountPreset));
-
- assertEquals(dataScroller.hasPages(), rowCountActual < TOTAL_ROW_COUNT);
- if (dataScroller.hasPages()) {
- dataScroller.gotoLastPage();
-
- int pagesExpected = pageCountActualExpected(rowCountActual);
- int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
-
- if (countOfVisiblePages < pagesExpected) {
- int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage,
pageCountActualExpected(rowCountActual));
- } else {
- assertEquals(countOfVisiblePages, pagesExpected);
- }
-
- int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
- rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, rowCountExpected);
- }
- }
- }
-
- private int pageCountActualExpected(int rowCountActual) {
- return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT /
rowCountActual)).intValue();
- }
-
- private int rowCountLastPageExpected(int rowCountPreset) {
- int result = TOTAL_ROW_COUNT % rowCountPreset;
- return (result == 0) ? rowCountPreset : result;
- }
-}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
(from rev 18158,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/ScrollerTestCase.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-20
13:33:16 UTC (rev 18159)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.testng.annotations.Test;
+
+/**
+ * Test of DataScroller tied to Extended Data Table
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestScroller extends AbstractMetamerTest {
+
+ private static final int TOTAL_ROW_COUNT = 50;
+ private static final Integer[] ROW_COUNT_VALUES =
+ new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1, 2
* TOTAL_ROW_COUNT};
+ DataScroller dataScroller1 = new
DataScroller(pjq("span.rf-ds[id$=scroller1]"));
+ DataScroller dataScroller2 = new
DataScroller(pjq("span.rf-ds[id$=scroller2]"));
+ DataTable table = new DataTable(pjq("div.rf-edt[id$=richEDT]"));
+ ElementLocator attributeRowsInput = id("form:attributes:rowsInput");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richExtendedDataTable/scroller.xhtml");
+ }
+
+ /**
+ * Tests row count for scroller in footer of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
+ @Test(dataProvider = "templates", groups = "client-side-perf")
+ public void testRowCountFooterScroller(String templates) {
+ testRowCount(dataScroller2);
+ }
+
+ /**
+ * Tests row count for scroller outside of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
+ @Test(dataProvider = "templates")
+ public void testRowCountOutsideTable(String templates) {
+ testRowCount(dataScroller1);
+ }
+
+ /**
+ * <p>
+ * Test the data scroller functionality for different values of row count
+ * </p>
+ *
+ * <p>
+ * If desired, sets the value of 'rows' first for each iteration.
+ * </p>
+ *
+ * <p>
+ * Then goes to first page and verifies that there is valid number of rows.
+ * </p>
+ *
+ * <p>
+ * Verifies that on the first page is less than total number of rows if the scroller
has several pages.
+ * </p>
+ *
+ * <p>
+ * If the scroller has pages enabled, goes to last page and verifies that this is
valid number of pages visible in
+ * scroller and the number of rows is valid.
+ * </p>
+ *
+ * <p>
+ */
+ private void testRowCount(DataScroller dataScroller) {
+ for (Integer rowsPerPage : ROW_COUNT_VALUES) {
+ if (rowsPerPage != null) {
+ selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
+ selenium.waitForPageToLoad();
+ }
+
+ dataScroller.gotoFirstPage();
+ int rowCountPreset = Integer.valueOf(selenium.getValue(attributeRowsInput));
+ int rowCountActual = table.getCountOfTableRows();
+ assertEquals(rowCountActual, Math.min(TOTAL_ROW_COUNT, rowCountPreset));
+
+ assertEquals(dataScroller.hasPages(), rowCountActual < TOTAL_ROW_COUNT);
+ if (dataScroller.hasPages()) {
+ dataScroller.gotoLastPage();
+
+ int pagesExpected = pageCountActualExpected(rowCountActual);
+ int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
+
+ if (countOfVisiblePages < pagesExpected) {
+ int lastVisiblePage = dataScroller.getLastVisiblePage();
+ assertEquals(lastVisiblePage,
pageCountActualExpected(rowCountActual));
+ } else {
+ assertEquals(countOfVisiblePages, pagesExpected);
+ }
+
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
+ rowCountActual = table.getCountOfTableRows();
+ assertEquals(rowCountActual, rowCountExpected);
+ }
+ }
+ }
+
+ private int pageCountActualExpected(int rowCountActual) {
+ return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT /
rowCountActual)).intValue();
+ }
+
+ private int rowCountLastPageExpected(int rowCountPreset) {
+ int result = TOTAL_ROW_COUNT % rowCountPreset;
+ return (result == 0) ? rowCountPreset : result;
+ }
+}