use of org.xwiki.extension.test.po.PaginationFilterPane in project xwiki-platform by xwiki.
the class ExtensionIT method testPagination.
/**
* The extension search results pagination.
*/
@Test
public void testPagination() {
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoCoreExtensions();
SearchResultsPane searchResults = adminPage.getSearchResults();
assertNull(searchResults.getNoResultsMessage());
assertEquals(20, searchResults.getDisplayedResultsCount());
PaginationFilterPane pagination = searchResults.getPagination();
assertEquals((pagination.getResultsCount() + 20 - 1) / 20, pagination.getPageCount());
assertEquals("1 - 20", pagination.getCurrentRange());
assertEquals(1, pagination.getCurrentPageIndex());
assertFalse(pagination.hasPreviousPage());
assertTrue(pagination.hasNextPage());
assertTrue(pagination.getPageCount() > 5);
assertTrue(pagination.getResultsCount() > 100);
String firstExtensionName = searchResults.getExtension(0).getName();
pagination = pagination.gotoPage(4);
searchResults = new SearchResultsPane();
assertEquals(20, searchResults.getDisplayedResultsCount());
assertEquals("61 - 80", pagination.getCurrentRange());
assertEquals(4, pagination.getCurrentPageIndex());
assertTrue(pagination.hasNextPage());
String secondExtensionName = searchResults.getExtension(0).getName();
assertFalse(firstExtensionName.equals(secondExtensionName));
pagination = pagination.previousPage();
searchResults = new SearchResultsPane();
assertEquals(20, searchResults.getDisplayedResultsCount());
assertEquals("41 - 60", pagination.getCurrentRange());
assertEquals(3, pagination.getCurrentPageIndex());
String thirdExtensionName = searchResults.getExtension(0).getName();
assertFalse(firstExtensionName.equals(thirdExtensionName));
assertFalse(secondExtensionName.equals(thirdExtensionName));
pagination = pagination.nextPage();
searchResults = new SearchResultsPane();
assertEquals(20, searchResults.getDisplayedResultsCount());
assertEquals("61 - 80", pagination.getCurrentRange());
assertEquals(4, pagination.getCurrentPageIndex());
assertEquals(secondExtensionName, searchResults.getExtension(0).getName());
pagination = pagination.gotoPage(pagination.getPageCount());
searchResults = new SearchResultsPane();
assertEquals(((pagination.getResultsCount() - 1) % 20) + 1, searchResults.getDisplayedResultsCount());
assertEquals(pagination.getPageCount(), pagination.getCurrentPageIndex());
assertFalse(pagination.hasNextPage());
assertTrue(pagination.hasPreviousPage());
}
Aggregations