You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SetPageFirstItemLoadsNeededRowsOnlyTest.java 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.vaadin.tests.components.table;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import com.vaadin.testbench.elements.LabelElement;
  5. import com.vaadin.tests.tb3.MultiBrowserTest;
  6. public class SetPageFirstItemLoadsNeededRowsOnlyTest extends MultiBrowserTest {
  7. /*
  8. * expectedRowsRequested is related to VScrollTable's cache_rate and
  9. * pageLength. See for instance VScrollTable.ensureCacheFilled().
  10. *
  11. * This also takes into account if the visible rows are at the very start or
  12. * end of the table, if the user scrolled or the
  13. * Table.setCurrentPageFirstItemIndex(int) method was used.
  14. *
  15. * This value should not change if cache_rate and pageLength are not changed
  16. * as well, and if this test remains constant: the table is scrolled to the
  17. * very end (done in the actual UI: SetPageFirstItemLoadsNeededRowsOnly).
  18. */
  19. private int expectedRowsRequested = 45;
  20. @Test
  21. public void verifyLoadedRows() throws InterruptedException {
  22. openTestURL();
  23. // wait for events to be processed in UI after loading page
  24. sleep(2000);
  25. String labelValue = $(LabelElement.class).get(1).getText();
  26. String expectedLabelValue = "rows requested: " + expectedRowsRequested;
  27. String errorMessage = "Too many rows were requested";
  28. assertEquals(errorMessage, expectedLabelValue, labelValue);
  29. }
  30. }