Author: lfryc(a)redhat.com
Date: 2010-07-28 09:40:23 -0400 (Wed, 28 Jul 2010)
New Revision: 18256
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
Removed:
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
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
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/richExtendedDataTable/TestScroller.java
Log:
moved DataTable, DataScroller and AssertingDataScroller to separata package ftest.model
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java
(from rev 18255,
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/model/AssertingDataScroller.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/AssertingDataScroller.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.model;
+
+import static junit.framework.Assert.*;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+/**
+ * Provides DataScroller control methods with assertions about scroller state.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class AssertingDataScroller extends DataScroller {
+
+ public AssertingDataScroller(JQueryLocator root) {
+ super(root);
+ }
+
+ @Override
+ public void gotoPage(int pageNumber) {
+ int startCount = this.getCountOfVisiblePages();
+ super.gotoPage(pageNumber);
+
+ int currentPage = this.getCurrentPage();
+ assertEquals(this.getCountOfVisiblePages(), startCount);
+ assertEquals(currentPage, pageNumber);
+
+ assertEquals(isFirstPageButtonDisabled(), this.isFirstPage());
+ assertEquals(isLastPageButtonDisabled(), this.isLastPage());
+
+ if (fastStep != null) {
+ assertEquals(isFastRewindDisabled(), currentPage - fastStep < 1);
+ if (lastPage != null) {
+ assertEquals(isFastForwardDisabled(), currentPage + fastStep >
lastPage);
+ }
+ }
+ }
+
+ @Override
+ public void gotoFirstPage() {
+ super.gotoFirstPage();
+ assertTrue(isFastRewindDisabled());
+ assertTrue(isFirstPageButtonDisabled());
+ }
+
+ @Override
+ public void gotoLastPage() {
+ super.gotoLastPage();
+ assertTrue(isFastForwardDisabled());
+ assertTrue(isLastPageButtonDisabled());
+ }
+
+ public boolean isFastForwardDisabled() {
+ return selenium.belongsClass(fastForwardButton, CLASS_DISABLED);
+ }
+
+ public boolean isFastRewindDisabled() {
+ return selenium.belongsClass(fastRewindButton, CLASS_DISABLED);
+ }
+
+ public boolean isLastPageButtonDisabled() {
+ return selenium.belongsClass(lastPageButton, CLASS_DISABLED);
+ }
+
+ public boolean isFirstPageButtonDisabled() {
+ return selenium.belongsClass(firstPageButton, CLASS_DISABLED);
+ }
+}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
(from rev 18255,
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/model/DataScroller.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.model;
+
+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.guard.request.RequestTypeGuardFactory.*;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
+
+/**
+ * Provides DataScroller control methods.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataScroller {
+
+ protected static final String CLASS_DISABLED = "rf-ds-dis";
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
+
+ ReferencedLocator<JQueryLocator> numberedPages = ref(root, ">
.rf-ds-dtl");
+ ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, ">
.rf-ds-dtl:textEquals('{0}')");
+
+ ReferencedLocator<JQueryLocator> firstPageButton = ref(root, ">
.rf-ds-l[id$=ds_f]");
+ ReferencedLocator<JQueryLocator> fastRewindButton = ref(root, ">
.rf-ds-l[id$=ds_fr]");
+ ReferencedLocator<JQueryLocator> fastForwardButton = ref(root, ">
.rf-ds-r[id$=ds_ff]");
+ ReferencedLocator<JQueryLocator> lastPageButton = ref(root, ">
.rf-ds-r[id$=ds_l]");
+
+ 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();
+ }
+
+ 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()) {
+ clickFirstPageButton();
+ }
+ }
+
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
+
+ public void gotoPage(int pageNumber) {
+ while (pageNumber > getLastVisiblePage()) {
+ fastForward();
+ }
+
+ while (pageNumber < getFirstVisiblePage()) {
+ fastRewind();
+ }
+
+ clickPageButton(pageNumber);
+ }
+
+ public void fastForward() {
+ 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();
+ }
+ }
+
+ public void fastRewind() {
+ 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();
+ }
+ }
+
+ public int getCountOfVisiblePages() {
+ return selenium.getCount(numberedPages);
+ }
+
+ public boolean hasPages() {
+ return selenium.isElementPresent(lastVisiblePage);
+ }
+
+ public int getFirstVisiblePage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(firstVisiblePage));
+ }
+
+ public int getLastVisiblePage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(lastVisiblePage));
+ }
+
+ public int getLastPage() {
+ int startPage = getCurrentPage();
+ clickLastPageButton();
+ int lastPage = getCurrentPage();
+ if (startPage == 1) {
+ clickFirstPageButton();
+ } else {
+ gotoPage(startPage);
+ }
+ return lastPage;
+ }
+
+ 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);
+ }
+
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
+
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
+
+ public void clickPageButton(int pageNumber) {
+ guardXhr(selenium).click(specificNumberedPage.format(pageNumber));
+ }
+
+ public void clickFastForward() {
+ guardXhr(selenium).click(fastForwardButton);
+ }
+
+ public void clickFastRewind() {
+ guardXhr(selenium).click(fastRewindButton);
+ }
+
+
+}
Copied:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
(from rev 18255,
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java)
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.model;
+
+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.reference.ReferencedLocator.*;
+
+/**
+ * Provides methods to control DataTable
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTable {
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
+
+ ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b
table table tr");
+
+ public DataTable(JQueryLocator tableRoot) {
+ root.setLocator(tableRoot);
+ }
+
+ public int getCountOfTableRows() {
+ return selenium.getCount(tableRows);
+ }
+
+ public String getTableText() {
+ return selenium.getText(root.getLocator());
+ }
+}
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-28
13:39:25 UTC (rev 18255)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -33,8 +33,8 @@
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Named;
import org.richfaces.tests.metamer.ftest.annotations.Use;
-import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
-import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Deleted:
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-28
13:39:25 UTC (rev 18255)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -1,89 +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 junit.framework.Assert.*;
-
-import org.jboss.test.selenium.locator.JQueryLocator;
-
-/**
- * Provides DataScroller control methods with assertions about scroller state.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class AssertingDataScroller extends DataScroller {
-
- public AssertingDataScroller(JQueryLocator root) {
- super(root);
- }
-
- @Override
- public void gotoPage(int pageNumber) {
- int startCount = this.getCountOfVisiblePages();
- super.gotoPage(pageNumber);
-
- int currentPage = this.getCurrentPage();
- assertEquals(this.getCountOfVisiblePages(), startCount);
- assertEquals(currentPage, pageNumber);
-
- assertEquals(isFirstPageButtonDisabled(), this.isFirstPage());
- assertEquals(isLastPageButtonDisabled(), this.isLastPage());
-
- if (fastStep != null) {
- assertEquals(isFastRewindDisabled(), currentPage - fastStep < 1);
- if (lastPage != null) {
- assertEquals(isFastForwardDisabled(), currentPage + fastStep >
lastPage);
- }
- }
- }
-
- @Override
- public void gotoFirstPage() {
- super.gotoFirstPage();
- assertTrue(isFastRewindDisabled());
- assertTrue(isFirstPageButtonDisabled());
- }
-
- @Override
- public void gotoLastPage() {
- super.gotoLastPage();
- assertTrue(isFastForwardDisabled());
- assertTrue(isLastPageButtonDisabled());
- }
-
- public boolean isFastForwardDisabled() {
- return selenium.belongsClass(fastForwardButton, CLASS_DISABLED);
- }
-
- public boolean isFastRewindDisabled() {
- return selenium.belongsClass(fastRewindButton, CLASS_DISABLED);
- }
-
- public boolean isLastPageButtonDisabled() {
- return selenium.belongsClass(lastPageButton, CLASS_DISABLED);
- }
-
- public boolean isFirstPageButtonDisabled() {
- return selenium.belongsClass(firstPageButton, CLASS_DISABLED);
- }
-}
Deleted:
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-28
13:39:25 UTC (rev 18255)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -1,213 +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 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.guard.request.RequestTypeGuardFactory.*;
-import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
-
-/**
- * Provides DataScroller control methods.
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataScroller {
-
- protected static final String CLASS_DISABLED = "rf-ds-dis";
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
-
- ReferencedLocator<JQueryLocator> numberedPages = ref(root, ">
.rf-ds-dtl");
- ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, ">
.rf-ds-dtl:textEquals('{0}')");
-
- ReferencedLocator<JQueryLocator> firstPageButton = ref(root, ">
.rf-ds-l[id$=ds_f]");
- ReferencedLocator<JQueryLocator> fastRewindButton = ref(root, ">
.rf-ds-l[id$=ds_fr]");
- ReferencedLocator<JQueryLocator> fastForwardButton = ref(root, ">
.rf-ds-r[id$=ds_ff]");
- ReferencedLocator<JQueryLocator> lastPageButton = ref(root, ">
.rf-ds-r[id$=ds_l]");
-
- 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();
- }
-
- 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()) {
- clickFirstPageButton();
- }
- }
-
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
-
- public void gotoPage(int pageNumber) {
- while (pageNumber > getLastVisiblePage()) {
- fastForward();
- }
-
- while (pageNumber < getFirstVisiblePage()) {
- fastRewind();
- }
-
- clickPageButton(pageNumber);
- }
-
- public void fastForward() {
- 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();
- }
- }
-
- public void fastRewind() {
- 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();
- }
- }
-
- public int getCountOfVisiblePages() {
- return selenium.getCount(numberedPages);
- }
-
- public boolean hasPages() {
- return selenium.isElementPresent(lastVisiblePage);
- }
-
- public int getFirstVisiblePage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(firstVisiblePage));
- }
-
- public int getLastVisiblePage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(lastVisiblePage));
- }
-
- public int getLastPage() {
- int startPage = getCurrentPage();
- clickLastPageButton();
- int lastPage = getCurrentPage();
- if (startPage == 1) {
- clickFirstPageButton();
- } else {
- gotoPage(startPage);
- }
- return lastPage;
- }
-
- 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);
- }
-
- public void clickLastPageButton() {
- guardXhr(selenium).click(lastPageButton);
- }
-
- public void clickFirstPageButton() {
- guardXhr(selenium).click(firstPageButton);
- }
-
- public void clickPageButton(int pageNumber) {
- guardXhr(selenium).click(specificNumberedPage.format(pageNumber));
- }
-
- public void clickFastForward() {
- guardXhr(selenium).click(fastForwardButton);
- }
-
- public void clickFastRewind() {
- guardXhr(selenium).click(fastRewindButton);
- }
-
-
-}
Deleted:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-28
13:39:25 UTC (rev 18255)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -1,57 +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 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.reference.ReferencedLocator.*;
-
-/**
- * Provides methods to control DataTable
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class DataTable {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- LocatorReference<JQueryLocator> root = new
LocatorReference<JQueryLocator>(null);
-
- ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b
table table tr");
-
- public DataTable(JQueryLocator tableRoot) {
- root.setLocator(tableRoot);
- }
-
- public int getCountOfTableRows() {
- return selenium.getCount(tableRows);
- }
-
- public String getTableText() {
- return selenium.getText(root.getLocator());
- }
-}
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28
13:39:25 UTC (rev 18255)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-28
13:40:23 UTC (rev 18256)
@@ -29,6 +29,9 @@
import org.jboss.test.selenium.locator.IdLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataScroller;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
import org.testng.annotations.Test;
/**