]> source.dussan.org Git - vaadin-framework.git/commitdiff
Convert TableScrollsOnSelectionTest to TB4.
authorSauli Tähkäpää <sauli@vaadin.com>
Fri, 12 Sep 2014 13:10:48 +0000 (16:10 +0300)
committerSauli Tähkäpää <sauli@vaadin.com>
Fri, 19 Sep 2014 06:07:40 +0000 (06:07 +0000)
Change-Id: I27b8edbd0761771054dc4e1b0b6b2559957da0c6

uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java
uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.html [deleted file]
uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.java
uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelectionTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java

index 26c4d99c6892e09e80c16dac7e34294b2e98455b..ebf2c1dc4725baa05cf013e2c30f141956895594 100644 (file)
@@ -4,15 +4,11 @@ import com.vaadin.testbench.elements.ButtonElement;
 import com.vaadin.testbench.elements.TableElement;
 import com.vaadin.tests.tb3.MultiBrowserTest;
 import org.junit.Test;
-import org.openqa.selenium.By;
 import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.interactions.Actions;
 import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.support.ui.ExpectedCondition;
 
 import java.util.List;
-import java.util.NoSuchElementException;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -60,22 +56,7 @@ public class LongMultiselectTest extends MultiBrowserTest {
     }
 
     private void scrollToBottom() {
-        testBenchElement(getTable().findElement(By.className("v-scrollable"))).scroll(ROWCOUNT * 30);
-
-        waitUntilRowIsVisible(LASTSELECTEDROW);
-    }
-
-    private void waitUntilRowIsVisible(final int row) {
-        waitUntil(new ExpectedCondition<Object>() {
-            @Override
-            public Object apply(WebDriver input) {
-                try {
-                   return getTable().getCell(row, 0) != null;
-                } catch (NoSuchElementException e) {
-                    return false;
-                }
-            }
-        });
+        scrollTable(getTable(), ROWCOUNT, LASTSELECTEDROW);
     }
 
 }
\ No newline at end of file
diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.html b/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.html
deleted file mode 100644 (file)
index dff3dcb..0000000
+++ /dev/null
@@ -1,45 +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>New Test</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">New Test</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.components.table.TableScrollsOnSelection?restartApplication</td>
-       <td></td>
-</tr>
-<!--Scroll to the end of the page (show last items in Table)-->
-<tr>
-       <td>scroll</td>
-       <td>vaadin=runcomvaadintestscomponentstableTableScrollsOnSelection::</td>
-       <td>2000</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>300</td>
-       <td></td>
-</tr>
-<!--Select the last item (79)-->
-<tr>
-    <td>mouseClick</td>
-    <td>vaadin=runcomvaadintestscomponentstableTableScrollsOnSelection::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[79]/domChild[0]/domChild[0]</td>
-    <td>38,-892</td>
-</tr>
-<!--Ensure the page is not scrolled to the beginning-->
-<tr>
-       <td>screenCapture</td>
-       <td></td>
-       <td>scrolled-down-and-selected-79</td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
index f49fdfd3b998fcef3ddcefed705d8a72168dc39e..104cd0ab3b0850a4d4fade6cb4985cb00817342f 100644 (file)
@@ -2,14 +2,15 @@ package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Item;
 import com.vaadin.data.util.IndexedContainer;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.Table;
 
-public class TableScrollsOnSelection extends TestBase {
+public class TableScrollsOnSelection extends AbstractTestUI {
 
     @Override
-    protected void setup() {
-        getMainWindow().getContent().setSizeUndefined();
+    protected void setup(VaadinRequest request) {
+        getContent().setSizeUndefined();
 
         IndexedContainer cont = new IndexedContainer();
         cont.addContainerProperty("number", String.class, null);
@@ -25,7 +26,7 @@ public class TableScrollsOnSelection extends TestBase {
     }
 
     @Override
-    protected String getDescription() {
+    protected String getTestDescription() {
         return "The scroll position should not change when an item is selected in a Table that is higher than the view.";
     }
 
diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelectionTest.java b/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelectionTest.java
new file mode 100644 (file)
index 0000000..d914689
--- /dev/null
@@ -0,0 +1,23 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class TableScrollsOnSelectionTest extends MultiBrowserTest {
+
+    @Test
+    public void tableIsNotScrolledOnSelect() throws IOException {
+        openTestURL();
+
+        TableElement table = $(TableElement.class).first();
+
+        scrollTable(table, 80, 79);
+
+        table.getCell(79, 0).click();
+
+        compareScreen("scrolled-down");
+    }
+}
\ No newline at end of file
index 8e6370a6fdb51d5f9f13a5a27b1712b7227a0127..1d03a7df76e1f020c5c34c711385f641a0042566 100644 (file)
@@ -30,7 +30,9 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.NoSuchElementException;
 
+import com.vaadin.testbench.elements.TableElement;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
@@ -245,6 +247,25 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
                 .click();
     }
 
+    protected void waitUntilRowIsVisible(final TableElement table, final int row) {
+        waitUntil(new ExpectedCondition<Object>() {
+            @Override
+            public Object apply(WebDriver input) {
+                try {
+                   return table.getCell(row, 0) != null;
+                } catch (NoSuchElementException e) {
+                    return false;
+                }
+            }
+        });
+    }
+
+    protected void scrollTable(TableElement table, int rows, int rowToWait) {
+        testBenchElement(table.findElement(By.className("v-scrollable"))).scroll(rows * 30);
+
+        waitUntilRowIsVisible(table, rowToWait);
+    }
+
     @Retention(RetentionPolicy.RUNTIME)
     @Target(ElementType.TYPE)
     public @interface RunLocally {