Author: jjamrich
Date: 2011-11-24 07:57:37 -0500 (Thu, 24 Nov 2011)
New Revision: 22996
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestDataScrollerAttributes.java
Log:
RFPL-870: add dataScroller tests for JS API
Buttons with JS API functions bound to dataScroller doesn't belongs to dataScroller
attributes, but they are placed on simple page with dataScroller. Beacause of this are
covered by TestCase for dataScroller attributes.
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2011-11-24
12:57:24 UTC (rev 22995)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2011-11-24
12:57:37 UTC (rev 22996)
@@ -24,6 +24,7 @@
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
@@ -58,6 +59,19 @@
ReferencedLocator<JQueryLocator> firstVisiblePage = ref(root, ">
.rf-ds-nmb-btn:first");
ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, ">
.rf-ds-nmb-btn:last");
ReferencedLocator<JQueryLocator> currentPage = ref(root, ">
.rf-ds-act");
+
+ // buttons with direct operation bound to rich:componentControll
+ JQueryLocator firstJsApiBtn = jq("input[id$=buttonStpFirst{0}]");
+ JQueryLocator previousJsApiBtn = jq("input[id$=buttonStpPrev{0}]");
+ JQueryLocator nextJsApiBtn = jq("input[id$=buttonStpNext{0}]");
+ JQueryLocator lastJsApiBtn = jq("input[id$=buttonStpLast{0}]");
+
+ // buttons with "switchToPage" action bound to rich:componentControll and
+ // operation specified by param
+ JQueryLocator firstStpJsApiBtn = jq("input[id$=buttonStpFirst{0}]");
+ JQueryLocator previousStpJsApiBtn = jq("input[id$=buttonStpPrev{0}]");
+ JQueryLocator nextStpJsApiBtn = jq("input[id$=buttonStpNext{0}]");
+ JQueryLocator lastStpJsApiBtn = jq("input[id$=buttonStpLast{0}]");
Integer fastStep = null;
Integer lastPage = null;
@@ -284,4 +298,38 @@
public void clickStepPrevious() {
guardXhr(selenium).click(previousButton);
}
+
+ // actions performed on buttons with JS API operation
+
+ public void clickJsApiFirst(int scrollerNo) {
+ guardXhr(selenium).click(firstJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiStpFirst(int scrollerNo) {
+ guardXhr(selenium).click(firstStpJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiPrevious(int scrollerNo) {
+ guardXhr(selenium).click(previousJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiStpPrevious(int scrollerNo) {
+ guardXhr(selenium).click(previousStpJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiNext(int scrollerNo) {
+ guardXhr(selenium).click(nextJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiStpNext(int scrollerNo) {
+ guardXhr(selenium).click(nextStpJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiLast(int scrollerNo) {
+ guardXhr(selenium).click(lastJsApiBtn.format(scrollerNo));
+ }
+
+ public void clickJsApiStpLast(int scrollerNo) {
+ guardXhr(selenium).click(lastStpJsApiBtn.format(scrollerNo));
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestDataScrollerAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestDataScrollerAttributes.java 2011-11-24
12:57:24 UTC (rev 22995)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestDataScrollerAttributes.java 2011-11-24
12:57:37 UTC (rev 22996)
@@ -270,7 +270,25 @@
assertEquals(getScroller().getCurrentPage(), 1, "After clicking on the step
previous button, the current page doesn't match.");
}
+ /**
+ * Test buttons with scroller JS API binding
+ */
@Test
+ public void testJsApi() {
+ verifyJsApi(1);
+ verifyJsApi(2);
+ }
+
+ /**
+ * Test buttons with scroller JS API binding, using switchToPage operation
+ */
+ @Test
+ public void testJsApiStp() {
+ verifyJsApiStp(1);
+ verifyJsApiStp(2);
+ }
+
+ @Test
public void testStyle() {
super.testStyle(getScroller());
}
@@ -301,4 +319,49 @@
return tableAttributes;
}
+ private void verifyJsApi(int scrollerNo) {
+ retrieveRequestTime.initializeValue();
+ getScroller().clickJsApiLast(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 6,
+ "After clicking on the step last button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiFirst(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 1,
+ "After clicking on the step first button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiNext(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 2,
+ "After clicking on the step next button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiNext(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 3,
+ "After clicking on the step next button (JS API), the current page
doesn't match.");
+ }
+
+ private void verifyJsApiStp(int scrollerNo) {
+ retrieveRequestTime.initializeValue();
+ getScroller().clickJsApiStpLast(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 6,
+ "After clicking on the step last button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiStpFirst(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 1,
+ "After clicking on the step first button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiStpNext(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 2,
+ "After clicking on the step next button (JS API), the current page
doesn't match.");
+
+ getScroller().clickJsApiStpNext(scrollerNo);
+ waitGui.waitForChange(retrieveRequestTime);
+ assertEquals(getScroller().getCurrentPage(), 3,
+ "After clicking on the step next button (JS API), the current page
doesn't match.");
+ }
}
Show replies by date