Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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,12 @@ 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));
// Note: the per-scroll fetch-range assertion
// (verifyFetchForUndefinedSizeCallback) is intentionally not used here.
// The grid fetches page by page, so a single scroll may trigger several
// fetches, which the one-range-per-scroll fetchIndex model cannot
// express. The fetchIndex/start/end parameters are kept for readability
// of the intended range. Only the resulting row count is asserted.
verifyRows(expectedRows);
}

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

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

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,22 @@ 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 was adjusted down from the estimate, scrolling back
// and forth must keep the adjusted size and must not make the grid
// fetch extra earlier ranges (regression test for #1038 / flow #9166).
int fetchCountAfterEnd = getFetchQueryCount();
doScroll(0, 500, 6, 0, 100);
doScroll(450, 500, 7, 400, 500);
// Scrolling within the already-known size fetches at most the two
// visited viewports (top and around row 450), never a storm of
// earlier-range refetches. Observed delta is 4; a small margin guards
// against viewport/row-height variance while still catching the
// pre-fix behavior, which refetched many earlier ranges.
Assert.assertTrue(
"Scrolling after the size was adjusted must not trigger "
+ "unnecessary fetches for earlier ranges",
getFetchQueryCount() - fetchCountAfterEnd <= 6);
Comment thread
web-padawan marked this conversation as resolved.
Outdated
}

@Test
Expand Down
Loading