[richfaces-svn-commits] JBoss Rich Faces SVN: r18577 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: model and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Aug 11 17:21:10 EDT 2010
Author: lfryc at redhat.com
Date: 2010-08-11 17:21:10 -0400 (Wed, 11 Aug 2010)
New Revision: 18577
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/TestDataScroller.java
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/PaginationTester.java
Log:
added test case for testing DataScroller using ComponentControl
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 2010-08-11 21:20:08 UTC (rev 18576)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-08-11 21:21:10 UTC (rev 18577)
@@ -41,7 +41,7 @@
protected static final String CLASS_DISABLED = "rf-ds-dis";
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ protected AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
ReferencedLocator<JQueryLocator> numberedPages = ref(root, "> .rf-ds-dtl");
ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, "> .rf-ds-dtl:textEquals('{0}')");
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java 2010-08-11 21:21:10 UTC (rev 18577)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.richComponentControl;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+import static org.testng.Assert.*;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ComponentControlDataScroller extends AssertingDataScroller {
+
+ JQueryLocator button = jq(":submit[id$=button]");
+ JQueryLocator selectOperation = jq(":radio[name$=operationInput][value={0}]");
+
+ public ComponentControlDataScroller() {
+ super(jq("span.rf-ds[id$=scroller]"));
+ }
+
+ @Override
+ public void clickFirstPageButton() {
+ doOperation("first");
+ }
+
+ @Override
+ public void clickFastRewind() {
+ doOperation("previous");
+ }
+
+ @Override
+ public void clickFastForward() {
+ doOperation("next");
+ }
+
+ @Override
+ public void clickLastPageButton() {
+ doOperation("last");
+ }
+
+ private void doOperation(String operation) {
+ JQueryLocator locator = selectOperation.format(operation);
+ if (!"on".equals(selenium.getValue(locator))) {
+ selenium.check(locator);
+ guardHttp(selenium).fireEvent(locator, Event.CHANGE);
+ }
+ guardXhr(selenium).click(button);
+ }
+
+ @Override
+ public void clickPageButton(int pageNumber) {
+ int lastPage = getCurrentPage();
+ while (pageNumber < lastPage) {
+ clickFastRewind();
+ int page = getCurrentPage();
+ assertEquals(page, lastPage - 1);
+ lastPage = page;
+ }
+ while (pageNumber > lastPage) {
+ clickFastForward();
+ int page = getCurrentPage();
+ assertEquals(page, lastPage + 1);
+ lastPage = page;
+ }
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/TestDataScroller.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/TestDataScroller.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/TestDataScroller.java 2010-08-11 21:21:10 UTC (rev 18577)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.richComponentControl;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.richDataScroller.PaginationTester;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataScroller extends AbstractMetamerTest {
+
+ ComponentControlDataScroller dataScroller = new ComponentControlDataScroller();
+
+ PaginationTester paginationTester = new PaginationTester() {
+
+ @Override
+ protected void verifyBeforeScrolling() {
+
+ }
+
+ @Override
+ protected void verifyAfterScrolling() {
+
+ }
+ };
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richComponentControl/simple.xhtml");
+ }
+
+ @BeforeMethod
+ public void setup() {
+ paginationTester.setDataScroller(dataScroller);
+ int lastPage = dataScroller.obtainLastPage();
+ dataScroller.setLastPage(lastPage);
+ paginationTester.initializeTestedPages(lastPage);
+ }
+
+ @Test
+ public void testScrollerPagination() {
+ paginationTester.testNumberedPages();
+ }
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/PaginationTester.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/PaginationTester.java 2010-08-11 21:20:08 UTC (rev 18576)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/PaginationTester.java 2010-08-11 21:21:10 UTC (rev 18577)
@@ -22,7 +22,6 @@
package org.richfaces.tests.metamer.ftest.richDataScroller;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.model.DataScroller;
import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
@@ -37,7 +36,7 @@
public static final JQueryLocator DATA_SCROLLER_OUTSIDE_TABLE = pjq("span.rf-ds[id$=scroller1]");
public static final JQueryLocator DATA_SCROLLER_IN_TABLE_FOOTER = pjq("span.rf-ds[id$=scroller2]");
- protected AssertingDataScroller dataScroller = new AssertingDataScroller(null);
+ protected DataScroller dataScroller;
private int[] testPages;
public void initializeTestedPages(int lastPage) {
@@ -52,6 +51,10 @@
return dataScroller;
}
+ public void setDataScroller(DataScroller dataScroller) {
+ this.dataScroller = dataScroller;
+ }
+
public void testNumberedPages() {
Integer lastNumber = null;
for (int pageNumber : testPages) {
More information about the richfaces-svn-commits
mailing list