]> source.dussan.org Git - vaadin-framework.git/commitdiff
UIScrollTest test upgrade (#14292)
authorAnna Koskinen <anna@vaadin.com>
Mon, 4 Aug 2014 11:22:40 +0000 (14:22 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 19 Aug 2014 08:49:03 +0000 (08:49 +0000)
Change-Id: I5203b69d2f4ad67107ac347bff9b56b6d66c63bd

uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html [deleted file]
uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.java [deleted file]
uitest/src/com/vaadin/tests/components/uitest/UIScrolling.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/uitest/UIScrollingTest.java [new file with mode: 0644]

diff --git a/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html b/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.html
deleted file mode 100644 (file)
index acbe30c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head profile="http://selenium-ide.openqa.org/profiles/test-case">
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link rel="selenium.base" href="" />
-<title>UIScrollTest</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">UIScrollTest</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.components.uitest.UIScrollTest?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentsuitestUIScrollTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>screenCapture</td>
-       <td></td>
-       <td>Halfway_down_button</td>
-</tr>
-<tr>
-       <td>scroll</td>
-       <td>vaadin=runcomvaadintestscomponentsuitestUIScrollTest::</td>
-       <td>1020</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>300</td>
-       <td></td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentsuitestUIScrollTest::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>//div[@id='runcomvaadintestscomponentsuitestUIScrollTest-1797389287-overlays']//h1</td>
-       <td>Scrolled to 1020 px</td>
-</tr>
-<tr>
-       <td>closeNotification</td>
-       <td>//div[@id='runcomvaadintestscomponentsuitestUIScrollTest-1797389287-overlays']/div</td>
-       <td>0,0</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.java b/uitest/src/com/vaadin/tests/components/uitest/UIScrollTest.java
deleted file mode 100644 (file)
index 66b6ef9..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.vaadin.tests.components.uitest;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.UI;
-
-public class UIScrollTest extends TestBase {
-
-    @Override
-    protected void setup() {
-        // Set layout to high enough to get scroll.
-        getLayout().setHeight("2250px");
-        addComponent(new Button("scoll to 1000px", new Button.ClickListener() {
-
-            @Override
-            public void buttonClick(ClickEvent event) {
-                UI.getCurrent().setScrollTop(1000);
-            }
-        }));
-        addComponent(new Button(
-                "This button is halfway down. Click to report scroll position.",
-                new Button.ClickListener() {
-                    @Override
-                    public void buttonClick(ClickEvent event) {
-                        Notification.show("Scrolled to "
-                                + event.getButton().getUI().getScrollTop()
-                                + " px");
-                    }
-                }));
-    }
-
-    @Override
-    protected String getDescription() {
-        return "Windows can be programmatically scrolled";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 9952;
-    }
-
-}
diff --git a/uitest/src/com/vaadin/tests/components/uitest/UIScrolling.java b/uitest/src/com/vaadin/tests/components/uitest/UIScrolling.java
new file mode 100644 (file)
index 0000000..a6f9d6e
--- /dev/null
@@ -0,0 +1,45 @@
+package com.vaadin.tests.components.uitest;
+
+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.Notification;
+import com.vaadin.ui.UI;
+
+public class UIScrolling extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        // Set layout to high enough to get scroll.
+        getLayout().setHeight("2250px");
+        addComponent(new Button("scroll to 1000px", new Button.ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                UI.getCurrent().setScrollTop(1000);
+            }
+        }));
+        addComponent(new Button(
+                "This button is halfway down. Click to report scroll position.",
+                new Button.ClickListener() {
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        Notification.show("Scrolled to "
+                                + event.getButton().getUI().getScrollTop()
+                                + " px");
+                    }
+                }));
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Windows can be programmatically scrolled";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 9952;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/uitest/UIScrollingTest.java b/uitest/src/com/vaadin/tests/components/uitest/UIScrollingTest.java
new file mode 100644 (file)
index 0000000..46d79a2
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.uitest;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.StaleElementReferenceException;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Tests UI scrolling.
+ * 
+ * @author Vaadin Ltd
+ */
+public class UIScrollingTest extends MultiBrowserTest {
+
+    @Override
+    protected boolean usePersistentHoverForIE() {
+        return false;
+    }
+
+    @Test
+    public void testScrolling() throws IOException, InterruptedException {
+        openTestURL();
+
+        List<ButtonElement> buttons = $(ButtonElement.class).all();
+        buttons.get(0).click();
+        sleep(100);
+
+        buttons.get(1).click();
+
+        waitForElementPresent(By.className("v-Notification"));
+
+        NotificationElement notification = $(NotificationElement.class).first();
+        assertEquals("Scrolled to 1000 px",
+                notification.findElement(By.tagName("h1")).getText());
+
+        // attempt to close the notification
+        try {
+            notification.closeNotification();
+        } catch (StaleElementReferenceException e) {
+        }
+
+        WebElement ui = findElement(By.className("v-ui"));
+        testBenchElement(ui).scroll(1020);
+
+        buttons.get(1).click();
+
+        waitForElementPresent(By.className("v-Notification"));
+
+        notification = $(NotificationElement.class).first();
+        assertEquals("Scrolled to 1020 px",
+                notification.findElement(By.tagName("h1")).getText());
+
+        try {
+            notification.closeNotification();
+        } catch (StaleElementReferenceException e) {
+        }
+    }
+}