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.

GridScrolledResizeTest.java 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.JavascriptExecutor;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.support.ui.ExpectedConditions;
  7. import com.vaadin.testbench.By;
  8. import com.vaadin.testbench.TestBenchElement;
  9. import com.vaadin.testbench.elements.ButtonElement;
  10. import com.vaadin.testbench.elements.GridElement;
  11. import com.vaadin.tests.tb3.MultiBrowserTest;
  12. public class GridScrolledResizeTest extends MultiBrowserTest {
  13. @Test
  14. public void scrollUpdatedAfterResize() {
  15. openTestURL();
  16. GridElement grid = $(GridElement.class).first();
  17. ButtonElement button = $(ButtonElement.class).first();
  18. WebElement scrollbar = grid
  19. .findElement(By.className("v-grid-scroller-horizontal"));
  20. TestBenchElement header = grid.getHeader();
  21. int initialHeaderRight = header.getLocation().getX()
  22. + header.getSize().getWidth();
  23. // resize to include scrollbar
  24. button.click();
  25. assertEquals("No visible scrollbar when one expected.", "block",
  26. scrollbar.getCssValue("display"));
  27. int scrolledHeaderRight = header.getLocation().getX()
  28. + header.getSize().getWidth();
  29. assertLessThan("Header should have moved with the resize.",
  30. scrolledHeaderRight, initialHeaderRight);
  31. // ensure the contents are scrolled
  32. ((JavascriptExecutor) driver)
  33. .executeScript("arguments[0].scrollLeft = 1000", scrollbar);
  34. // resize to not include scrollbar
  35. button.click();
  36. waitUntilNot(ExpectedConditions.visibilityOf(scrollbar));
  37. // ensure the contents move with the resize
  38. int newHeaderRight = header.getLocation().getX()
  39. + header.getSize().getWidth();
  40. assertEquals("Header should have expanded back.", initialHeaderRight,
  41. newHeaderRight);
  42. }
  43. }