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.

WindowMoveListenerTest.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.vaadin.tests.components.window;
  2. import static org.junit.Assert.assertNotEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.By;
  5. import org.openqa.selenium.Point;
  6. import org.openqa.selenium.WebElement;
  7. import org.openqa.selenium.interactions.Action;
  8. import org.openqa.selenium.interactions.Actions;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class WindowMoveListenerTest extends MultiBrowserTest {
  11. @Test
  12. public void testWindowRepositioning() throws Exception {
  13. openTestURL();
  14. final WebElement window = getDriver().findElement(By.id("testwindow"));
  15. WebElement button = getDriver().findElement(By.id("testbutton"));
  16. // I'd loved to use the header, but that doesn't work. Footer works
  17. // fine, though :)
  18. WebElement windowFooter = getDriver()
  19. .findElement(By.className("v-window-footer"));
  20. final Point winPos = window.getLocation();
  21. // move window
  22. Action a = new Actions(driver).clickAndHold(windowFooter)
  23. .moveByOffset(100, 100).release().build();
  24. a.perform();
  25. assertNotEquals("Window was not dragged correctly.", winPos.x,
  26. window.getLocation().x);
  27. assertNotEquals("Window was not dragged correctly.", winPos.y,
  28. window.getLocation().y);
  29. // re-set window
  30. button.click();
  31. waitUntilWindowHasReseted(window, winPos);
  32. }
  33. private void waitUntilWindowHasReseted(final WebElement window,
  34. final Point winPos) {
  35. waitUntil(input -> winPos.x == window.getLocation().x
  36. && winPos.y == window.getLocation().y, 5);
  37. }
  38. }