Author: lfryc(a)redhat.com
Date: 2010-07-23 10:17:53 -0400 (Fri, 23 Jul 2010)
New Revision: 18218
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
Log:
extended richDataScroller/TestPagination for another fastStep/maxPages values
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-23
14:17:03 UTC (rev 18217)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-23
14:17:53 UTC (rev 18218)
@@ -328,7 +328,6 @@
List<Object> result = new LinkedList<Object>();
for (int i = 0; i < use.value().length; i++) {
boolean satisfied = false;
- System.out.println(this.getClass().getName());
for (Field field : this.getClass().getDeclaredFields()) {
String name = use.value()[i];
name = StringUtils.replace(name, "*", ".+");
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23
14:17:03 UTC (rev 18217)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23
14:17:53 UTC (rev 18218)
@@ -24,7 +24,7 @@
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.*;
import java.net.URL;
@@ -47,9 +47,6 @@
*/
public class TestPagination extends AbstractMetamerTest {
-
-
- private static final int FAST_STEP = 2;
private static final int[] PAGES = new int[] { 3, 6, 1, 4, 6, 2, 4, 5 };
@Inject
@@ -64,11 +61,11 @@
DataTable dataTable = new
DataTable(pjq("table.rf-dt[id$=richDataTable]"));
@Inject
- @Use(ints = { 2 })
+ @Use(ints = { 2, 3 })
int fastStep;
@Inject
- @Use(ints = { 3 })
+ @Use(ints = { 3, 4 })
int maxPages;
public TestPagination() {
@@ -85,18 +82,23 @@
public URL getTestUrl() {
return buildUrl(contextPath,
"faces/components/richDataScroller/simple.xhtml");
}
-
+ @BeforeMethod
+ public void prepareAttributes() {
+ guardHttp(selenium).type(attributeFastStep, String.valueOf(fastStep));
+ guardHttp(selenium).type(attributeMaxPages, String.valueOf(maxPages));
+ }
@Test
- public void testNumberedPages() {
- dataScroller.setFastStep(FAST_STEP);
+ public void testNumberedPagesWithMaxPagesAndFastStep() {
+ dataScroller.setFastStep(fastStep);
dataScroller.setLastPage(dataScroller.getLastPage());
for (int pageNumber : PAGES) {
String tableText = dataTable.getTableText();
dataScroller.gotoPage(pageNumber);
assertFalse(tableText.equals(dataTable.getTableText()));
+ assertEquals(maxPages, dataScroller.getCountOfVisiblePages());
}
}
@@ -105,10 +107,4 @@
public void invalidateSession() {
super.invalidateSession();
}
-
- @BeforeMethod
- public void prepareAttributes() {
- guardHttp(selenium).type(attributeFastStep, "2");
- guardHttp(selenium).type(attributeMaxPages, "3");
- }
}
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-23
14:17:03 UTC (rev 18217)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-23
14:17:53 UTC (rev 18218)
@@ -33,23 +33,10 @@
*/
public class AssertingDataScroller extends DataScroller {
- private static final String CLASS_DISABLED = "rf-ds-dis";
-
- private Integer fastStep = null;
- private Integer lastPage = null;
-
public AssertingDataScroller(JQueryLocator root) {
super(root);
}
- public void setFastStep(int fastStep) {
- this.fastStep = fastStep;
- }
-
- public void setLastPage(int pageNumber) {
- this.lastPage = pageNumber;
- }
-
@Override
public void gotoPage(int pageNumber) {
int startCount = this.getCountOfVisiblePages();
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-23
14:17:03 UTC (rev 18217)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-23
14:17:53 UTC (rev 18218)
@@ -39,6 +39,8 @@
*/
public class DataScroller {
+ protected static final String CLASS_DISABLED = "rf-ds-dis";
+
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
@@ -54,11 +56,14 @@
ReferencedLocator<JQueryLocator> firstVisiblePage = ref(root, ">
.rf-ds-dtl:first");
ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, ">
.rf-ds-dtl:last");
ReferencedLocator<JQueryLocator> currentPage = ref(root, ">
.rf-ds-cur");
+
+ Integer fastStep = null;
+ Integer lastPage = null;
public DataScroller(JQueryLocator root) {
setRoot(root);
}
-
+
public JQueryLocator getRoot() {
return root.getLocator();
}
@@ -66,6 +71,14 @@
public void setRoot(JQueryLocator root) {
this.root.setLocator(root);
}
+
+ public void setFastStep(int fastStep) {
+ this.fastStep = fastStep;
+ }
+
+ public void setLastPage(int pageNumber) {
+ this.lastPage = pageNumber;
+ }
public void gotoFirstPage() {
if (!isFirstPage()) {
@@ -80,27 +93,47 @@
}
public void gotoPage(int pageNumber) {
- while (pageNumber > getLastVisiblePage()) {
+ while (pageNumber > getLastVisiblePage()) {
fastForward();
}
+
while (pageNumber < getFirstVisiblePage()) {
fastRewind();
}
+
clickPageButton(pageNumber);
}
public void fastForward() {
- if (selenium.belongsClass(fastForwardButton, "rf-ds-dis")) {
- throw new AssertionError("fast forward button disabled");
+ if (selenium.belongsClass(fastForwardButton, CLASS_DISABLED)) {
+ if (fastStep != null && lastPage != null) {
+ if (getCurrentPage() + fastStep > lastPage) {
+ gotoPage(getLastVisiblePage());
+ } else {
+ throw new AssertionError("fast forward button disabled");
+ }
+ } else {
+ gotoPage(getLastVisiblePage());
+ }
+ } else {
+ clickFastForward();
}
- clickFastForward();
}
public void fastRewind() {
- if (selenium.belongsClass(fastRewindButton, "rf-ds-dis")) {
- throw new AssertionError("fast rewind button disabled");
+ if (selenium.belongsClass(fastRewindButton, CLASS_DISABLED)) {
+ if (fastStep != null) {
+ if (getCurrentPage() - fastStep <= 0) {
+ gotoPage(getFirstVisiblePage());
+ } else {
+ throw new AssertionError("fast forward button disabled");
+ }
+ } else {
+ gotoPage(getFirstVisiblePage());
+ }
+ } else {
+ clickFastRewind();
}
- clickFastRewind();
}
public int getCountOfVisiblePages() {