]> source.dussan.org Git - vaadin-framework.git/commitdiff
Converted LongMultiselectTest to TB4.
authorSauli Tähkäpää <sauli@vaadin.com>
Fri, 12 Sep 2014 10:25:38 +0000 (13:25 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 19 Sep 2014 05:36:04 +0000 (05:36 +0000)
Change-Id: I0336929861ef0e162fab5f7ff4fee8dfe0b343b4

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

diff --git a/uitest/src/com/vaadin/tests/components/table/LongMultiselect.html b/uitest/src/com/vaadin/tests/components/table/LongMultiselect.html
deleted file mode 100644 (file)
index 82778d5..0000000
+++ /dev/null
@@ -1,72 +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="http://localhost:8888/" />
-<title>LongMultiselect</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">LongMultiselect</td></tr>
-</thead><tbody>
-<tr>
-       <td>open</td>
-       <td>/run/com.vaadin.tests.components.table.LongMultiselect?restartApplication</td>
-       <td></td>
-</tr>
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[4]/domChild[1]</td>
-       <td>38,13</td>
-</tr>
-<tr>
-       <td>scroll</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
-       <td>18330</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>300</td>
-       <td></td>
-</tr>
-<tr>
-       <td>scroll</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td>
-       <td>18330</td>
-</tr>
-<tr>
-       <td>pause</td>
-       <td>300</td>
-       <td></td>
-</tr>
-<tr>
-       <td>mouseClick</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[22]/domChild[0]/domChild[0]</td>
-       <td>41,-1823:shift</td>
-</tr>
-<tr>
-       <td>click</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]</td>
-       <td></td>
-</tr>
-<tr>
-       <td>screenCapture</td>
-       <td></td>
-       <td>selected-5-99</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[18]/domChild[1]/domChild[0]</td>
-       <td>updated</td>
-</tr>
-<tr>
-       <td>assertText</td>
-       <td>vaadin=runcomvaadintestscomponentstableLongMultiselect::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[19]/domChild[1]</td>
-       <td></td>
-</tr>
-
-</tbody></table>
-</body>
-</html>
index 43a89e4211cd2772ec034400dfedad60595f1218..d5302cdf45b1ed801d952ca39e427922ec8ac355 100644 (file)
@@ -3,29 +3,23 @@ package com.vaadin.tests.components.table;
 import java.util.Collection;
 
 import com.vaadin.data.Property;
-import com.vaadin.tests.components.TestBase;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.VerticalLayout;
 
-public class LongMultiselect extends TestBase {
+public class LongMultiselect extends AbstractTestUI {
 
     private enum ItemProperty {
         COLUMN1, COLUMN2
     }
 
     @Override
-    protected void setup() {
-        VerticalLayout layout = generateLayout();
-        addComponent(layout);
-        layout.setSizeFull();
-    }
-
-    private VerticalLayout generateLayout() {
-        VerticalLayout layout = new VerticalLayout();
-
+    protected void setup(VaadinRequest request) {
         final Table table = new Table("Ticket #8264 table");
-        layout.addComponent(table);
+        addComponent(table);
+
         table.setWidth("200px");
         table.setHeight("170px");
         table.setSelectable(true);
@@ -40,7 +34,7 @@ public class LongMultiselect extends TestBase {
         }
 
         // Add action button
-        layout.addComponent(new Button("Do It", new Button.ClickListener() {
+        addComponent(new Button("Do It", new Button.ClickListener() {
             @Override
             public void buttonClick(Button.ClickEvent event) {
                 // Set ItemProperty.COLUMN2 for all selected values of table
@@ -57,11 +51,10 @@ public class LongMultiselect extends TestBase {
             }
         }));
 
-        return layout;
     }
 
     @Override
-    protected String getDescription() {
+    protected String getTestDescription() {
         return "Multiselecting 94 rows (from \"item 5\" to \"item 98\") and modifying second column of each row selected (press Do It). This should work (update the 2nd column) and not cause JS exception.";
     }
 
diff --git a/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java b/uitest/src/com/vaadin/tests/components/table/LongMultiselectTest.java
new file mode 100644 (file)
index 0000000..26c4d99
--- /dev/null
@@ -0,0 +1,81 @@
+package com.vaadin.tests.components.table;
+
+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;
+
+public class LongMultiselectTest extends MultiBrowserTest {
+
+    private int ROWCOUNT = 100;
+    private int FIRSTSELECTEDROW = 4;
+    private int LASTSELECTEDROW = 97;
+
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        return getBrowsersSupportingShiftClick();
+    }
+
+    @Override
+    protected boolean requireWindowFocusForIE() {
+        return true;
+    }
+
+    @Test
+    public void selectedRowsAreUpdated() throws InterruptedException {
+        openTestURL();
+
+        selectRows();
+        $(ButtonElement.class).first().click();
+
+        TableElement table = getTable();
+        assertThat(table.getCell(LASTSELECTEDROW, 1).getText(), is("updated"));
+        assertThat(table.getCell(LASTSELECTEDROW-1, 1).getText(), is("updated"));
+    }
+
+    private void selectRows() {
+        TableElement table = getTable();
+        table.getCell(FIRSTSELECTEDROW, 0).click();
+
+        scrollToBottom();
+
+        new Actions(getDriver()).keyDown(Keys.SHIFT).click(getTable().getCell(LASTSELECTEDROW, 0)).keyUp(Keys.SHIFT)
+                .build().perform();
+    }
+
+    private TableElement getTable() {
+        return $(TableElement.class).first();
+    }
+
+    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;
+                }
+            }
+        });
+    }
+
+}
\ No newline at end of file
index ccbb6ca87280577d9eaac56c323d984e5555f8ae..414aebbd33111fd0d4dd90b0c098d3913fa02db6 100644 (file)
@@ -50,6 +50,18 @@ public abstract class MultiBrowserTest extends PrivateTB3Configuration {
         return browsers;
     }
 
+
+    protected List<DesiredCapabilities> getBrowsersSupportingShiftClick() {
+        List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers());
+
+        //IE supports shift click only when require window focus is true
+        browsers.remove(Browser.FIREFOX.getDesiredCapabilities());
+        browsers.remove(Browser.PHANTOMJS.getDesiredCapabilities());
+
+        return browsers;
+    }
+
+
     public enum Browser {
         FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI(
                 BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil