]> source.dussan.org Git - vaadin-framework.git/commitdiff
Extract IE8 to it's own TableColumnResizeContentsWidthTest.
authorSauli Tähkäpää <sauli@vaadin.com>
Thu, 18 Sep 2014 06:40:03 +0000 (09:40 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 19 Sep 2014 05:43:39 +0000 (05:43 +0000)
Change-Id: I1f9680b9fd16977aa3351e2406e0831b2046c191

uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthIE8Test.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java

diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthIE8Test.java b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthIE8Test.java
new file mode 100644 (file)
index 0000000..8bace7e
--- /dev/null
@@ -0,0 +1,50 @@
+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.WebElement;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+public class TableColumnResizeContentsWidthIE8Test extends MultiBrowserTest {
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        List<DesiredCapabilities> browsersToTest = new ArrayList<DesiredCapabilities>();
+
+        browsersToTest.add(Browser.IE8.getDesiredCapabilities());
+
+        return browsersToTest;
+    }
+
+    @Override
+    protected Class<?> getUIClass() {
+        return TableColumnResizeContentsWidth.class;
+    }
+
+    @Test
+    public void testResizing() throws InterruptedException {
+        openTestURL();
+
+        TableElement table = $(TableElement.class).first();
+        List<ButtonElement> buttons = $(ButtonElement.class).all();
+
+        WebElement textField = table.findElement(By.className("v-textfield"));
+
+        // click the button for decreasing size
+        buttons.get(1).click();
+
+        assertEquals(60, textField.getSize().width);
+
+        // click the button for increasing size
+        buttons.get(0).click();
+
+        assertEquals(80, textField.getSize().width);
+    }
+}
index 0e98e7ddecf33e2491af883d6f54cbd35f2cdc54..3ae66de684eee3bdd5cba0dd8b07547f5af3191e 100644 (file)
  */
 package com.vaadin.tests.components.table;
 
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
+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.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.ExpectedCondition;
 
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.TableElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
 
 /**
  * Tests that components within table cells get resized when their column gets
@@ -36,41 +38,64 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
  */
 public class TableColumnResizeContentsWidthTest extends MultiBrowserTest {
 
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        List<DesiredCapabilities> browsersToTest = super.getBrowsersToTest();
+
+        //Can't get IE8 to hit the resizer, extracted IE8 to it's own test class.
+        browsersToTest.remove(Browser.IE8.getDesiredCapabilities());
+
+        return browsersToTest;
+    }
+
     @Test
     public void testResizing() throws InterruptedException {
         openTestURL();
 
-        TableElement table = $(TableElement.class).first();
         List<ButtonElement> buttons = $(ButtonElement.class).all();
 
-        WebElement textField = table.findElement(By.className("v-textfield"));
-        WebElement resizer = table.findElement(By.className("v-table-resizer"));
-
-        assertEquals(100, textField.getSize().width);
-
-        // drag resizer to left
-        new Actions(getDriver()).moveToElement(resizer).clickAndHold()
-                .moveByOffset(-20, 0).release().perform();
+        WebElement resizer = getTable().findElement(By.className("v-table-resizer"));
 
-        assertEquals(80, textField.getSize().width);
+        assertEquals(100, getTextFieldWidth());
 
-        // drag resizer to right
-        new Actions(getDriver()).moveToElement(resizer).clickAndHold()
-                .moveByOffset(40, 0).release().perform();
+        moveResizer(resizer, -20);
+        assertEquals(80, getTextFieldWidth());
 
-        assertEquals(120, textField.getSize().width);
+        moveResizer(resizer, 40);
+        assertEquals(120, getTextFieldWidth());
 
         // click the button for decreasing size
         buttons.get(1).click();
-        sleep(50);
-
-        assertEquals(80, textField.getSize().width);
+        waitUntilTextFieldWidthIs(80);
 
         // click the button for increasing size
         buttons.get(0).click();
-        sleep(50);
+        waitUntilTextFieldWidthIs(100);
+    }
+
+    private void waitUntilTextFieldWidthIs(final int width) {
+        waitUntil(new ExpectedCondition<Object>() {
+            @Override
+            public Object apply(WebDriver input) {
+                return getTextFieldWidth() == width;
+            }
+        });
+    }
+
+    private int getTextFieldWidth() {
+        TableElement table = getTable();
+        final WebElement textField = table.findElement(By.className("v-textfield"));
+
+        return textField.getSize().width;
+    }
 
-        assertEquals(100, textField.getSize().width);
+    private TableElement getTable() {
+        return $(TableElement.class).first();
     }
 
+    private void moveResizer(WebElement resizer, int offset) {
+        new Actions(driver).clickAndHold(resizer).moveByOffset(offset, 0).release().perform();
+    }
 }
+
+