Author: dsvyatobatsko
Date: 2008-05-08 08:46:32 -0400 (Thu, 08 May 2008)
New Revision: 8493
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/inputNumberSpinner/
trunk/test-applications/seleniumTest/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InputNumberSpinnerTest.java
Log:
inputNumberSpinner component test
Added:
trunk/test-applications/seleniumTest/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/seleniumTest/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InputNumberSpinnerTest.java
===================================================================
---
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InputNumberSpinnerTest.java
(rev 0)
+++
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InputNumberSpinnerTest.java 2008-05-08
12:46:32 UTC (rev 8493)
@@ -0,0 +1,91 @@
+package org.richfaces;
+
+import org.ajax4jsf.test.base.SeleniumTestBase;
+import org.ajax4jsf.test.base.Templates;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Parameters;
+import org.testng.annotations.Test;
+
+
+public class InputNumberSpinnerTest extends SeleniumTestBase {
+
+ public InputNumberSpinnerTest() {
+ super("http", "localhost", "8080");
+ }
+
+ /**
+ * This method are invoking before selenium tests started
+ */
+ @BeforeTest
+ @Parameters( { "browser" })
+ public void startSelenium(String browser) {
+ super.startSelenium(browser);
+ }
+
+ /**
+ * This method are invoking after selenium tests completed
+ */
+ @AfterTest
+ public void stopSelenium() {
+ super.stopSelenium();
+ }
+
+ @Test
+ public void testInputNumberSpinnerComponent() throws Exception {
+ _testInputNumberSpinnerComponent(Templates.SIMPLE);
+ //it looks as if the spinner does not work inside rich:dataTable
+ //_testInputNumberSpinnerComponent(Templates.DATATABLE);
+ }
+
+ private void _testInputNumberSpinnerComponent(Templates template) {
+
renderPage("/faces/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml",
template);
+
+ writeStatus("check whether the spinner is invariant with respect to pair of
sequential opposite operations");
+
+ //start value = 20
+ String before = getSpinnerValue();
+ clickUp();
+ clickDown();
+ String after = getSpinnerValue();
+ Assert.assertEquals(before, after);
+ Assert.assertEquals(after, "20");
+
+ writeStatus("check upper bound and cycling");
+
+ clickUp(); //+10
+ clickUp(); //+10
+ clickUp(); //+10
+ clickUp(); //+10
+ clickUp(); //+10
+ Assert.assertEquals(getSpinnerValue(), "10");
+
+ writeStatus("check lower bound and cycling");
+
+ clickDown(); //-10
+ Assert.assertEquals(getSpinnerValue(), "0");
+ clickDown(); //-10
+ Assert.assertEquals(getSpinnerValue(), "50");
+ clickDown(); //-10
+ Assert.assertEquals(getSpinnerValue(), "40");
+ }
+
+ private void clickUp() {
+ String id = getParentId() + "_form:" + "spinnerButtons";
+ selenium.fireEvent("dom=selenium.browserbot.getCurrentWindow().$('"
+ id + "').down('tbody').down('tr',
0).down('td').down('input')", "mousedown");
+ selenium.fireEvent("dom=selenium.browserbot.getCurrentWindow().$('"
+ id + "').down('tbody').down('tr',
0).down('td').down('input')", "mouseup");
+ }
+
+ private void clickDown() {
+ String id = getParentId() + "_form:" + "spinnerButtons";
+ selenium.fireEvent("dom=selenium.browserbot.getCurrentWindow().$('"
+ id + "').down('tbody').down('tr',
1).down('td').down('input')", "mousedown");
+ selenium.fireEvent("dom=selenium.browserbot.getCurrentWindow().$('"
+ id + "').down('tbody').down('tr',
1).down('td').down('input')", "mouseup");
+ }
+
+ private String getSpinnerValue() {
+ String id = getParentId() + "_form:" + "spinnerEdit";
+ return runScript("$('" + id +
"').down('input').value");
+ }
+
+}
Property changes on:
trunk/test-applications/seleniumTest/src/test/java/org/richfaces/InputNumberSpinnerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native