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.9KB

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