Author: lfryc(a)redhat.com
Date: 2011-01-14 11:02:27 -0500 (Fri, 14 Jan 2011)
New Revision: 21033
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java
Log:
rich:collapsibleSubTable - automated Scroller sample (RFPL-731)
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-01-14
16:01:38 UTC (rev 21032)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/AbstractCollapsibleSubTableTest.java 2011-01-14
16:02:27 UTC (rev 21033)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.richCollapsibleSubTable;
import java.util.LinkedList;
@@ -3,4 +24,6 @@
import java.util.List;
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.ExpandMode;
import org.richfaces.tests.metamer.bean.Model;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -17,6 +40,10 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
public abstract class AbstractCollapsibleSubTableTest extends AbstractMetamerTest {
private static final List<Employee> EMPLOYEES = Model.unmarshallEmployees();
@@ -39,6 +66,10 @@
CollapsibleSubTable secondSubtable;
CollapsibleSubTableToggler secondToggler;
+ @Inject
+ @Use(empty = true)
+ ExpandMode expandMode;
+
@BeforeMethod
public void configure() {
if (configuration != null) {
@@ -77,4 +108,15 @@
return name;
}
}
+
+ protected RequestType getRequestTypeForExpandMode() {
+ switch (expandMode) {
+ case ajax:
+ return RequestType.XHR;
+ case server:
+ return RequestType.HTTP;
+ default:
+ return RequestType.NONE;
+ }
+ }
}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-01-14
16:01:38 UTC (rev 21032)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/CollapsibleSubTableAttributes.java 2011-01-14
16:02:27 UTC (rev 21033)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.richCollapsibleSubTable;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
@@ -11,6 +32,10 @@
import org.richfaces.model.SortMode;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
public class CollapsibleSubTableAttributes extends AbstractComponentAttributes {
JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
@@ -43,6 +68,10 @@
public void setRows(Integer rows) {
setProperty("rows", rows);
}
+
+ public Integer getRows() {
+ return Integer.valueOf(getProperty("rows"));
+ }
public void setSortMode(SortMode sortMode) {
setProperty("sortMode", sortMode);
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java 2011-01-14
16:01:38 UTC (rev 21032)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableFacets.java 2011-01-14
16:02:27 UTC (rev 21033)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.richCollapsibleSubTable;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
@@ -9,6 +30,10 @@
import org.testng.annotations.Test;
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
public class TestCollapsibleSubTableFacets extends AbstractCollapsibleSubTableTest {
private static final String SAMPLE_STRING = "Abc123!@#ĚščСам";
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java
(rev 0)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableScroller.java 2011-01-14
16:02:27 UTC (rev 21033)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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.richCollapsibleSubTable;
+
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.test.selenium.request.RequestType;
+import org.richfaces.ExpandMode;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.DataScroller;
+import org.richfaces.tests.metamer.ftest.richDataScroller.PaginationTester;
+import org.richfaces.tests.metamer.model.Employee;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestCollapsibleSubTableScroller extends AbstractCollapsibleSubTableTest {
+
+ DataScroller dataScroller;
+ DataScroller secondDataScroller;
+ PaginationTester paginationTester;
+
+ int rows = 5;
+
+ @Inject
+ @Use(booleans = { true, false })
+ boolean paralelScrolling;
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath,
"faces/components/richCollapsibleSubTable/scroller.xhtml");
+ }
+
+ @BeforeMethod
+ public void prepareComponent() {
+ if (paralelScrolling) {
+ paginationTester = new ParallelScrollingTester();
+ } else {
+ paginationTester = new BasicPaginationTester();
+ }
+
+ attributes.setExpandMode(expandMode);
+
+ dataScroller = new
DataScroller(subtable.getFooter().getChild(jq("span.rf-ds")));
+ secondDataScroller = new
DataScroller(secondSubtable.getFooter().getChild(jq("span.rf-ds")));
+
+ paginationTester.setDataScroller(dataScroller);
+
+ attributes.setRows(rows);
+
+ int lastPage = dataScroller.obtainLastPage();
+ dataScroller.setLastPage(lastPage);
+ paginationTester.initializeTestedPages(lastPage);
+
+ secondDataScroller.setLastPage(secondDataScroller.obtainLastPage());
+ }
+
+ @Test
+ @Use(field = "expandMode", enumeration = true)
+ public void testScrollerWithRowsAttribute() {
+ paginationTester.testNumberedPages();
+ }
+
+ public class BasicPaginationTester extends PaginationTester {
+
+ int secondScrollerPage;
+ String secondSubtableText;
+
+ @Override
+ protected void verifyBeforeScrolling() {
+ secondScrollerPage = secondDataScroller.getCurrentPage();
+ secondSubtableText = selenium.getText(secondSubtable);
+ }
+
+ @Override
+ protected void verifyAfterScrolling() {
+ if (expandMode != ExpandMode.none) {
+ final RequestType requestType = getRequestTypeForExpandMode();
+ guard(selenium, requestType).click(toggler);
+ guard(selenium, requestType).click(toggler);
+ }
+
+ assertEquals(secondDataScroller.getCurrentPage(), secondScrollerPage);
+ assertEquals(selenium.getText(secondSubtable), secondSubtableText);
+
+ int start = (dataScroller.getCurrentPage() - 1) * rows;
+ int end = Math.min(start + rows, employees.size());
+ int count = end - start;
+ List<Employee> visibleEmployees = employees.subList(start, end);
+
+ assertEquals(subtable.getRowCount(), count);
+
+ for (int i = 0; i < count; i++) {
+ String name = selenium.getText(subtable.getCell(1, i + 1));
+ String title = selenium.getText(subtable.getCell(2, i + 1));
+
+ assertEquals(name, visibleEmployees.get(i).getName());
+ assertEquals(title, visibleEmployees.get(i).getTitle());
+ }
+ }
+ }
+
+ public class ParallelScrollingTester extends BasicPaginationTester {
+
+ int notrandomizer = (Integer.MAX_VALUE - 17) * 13;
+
+ @Override
+ protected void verifyBeforeScrolling() {
+ notrandomizer *= 177;
+ int page = (Math.abs(notrandomizer) % secondDataScroller.getLastPage()) + 1;
+ secondDataScroller.gotoPage(page);
+ super.verifyBeforeScrolling();
+ }
+ }
+}
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java 2011-01-14
16:01:38 UTC (rev 21032)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richCollapsibleSubTable/TestCollapsibleSubTableSimple.java 2011-01-14
16:02:27 UTC (rev 21033)
@@ -1,3 +1,24 @@
+/*******************************************************************************
+ * 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.richCollapsibleSubTable;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guard;
@@ -13,12 +34,15 @@
import org.jboss.test.selenium.request.RequestType;
import org.richfaces.ExpandMode;
import org.richfaces.component.UICollapsibleSubTable;
-import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.model.Employee;
import org.testng.annotations.Test;
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
public class TestCollapsibleSubTableSimple extends AbstractCollapsibleSubTableTest {
@Override
@@ -26,10 +50,6 @@
return buildUrl(contextPath,
"faces/components/richCollapsibleSubTable/simple.xhtml");
}
- @Inject
- @Use(empty = true)
- ExpandMode expandMode;
-
@Test
@Use(field = "expandMode", enumeration = true)
@IssueTracking("https://issues.jboss.org/browse/RF-10181")
@@ -133,15 +153,4 @@
// TODO classes are currently not working
fail();
}
-
- private RequestType getRequestTypeForExpandMode() {
- switch (expandMode) {
- case ajax:
- return RequestType.XHR;
- case server:
- return RequestType.HTTP;
- default:
- return RequestType.NONE;
- }
- }
}