diff options
4 files changed, 50 insertions, 50 deletions
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 index dff3dcbc48..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.html +++ /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> diff --git a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.java b/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.java index f49fdfd3b9..104cd0ab3b 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.java +++ b/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.java @@ -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 index 0000000000..d914689f63 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelectionTest.java @@ -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 diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 108d72b91e..2e61ae52b6 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -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; @@ -230,6 +232,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 { |