From: Sauli Tähkäpää Date: Fri, 12 Sep 2014 13:10:48 +0000 (+0300) Subject: Convert TableScrollsOnSelectionTest to TB4. X-Git-Tag: 7.4.0.beta1~217 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=588b52dfbe4823ac6d752bafece7e2aa0870960c;p=vaadin-framework.git Convert TableScrollsOnSelectionTest to TB4. Change-Id: I27b8edbd0761771054dc4e1b0b6b2559957da0c6 --- diff --git a/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java b/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java index 26c4d99c68..ebf2c1dc47 100644 --- a/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java +++ b/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java @@ -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() { - @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 index dff3dcbc48..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableScrollsOnSelection.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.TableScrollsOnSelection?restartApplication
scrollvaadin=runcomvaadintestscomponentstableTableScrollsOnSelection::2000
pause300
mouseClickvaadin=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]38,-892
screenCapturescrolled-down-and-selected-79
- - 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 8e6370a6fd..1d03a7df76 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; @@ -245,6 +247,25 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { .click(); } + protected void waitUntilRowIsVisible(final TableElement table, final int row) { + waitUntil(new ExpectedCondition() { + @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 {