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.

ExpandingContainerVisibleRowRaceConditionTest.java 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.vaadin.tests.components.table;
  2. import static com.vaadin.tests.components.table.ExpandingContainerVisibleRowRaceCondition.TABLE;
  3. import static org.junit.Assert.assertEquals;
  4. import static org.junit.Assert.assertFalse;
  5. import static org.junit.Assert.fail;
  6. import java.util.List;
  7. import org.junit.Test;
  8. import org.openqa.selenium.By;
  9. import org.openqa.selenium.WebElement;
  10. import com.vaadin.tests.tb3.MultiBrowserTest;
  11. public class ExpandingContainerVisibleRowRaceConditionTest
  12. extends MultiBrowserTest {
  13. private static final int ROW_HEIGHT = 20;
  14. @Test
  15. public void testScrollingWorksWithoutJumpingWhenItemSetChangeOccurs() {
  16. openTestURL();
  17. sleep(1000);
  18. WebElement table = vaadinElementById(TABLE);
  19. assertFirstRowIdIs("ROW #120");
  20. testBenchElement(table.findElement(By.className("v-scrollable")))
  21. .scroll(320 * ROW_HEIGHT);
  22. sleep(1000);
  23. assertRowIdIsInThePage("ROW #330");
  24. assertScrollPositionIsNotVisible();
  25. }
  26. private void assertFirstRowIdIs(String expected) {
  27. List<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
  28. WebElement first = cellsOfFirstColumn.get(0);
  29. assertEquals(expected, first.getText());
  30. }
  31. private void assertRowIdIsInThePage(String expected) {
  32. List<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
  33. for (WebElement rowId : cellsOfFirstColumn) {
  34. if (expected.equals(rowId.getText())) {
  35. return;
  36. }
  37. }
  38. fail("Expected row was not found");
  39. }
  40. private void assertScrollPositionIsNotVisible() {
  41. WebElement table = vaadinElementById(TABLE);
  42. WebElement scrollPosition = table
  43. .findElement(By.className("v-table-scrollposition"));
  44. assertFalse(scrollPosition.isDisplayed());
  45. }
  46. private List<WebElement> getCellsOfFirstColumn() {
  47. WebElement table = vaadinElementById(TABLE);
  48. List<WebElement> firstCellOfRows = table
  49. .findElements(By.cssSelector(".v-table-table tr > td"));
  50. return firstCellOfRows;
  51. }
  52. }