Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ protected void open(int size) {
protected void doScroll(int rowToScroll, int expectedRows, int fetchIndex,
int start, int end) {
grid.scrollToRow(rowToScroll);
// FIXME when grid reduces size, it does currently some extra fetches
// -> not checking the requested items until this is fixed
// verifyFetchForUndefinedSizeCallback(fetchIndex,
// Range.between(start, end));
// A single scroll may fetch several pages, so only the resulting row
// count is asserted here. fetchIndex/start/end document the range.
verifyRows(expectedRows);
}

Expand Down Expand Up @@ -100,6 +98,20 @@ protected void verifyRows(int size) {
grid.getRowCount());
}

protected int getFetchQueryCount() {
return findElements(By.cssSelector("[id^='log-']")).size();
}

/**
* Returns the start offset of the fetch query logged at the given index.
* Log entries are formatted as {@code "<index>:Range [<start>..<end>]"}.
*/
protected int getFetchedOffset(int index) {
String text = findElement(By.id("log-" + index)).getText();
return Integer.parseInt(
text.substring(text.indexOf('[') + 1, text.indexOf("..")));
}

protected void verifyFetchForUndefinedSizeCallback(int index, Range range) {
WebElement log = findElement(By.id("log-" + index));
Assert.assertEquals("Invalid range for index " + index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ public void undefinedSizeGrid_defaultPageSizeEvenToDatasetSize_scrollingToEnd()
// scroll to actual end, no more items returned and size is adjusted
doScroll(500, 500, 5, 450, 500);
Assert.assertEquals(499, grid.getLastVisibleRowIndex());
// TODO #1038 test further after grid is note fetching extra stuff when
// size has been adjusted to less than what it is
// doScroll(0, 500, 6, 0, 100);
// doScroll(450, 500, 7, 400, 500);

// After the size is adjusted down, scrolling back and forth keeps the
// size and only fetches the visited viewports (near the top and near
// row 450) - never the ranges in between.
int fetchesBefore = getFetchQueryCount();
doScroll(0, 500, 6, 0, 100);
doScroll(450, 500, 7, 400, 500);
for (int i = fetchesBefore; i < getFetchQueryCount(); i++) {
int offset = getFetchedOffset(i);
Assert.assertTrue(
"Refetched an off-viewport range at offset " + offset
+ " after the size was adjusted",
offset < 150 || offset >= 350);
}
}

@Test
Expand Down
Loading