Author: lfryc(a)redhat.com
Date: 2010-07-21 08:11:34 -0400 (Wed, 21 Jul 2010)
New Revision: 18166
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
Log:
DataScroller refactored to use referenced locator pattern
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-21
12:10:49 UTC (rev 18165)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-21
12:11:34 UTC (rev 18166)
@@ -25,90 +25,90 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class DataScroller {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- JQueryLocator scrollerRoot;
- JQueryLocator pageNumbers = jq(".rf-ds-dtl");
- JQueryLocator firstPageButton = jq(".rf-ds-l[id$=ds_f]");
- JQueryLocator lastPageButton = jq(".rf-ds-r:eq(1)");
- JQueryLocator lastVisiblePage = jq(".rf-ds-dtl:last");
- JQueryLocator currentPage = jq(".rf-ds-cur");
- public DataScroller(JQueryLocator scrollerRoot) {
- this.scrollerRoot = scrollerRoot;
- }
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- public JQueryLocator getRoot() {
- return scrollerRoot;
- }
-
- public void gotoFirstPage() {
- if (!isFirstPage()) {
- clickFirstPageButton();
- }
- }
+ LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
+ ReferencedLocator<JQueryLocator> pageNumbers = ref(root, ">
.rf-ds-dtl"),
+ firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]"),
+ lastPageButton = ref(root, "> .rf-ds-r:eq(1)"),
+ lastVisiblePage = ref(root, "> .rf-ds-dtl:last"),
+ currentPage = ref(root, "> .rf-ds-cur");
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
+ public DataScroller(JQueryLocator root) {
+ setRoot(root);
+ }
- public void clickLastPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastPageButton);
- guardXhr(selenium).click(locator);
- }
+ public JQueryLocator getRoot() {
+ return root.getLocator();
+ }
- public void clickFirstPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(firstPageButton);
- guardXhr(selenium).click(locator);
- }
+ public void setRoot(JQueryLocator root) {
+ this.root.setLocator(root);
+ }
- public int getCountOfVisiblePages() {
- JQueryLocator locator = scrollerRoot.getDescendant(pageNumbers);
- return selenium.getCount(locator);
- }
+ public void gotoFirstPage() {
+ if (!isFirstPage()) {
+ clickFirstPageButton();
+ }
+ }
- public boolean hasPages() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- return selenium.isElementPresent(locator);
- }
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
- public Integer getLastVisiblePage() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- if (!hasPages()) {
- return null;
- }
- return integer(selenium.getText(locator));
- }
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
- public int getCurrentPage() {
- JQueryLocator locator = scrollerRoot.getDescendant(currentPage);
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(locator));
- }
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
- public boolean isFirstPage() {
- return getCurrentPage() == 1;
- }
+ public int getCountOfVisiblePages() {
+ return selenium.getCount(pageNumbers);
+ }
- public boolean isLastPage() {
- return getCurrentPage() == getLastVisiblePage();
- }
+ public boolean hasPages() {
+ return selenium.isElementPresent(lastVisiblePage);
+ }
- public static int integer(String string) {
- return Integer.valueOf(string);
- }
+ public Integer getLastVisiblePage() {
+ if (!hasPages()) {
+ return null;
+ }
+ return integer(selenium.getText(lastVisiblePage));
+ }
+
+ public int getCurrentPage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(currentPage));
+ }
+
+ public boolean isFirstPage() {
+ return getCurrentPage() == 1;
+ }
+
+ public boolean isLastPage() {
+ return getCurrentPage() == getLastVisiblePage();
+ }
+
+ public static int integer(String string) {
+ return Integer.valueOf(string);
+ }
}
Show replies by date