summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorThomas <thomas@vaadin.com>2013-11-05 15:21:06 +0200
committerVaadin Code Review <review@vaadin.com>2013-11-06 11:12:06 +0000
commitfefedeab68461ebc04fd45f91a35835fc9026a56 (patch)
treef4d3b8a2d60b7ed0f1c4e81499abba584cef3d94 /uitest
parente0e00befc848c242f986ba5cd993ae8610a7fa83 (diff)
downloadvaadin-framework-fefedeab68461ebc04fd45f91a35835fc9026a56.tar.gz
vaadin-framework-fefedeab68461ebc04fd45f91a35835fc9026a56.zip
Send window position data back to server after drag (#12885)
Change-Id: I9ca766b0e06390c7ab90f9cbd4996b83032789db
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java67
-rw-r--r--uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java50
2 files changed, 117 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java
new file mode 100644
index 0000000000..e0bc0d9471
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListener.java
@@ -0,0 +1,67 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Window;
+
+@SuppressWarnings("serial")
+public class WindowMoveListener extends AbstractTestUI {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ Window w = new Window("Caption");
+ w.setId("testwindow");
+ w.setHeight("100px");
+ w.setWidth("100px");
+ w.setPositionX(100);
+ w.setPositionY(100);
+ addWindow(w);
+
+ Button b = new Button();
+ b.setId("testbutton");
+ addComponent(b);
+ b.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ for (Window window : getWindows()) {
+ window.setPositionX(100);
+ window.setPositionY(100);
+ }
+ }
+ });
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Tests that windows send their updated position "
+ + "to server-side after being moved by user";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 12885;
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java
new file mode 100644
index 0000000000..3ea3b719c0
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java
@@ -0,0 +1,50 @@
+package com.vaadin.tests.components.window;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Point;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Action;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class WindowMoveListenerTest extends MultiBrowserTest {
+
+ @Test
+ public void testWindowRepositioning() throws Exception {
+ openTestURL();
+
+ WebElement window = getDriver().findElement(By.id("testwindow"));
+ WebElement button = getDriver().findElement(By.id("testbutton"));
+
+ // I'd loved to use the header, but that doesn't work. Footer works
+ // fine, though :)
+ WebElement windowHeader = getDriver().findElement(
+ By.className("v-window-footer"));
+
+ Point winPos = window.getLocation();
+
+ // move window
+ Action a = new Actions(driver).clickAndHold(windowHeader)
+ .moveByOffset(100, 100).release().build();
+ a.perform();
+
+ assertNotEquals("Window was not dragged correctly.", winPos.x,
+ window.getLocation().x);
+ assertNotEquals("Window was not dragged correctly.", winPos.y,
+ window.getLocation().y);
+
+ // re-set window
+ button.click();
+
+ assertEquals("Window was not re-positioned correctly.", winPos.x,
+ window.getLocation().x);
+ assertEquals("Window was not re-positioned correctly.", winPos.y,
+ window.getLocation().y);
+
+ }
+} \ No newline at end of file