Author: lfryc(a)redhat.com
Date: 2010-07-10 17:10:25 -0400 (Sat, 10 Jul 2010)
New Revision: 17904
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java
Log:
refactored ScrollerTestCase for EDT; completed JavaDoc
Modified:
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java
===================================================================
---
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java 2010-07-10
21:09:59 UTC (rev 17903)
+++
root/tests/metamer/trunk/ftest/test-source/src/main/java/org/richfaces/tests/testapp/richExtendedDataTable/ScrollerTestCase.java 2010-07-10
21:10:25 UTC (rev 17904)
@@ -22,7 +22,6 @@
package org.richfaces.tests.testapp.richExtendedDataTable;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
import static org.jboss.test.selenium.locator.LocatorFactory.*;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
@@ -35,13 +34,17 @@
import org.testng.annotations.Test;
/**
- * Test case for page /faces/components/commandButton/simple.xhtml
+ * Test of DataScroller tied to Extended Data Table
*
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class ScrollerTestCase extends AbstractTestappTestCase {
+ private static final int TOTAL_ROW_COUNT = 50;
+ private static final Integer[] ROW_COUNT_VALUES =
+ new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1, 2 *
TOTAL_ROW_COUNT};
+
DataScroller dataScroller1 = new
DataScroller(pjq("span.rf-ds[id$=scroller1]"));
DataScroller dataScroller2 = new
DataScroller(pjq("span.rf-ds[id$=scroller2]"));
DataTable table = new DataTable(pjq("table.rf-dt[id$=richEDT]"));
@@ -52,24 +55,56 @@
return buildUrl(contextPath,
"faces/components/richExtendedDataTable/scroller.xhtml");
}
- final static int TOTAL_ROW_COUNT = 50;
-
+ /**
+ * Tests row count for scroller in footer of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
@Test(dataProvider = "templates", groups = "client-side-perf")
- public void testInternalDataScrollerRowCount(String templates) {
+ public void testRowCountFooterScroller(String templates) {
testRowCount(dataScroller2);
}
+ /**
+ * Tests row count for scroller outside of the EDT.
+ *
+ * @see {@link #testRowCount(DataScroller)}
+ */
@Test(dataProvider = "templates")
- public void testExternalDataScrollerRowCount(String templates) {
+ public void testRowCountOutsideTable(String templates) {
testRowCount(dataScroller1);
}
+ /**
+ * <p>
+ * Test the data scroller functionality for different values of row count
+ * </p>
+ *
+ * <p>
+ * If desired, sets the value of 'rows' first for each iteration.
+ * </p>
+ *
+ * <p>
+ * Then goes to first page and verifies that there is valid number of rows.
+ * </p>
+ *
+ * <p>
+ * Verifies that on the first page is less than total number of rows if the scroller
has several pages.
+ * </p>
+ *
+ * <p>
+ * If the scroller has pages enabled, goes to last page and verifies that this is
valid number of pages visible in
+ * scroller and the number of rows is valid.
+ * </p>
+ *
+ * <p>
+ */
private void testRowCount(DataScroller dataScroller) {
- for (Integer rowsPerPage : new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17,
TOTAL_ROW_COUNT + 1,
- 2 * TOTAL_ROW_COUNT}) {
+ for (Integer rowsPerPage : ROW_COUNT_VALUES) {
if (rowsPerPage != null) {
selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
- guardHttp(selenium).fireEvent(attributeRowsInput, Event.BLUR);
+ selenium.fireEvent(attributeRowsInput, Event.BLUR);
+ selenium.waitForPageToLoad();
}
dataScroller.gotoFirstPage();
@@ -81,27 +116,28 @@
if (dataScroller.hasPages()) {
dataScroller.gotoLastPage();
- int pagesExpected = pageCountActual(rowCountActual);
+ int pagesExpected = pageCountActualExpected(rowCountActual);
int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
if (countOfVisiblePages < pagesExpected) {
int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage, pageCountActual(rowCountActual));
+ assertEquals(lastVisiblePage,
pageCountActualExpected(rowCountActual));
} else {
assertEquals(countOfVisiblePages, pagesExpected);
}
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, rowCountLastPage(rowCountPreset));
+ assertEquals(rowCountActual, rowCountExpected);
}
}
}
- int pageCountActual(int rowCountActual) {
+ private int pageCountActualExpected(int rowCountActual) {
return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT /
rowCountActual)).intValue();
}
- int rowCountLastPage(int rowCountPreset) {
+ private int rowCountLastPageExpected(int rowCountPreset) {
int result = TOTAL_ROW_COUNT % rowCountPreset;
return (result == 0) ? rowCountPreset : result;
}
Show replies by date