diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-06-11 10:09:18 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-06-18 05:41:44 +0000 |
commit | f28d710aee0279ee484acd5c645e9c425e6f4b3a (patch) | |
tree | 8bbc354bb6ad0283181c3b65e1aaa3c48427f1d8 | |
parent | 8b0846967af04070bf692d444f7d684499410d24 (diff) | |
download | vaadin-framework-f28d710aee0279ee484acd5c645e9c425e6f4b3a.tar.gz vaadin-framework-f28d710aee0279ee484acd5c645e9c425e6f4b3a.zip |
Change PhantomJS to run on Linux instead of Windows.
Change-Id: Ibb7080c37a67516c852e00d08c2d5d822fda654e
6 files changed, 92 insertions, 88 deletions
diff --git a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java index 53317bd581..43d6a55a8b 100644 --- a/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -49,7 +49,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36"); expectedUserAgent .put(Browser.PHANTOMJS.getDesiredCapabilities(), - "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"); + "Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34"); } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java index bc03593e3f..fa6f5a3a93 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxScrollingWithArrowsTest.java @@ -15,16 +15,19 @@ */ package com.vaadin.tests.components.combobox; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; import org.junit.Test; import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; /** * When pressed down key, while positioned on the last item - should show next @@ -32,52 +35,72 @@ import com.vaadin.tests.tb3.MultiBrowserTest; */ public class ComboBoxScrollingWithArrowsTest extends MultiBrowserTest { - @Before - public void openURL() { + private final int PAGESIZE = 10; + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + openPopup(); } - @Test - public void scrollDownArrowKeyTest() throws InterruptedException { - final int ITEMS_PER_PAGE = 10; + private WebElement getDropDown() { // Selenium is used instead of TestBench4, because there is no method to // access the popup of the combobox // The method ComboBoxElement.openPopup() opens the popup, but doesn't // provide any way to access the popup and send keys to it. // Ticket #13756 - WebElement dropDownComboBox = driver.findElement(By + + return driver.findElement(By .className("v-filterselect-input")); - // opens Lookup - dropDownComboBox.sendKeys(Keys.DOWN); + } + + private void openPopup() { + ComboBoxElement cb = $(ComboBoxElement.class).first(); + cb.openPopup(); + } + + @Test + public void scrollDownArrowKeyTest() throws InterruptedException { + WebElement dropDownComboBox = getDropDown(); + // go to the last item and then one more - for (int i = 0; i < ITEMS_PER_PAGE + 1; i++) { + for (int i = 0; i < PAGESIZE + 1; i++) { dropDownComboBox.sendKeys(Keys.DOWN); } - String expected = "item " + ITEMS_PER_PAGE;// item 10 + assertThat(getSelectedItemText(), is("item " + PAGESIZE)); //item 10 + } + + private String getSelectedItemText() { List<WebElement> items = driver.findElements(By .className("gwt-MenuItem-selected")); - String actual = items.get(0).getText(); - Assert.assertEquals(expected, actual); + return items.get(0).getText(); } @Test public void scrollUpArrowKeyTest() throws InterruptedException { - final int ITEMS_PER_PAGE = 10; - WebElement dropDownComboBox = driver.findElement(By - .className("v-filterselect-input")); - // opens Lookup - dropDownComboBox.sendKeys(Keys.DOWN); + WebElement dropDownComboBox = getDropDown(); + // go to the last item and then one more - for (int i = 0; i < ITEMS_PER_PAGE + 1; i++) { + for (int i = 0; i < PAGESIZE + 1; i++) { dropDownComboBox.sendKeys(Keys.DOWN); } + // move to one item up + waitUntilNextPageIsVisible(); dropDownComboBox.sendKeys(Keys.UP); - String expected = "item " + (ITEMS_PER_PAGE - 1);// item 9 - List<WebElement> items = driver.findElements(By - .className("gwt-MenuItem-selected")); - String actual = items.get(0).getText(); - Assert.assertEquals(expected, actual); + + assertThat(getSelectedItemText(), is("item " + (PAGESIZE - 1))); //item 9 + } + + private void waitUntilNextPageIsVisible() { + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return getSelectedItemText().equals("item " + PAGESIZE); + } + }, 5); } } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java index 54d355ab0a..7951187fa7 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java @@ -46,9 +46,11 @@ public class ComboBoxSetNullWhenNewItemsAllowedTest extends MultiBrowserTest { assertEquals("New value", element.getAttribute("value")); if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + Thread.sleep(500); } else { element.sendKeys(Keys.RETURN); } + assertEquals("", element.getAttribute("value")); } } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java index 7d5ad1fbc4..d4d36bd10f 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java @@ -15,32 +15,30 @@ */ package com.vaadin.tests.components.gridlayout; -import static org.junit.Assert.assertEquals; - -import java.util.List; - +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridLayoutElement; +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.support.ui.ExpectedCondition; -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.GridLayoutElement; -import com.vaadin.tests.tb3.MultiBrowserTest; +import java.util.List; + +import static org.junit.Assert.assertEquals; public class GridLayoutExpandRatioTest extends MultiBrowserTest { @Test - public void gridLayoutExpandRatioTest() { + public void cellSizesAreCorrectlyCalculated() { openTestURL(); - GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); - GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); - ButtonElement hidingButton = $(ButtonElement.class).get(0); - hidingButton.click(); - List<WebElement> slots5x5 = gridLayout5x5.findElements(By - .className("v-gridlayout-slot")); - List<WebElement> slots4x4 = gridLayout4x4.findElements(By - .className("v-gridlayout-slot")); - assertEquals("Different amount of slots", slots5x5.size(), - slots4x4.size()); + + hideMiddleRowAndColumn(); + final List<WebElement> slots4x4 = getSlots(1); + + waitUntilColumnAndRowAreHidden(slots4x4); + final List<WebElement> slots5x5 = getSlots(0); + for (int i = 0; i < slots5x5.size(); i++) { WebElement compared = slots5x5.get(i); WebElement actual = slots4x4.get(i); @@ -50,4 +48,23 @@ public class GridLayoutExpandRatioTest extends MultiBrowserTest { compared.getCssValue("left"), actual.getCssValue("left")); } } + + private void waitUntilColumnAndRowAreHidden(final List<WebElement> slots4x4) { + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return getSlots(0).size() == slots4x4.size(); + } + }, 5); + } + + private List<WebElement> getSlots(int index) { + GridLayoutElement layout = $(GridLayoutElement.class).get(index); + + return layout.findElements(By.className("v-gridlayout-slot")); + } + + private void hideMiddleRowAndColumn() { + $(ButtonElement.class).first().click(); + } } diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java index d0225275f7..a5eb9b6e04 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java @@ -15,43 +15,5 @@ */ package com.vaadin.tests.components.gridlayout; -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.testbench.elements.GridLayoutElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class GridLayoutHideMiddleCellsTest extends MultiBrowserTest { - @Test - public void gridLayoutInvisibleElementsTest() { - openTestURL(); - GridLayoutElement gridLayout5x5 = $(GridLayoutElement.class).get(0); - GridLayoutElement gridLayout4x4 = $(GridLayoutElement.class).get(1); - ButtonElement hidingButton = $(ButtonElement.class).get(0); - hidingButton.click(); - List<WebElement> slots5x5 = gridLayout5x5.findElements(By - .className("v-gridlayout-slot")); - List<WebElement> slots4x4 = gridLayout4x4.findElements(By - .className("v-gridlayout-slot")); - assertEquals("Different amount of slots", slots5x5.size(), - slots4x4.size()); - - for (int i = 0; i < slots5x5.size(); i++) { - assertEquals("Different left coordinate for element " + i, slots5x5 - .get(i).getCssValue("left"), - slots4x4.get(i).getCssValue("left")); - } - for (int i = 0; i < slots5x5.size(); i++) { - assertEquals("Different top coordinate for element " + i, slots5x5 - .get(i).getCssValue("top"), - slots4x4.get(i).getCssValue("top")); - } - } - +public class GridLayoutHideMiddleCellsTest extends GridLayoutExpandRatioTest { } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index 8783a4dc42..406f1fe27c 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -791,7 +791,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { */ public static DesiredCapabilities phantomJS(int version) { DesiredCapabilities c = DesiredCapabilities.phantomjs(); - c.setPlatform(Platform.XP); + c.setPlatform(Platform.LINUX); c.setVersion("" + version); return c; } |