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.

ContainerSizeChangeTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.vaadin.tests.components.table;
  2. import static org.hamcrest.CoreMatchers.is;
  3. import static org.hamcrest.MatcherAssert.assertThat;
  4. import static org.junit.Assert.fail;
  5. import java.io.IOException;
  6. import org.junit.Test;
  7. import org.openqa.selenium.NoSuchElementException;
  8. import com.vaadin.testbench.By;
  9. import com.vaadin.testbench.elements.ButtonElement;
  10. import com.vaadin.testbench.elements.TableElement;
  11. import com.vaadin.tests.tb3.MultiBrowserTest;
  12. public class ContainerSizeChangeTest extends MultiBrowserTest {
  13. @Test
  14. public void tableShouldLoadCorrectItems()
  15. throws IOException, InterruptedException {
  16. openTestURL();
  17. ButtonElement decreaseSize = $(ButtonElement.class)
  18. .caption("Decrease size").first();
  19. decreaseSize.click(); // decreasing container size from 50 to 40
  20. decreaseSize.click(); // decreasing container size from 40 to 30
  21. TableElement table = $(TableElement.class).first();
  22. // TableElement scroll not working properly, so we need to do this.
  23. // http://dev.vaadin.com/ticket/13826
  24. testBenchElement(table.findElement(By.className("v-scrollable")))
  25. .scroll(1000);
  26. // waitforvaadin not worky currently for table scroll, so we need to use
  27. // thread sleep :(
  28. Thread.sleep(1500);
  29. assertThatRowExists(table, 29);
  30. assertRowDoesNotExist(table, 30);
  31. }
  32. private void assertThatRowExists(TableElement table, int rowIndex) {
  33. assertThat(table.getCell(rowIndex, 0).getText(),
  34. is(String.format("a %s", rowIndex)));
  35. }
  36. private void assertRowDoesNotExist(TableElement table, int rowIndex) {
  37. try {
  38. table.getCell(rowIndex, 0);
  39. fail(String.format("Row %s should not exists.", rowIndex));
  40. } catch (NoSuchElementException e) {
  41. }
  42. }
  43. }