diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-07-08 11:32:54 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-07-08 11:32:54 +0300 |
commit | 770b5b5aced652cd7eed9d49e6c477908a9d7efb (patch) | |
tree | c4b2b7a6335f919510f323af419c79da74fdf7c7 /uitest/src | |
parent | ec205707eacb1187ab8f21e7e7c5150944ef349b (diff) | |
parent | 8c36375edb9cadfec64a67f034d2a6828242df6f (diff) | |
download | vaadin-framework-770b5b5aced652cd7eed9d49e6c477908a9d7efb.tar.gz vaadin-framework-770b5b5aced652cd7eed9d49e6c477908a9d7efb.zip |
Merge remote-tracking branch 'origin/master' into grid
Conflicts:
WebContent/release-notes.html
Change-Id: I7f97cb771665485dbc9130a3c9b0365185615fc5
Diffstat (limited to 'uitest/src')
21 files changed, 650 insertions, 332 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboboxPageLengthZeroScrollTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboboxPageLengthZeroScrollTest.java index 9d863d2c0c..948acc5fe6 100644 --- a/uitest/src/com/vaadin/tests/components/combobox/ComboboxPageLengthZeroScrollTest.java +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboboxPageLengthZeroScrollTest.java @@ -15,12 +15,16 @@ */ package com.vaadin.tests.components.combobox; +import java.util.Collections; +import java.util.List; + import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -60,4 +64,9 @@ public class ComboboxPageLengthZeroScrollTest extends MultiBrowserTest { cssValue); } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(Browser.IE8.getDesiredCapabilities()); + } } diff --git a/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java b/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java index cf756034a1..c80a74599d 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/LocaleChangeTest.java @@ -34,7 +34,7 @@ public class LocaleChangeTest extends MultiBrowserTest { assertPopupOpen(true); // Close the popup and change the locale. - toggleDatePopup(); + toggleDatePopupWorkaroundClosePopupIE(); assertPopupOpen(false); driver.findElement(By.className("v-button")).click(); // Locale change. @@ -55,6 +55,26 @@ public class LocaleChangeTest extends MultiBrowserTest { driver.findElement(By.className("v-datefield-button")).click(); } + /* + * Work around bug reported in ticket #14086. Delete this method once fixed + * andd use toggleDatePopup() instead. + */ + private void toggleDatePopupWorkaroundClosePopupIE() { + if (!BrowserUtil.isIE(getDesiredCapabilities())) { + driver.findElement(By.className("v-datefield-button")).click(); + } else { + boolean popupOpen = driver.findElements( + By.className("v-datefield-popup")).size() == 1; + if (popupOpen) { + driver.findElement( + By.className("v-datefield-calendarpanel-day-selected")) + .click(); + } else { + driver.findElement(By.className("v-datefield-button")).click(); + } + } + } + private String getDateValue() { return driver.findElement(By.className("v-datefield-textfield")) .getAttribute("value"); diff --git a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java new file mode 100644 index 0000000000..8bbb5cfe1a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutBaseTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +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.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; + +public abstract class GridLayoutBaseTest extends MultiBrowserTest { + @Test + public void cellSizesAreCorrectlyCalculated() { + openTestURL(); + + 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); + assertEquals("Different top coordinate for element " + i, + compared.getCssValue("top"), actual.getCssValue("top")); + assertEquals("Different left coordinate for element " + i, + 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/GridLayoutExpandRatioTest.java b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java index d4d36bd10f..f543068851 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutExpandRatioTest.java @@ -15,56 +15,12 @@ */ package com.vaadin.tests.components.gridlayout; -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 java.util.List; - -import static org.junit.Assert.assertEquals; - -public class GridLayoutExpandRatioTest extends MultiBrowserTest { - @Test - public void cellSizesAreCorrectlyCalculated() { - openTestURL(); - - 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); - assertEquals("Different top coordinate for element " + i, - compared.getCssValue("top"), actual.getCssValue("top")); - assertEquals("Different left coordinate for element " + i, - 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")); - } +/** + * A test class for testing GridLayoutExpandRatio. The class is empty because + * the name convention is UIClassName+Test. GridLayoutExpandRatioTest and + * GridLayoutHideMiddleCellsTest behave the same way but on different UI + * classes. Thats why they have different names and zero code. + */ +public class GridLayoutExpandRatioTest extends GridLayoutBaseTest { - 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 a5eb9b6e04..f62735051b 100644 --- a/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java +++ b/uitest/src/com/vaadin/tests/components/gridlayout/GridLayoutHideMiddleCellsTest.java @@ -15,5 +15,12 @@ */ package com.vaadin.tests.components.gridlayout; -public class GridLayoutHideMiddleCellsTest extends GridLayoutExpandRatioTest { +/** + * A test class for testing GridLayoutHideMiddleCellsTest. The class is empty + * because the name convention is UIClassName+Test. GridLayoutExpandRatioTest + * and GridLayoutHideMiddleCellsTest behave the same way but on different UI + * classes. Thats why they have different names and zero code. + */ +public class GridLayoutHideMiddleCellsTest extends GridLayoutBaseTest { + } diff --git a/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java b/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java index 0c6f0abf3c..bca8fd4390 100644 --- a/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java +++ b/uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java @@ -20,9 +20,13 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan; +import java.util.Collections; +import java.util.List; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.PopupViewElement; @@ -63,4 +67,8 @@ public class PopupViewResizeWhileOpenTest extends MultiBrowserTest { assertThat(shadowSize.width, is(lessThan(layoutSize.width + 10))); } + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return Collections.singletonList(Browser.IE8.getDesiredCapabilities()); + } } diff --git a/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java index 5502bf0495..e067ada818 100644 --- a/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java +++ b/uitest/src/com/vaadin/tests/components/window/WindowMoveListenerTest.java @@ -1,16 +1,16 @@ package com.vaadin.tests.components.window; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - +import com.vaadin.tests.tb3.MultiBrowserTest; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Point; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; -import com.vaadin.tests.tb3.MultiBrowserTest; +import static org.junit.Assert.assertNotEquals; public class WindowMoveListenerTest extends MultiBrowserTest { @@ -18,21 +18,20 @@ public class WindowMoveListenerTest extends MultiBrowserTest { public void testWindowRepositioning() throws Exception { openTestURL(); - WebElement window = getDriver().findElement(By.id("testwindow")); + final WebElement window = getDriver().findElement(By.id("testwindow")); WebElement button = getDriver().findElement(By.id("testbutton")); // I'd loved to use the header, but that doesn't work. Footer works // fine, though :) - WebElement windowHeader = getDriver().findElement( + WebElement windowFooter = getDriver().findElement( By.className("v-window-footer")); - Point winPos = window.getLocation(); + final Point winPos = window.getLocation(); // move window - Action a = new Actions(driver).clickAndHold(windowHeader) + Action a = new Actions(driver).clickAndHold(windowFooter) .moveByOffset(100, 100).release().build(); a.perform(); - assertNotEquals("Window was not dragged correctly.", winPos.x, window.getLocation().x); assertNotEquals("Window was not dragged correctly.", winPos.y, @@ -41,10 +40,16 @@ public class WindowMoveListenerTest extends MultiBrowserTest { // re-set window button.click(); - assertEquals("Window was not re-positioned correctly.", winPos.x, - window.getLocation().x); - assertEquals("Window was not re-positioned correctly.", winPos.y, - window.getLocation().y); + waitUntilWindowHasReseted(window, winPos); + } + private void waitUntilWindowHasReseted(final WebElement window, final Point winPos) { + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + return winPos.x == window.getLocation().x && + winPos.y == window.getLocation().y; + } + }, 5); } } diff --git a/uitest/src/com/vaadin/tests/components/window/WindowShadow.java b/uitest/src/com/vaadin/tests/components/window/WindowShadow.java new file mode 100644 index 0000000000..12e7899503 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowShadow.java @@ -0,0 +1,59 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.UI; +import com.vaadin.ui.Window; + +//Tests that invisible divs don't overlap windows and don't block mouse events +public class WindowShadow extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Window wnd = createWindow(); + wnd.setId("topwindow"); + Window wnd2 = createWindow(); + wnd2.setId("botwindow"); + wnd.setPositionX(100); + wnd.setPositionY(100); + wnd2.setPositionX(100); + // Pick ycoord, that the top div of the Window overlaps with its footer + int yCoord = (int) (wnd.getPositionX() + wnd.getHeight() - 5); + wnd2.setPositionY(yCoord); + UI.getCurrent().addWindow(wnd); + UI.getCurrent().addWindow(wnd2); + } + + private Window createWindow() { + Window wnd = new Window(); + wnd.setHeight("200"); + wnd.setWidth("200"); + return wnd; + } + + @Override + protected String getTestDescription() { + return "Popup window has shadow div elemetns, which overlaps other elements and blocks mouse events"; + } + + @Override + protected Integer getTicketNumber() { + return 13885; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/WindowShadowTest.java b/uitest/src/com/vaadin/tests/components/window/WindowShadowTest.java new file mode 100644 index 0000000000..0bd6c9fa44 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/WindowShadowTest.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.window; + +import java.awt.AWTException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.HasInputDevices; +import org.openqa.selenium.interactions.Mouse; +import org.openqa.selenium.interactions.internal.Coordinates; +import org.openqa.selenium.internal.Locatable; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class WindowShadowTest extends MultiBrowserTest { + + @Test + public void dragBackgroundWindow() throws AWTException, IOException, + InterruptedException { + openTestURL(); + WebElement wnd = getDriver().findElement(By.id("topwindow")); + // There is some bug in Selenium. Can't move window using header + // need use footer instead. + WebElement wnd1Footer = wnd + .findElement(By.className("v-window-footer")); + Point startLoc = wnd.getLocation(); + Coordinates footerCoordinates = ((Locatable) wnd1Footer) + .getCoordinates(); + Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); + mouse.mouseDown(footerCoordinates); + mouse.mouseMove(footerCoordinates, 200, 200); + mouse.mouseUp(footerCoordinates); + Point endLoc = wnd.getLocation(); + // don't compare to specific coordinate, because in IE9 and IE11 + // the window position is random. + // So, checkt that the window was moved + org.junit.Assert.assertNotEquals(startLoc, endLoc); + } + + // IE8 doesn't support shadow-box css rule + // ignore this browser in testing + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>( + getAllBrowsers()); + browsers.remove(Browser.IE8.getDesiredCapabilities()); + return browsers; + } +}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java index ac58deea56..f2207ccba7 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationLongPollingTest.java @@ -26,33 +26,19 @@ import org.openqa.selenium.support.ui.Select; public class PushConfigurationLongPollingTest extends PushConfigurationTest { - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - List<DesiredCapabilities> browsers = super.getBrowsersToTest(); - - browsers.remove(Browser.IE8.getDesiredCapabilities()); - - return browsers; - } - @Test public void testLongPolling() throws InterruptedException { - new Select(getTransportSelect()).selectByVisibleText("LONG_POLLING"); - new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + openDebugLogTab(); + new Select(getTransportSelect()).selectByVisibleText("LONG_POLLING"); assertThat(getStatusText(), containsString("fallbackTransport: long-polling")); assertThat(getStatusText(), containsString("transport: long-polling")); + clearDebugMessages(); + new Select(getPushModeSelect()).selectByVisibleText("AUTOMATIC"); + waitForDebugMessage("Push connection established using long-polling", 10); waitForServerCounterToUpdate(); - - // Use debug console to verify we used the correct transport type - assertThat( - driver.getPageSource(), - containsString("Push connection established using long-polling")); - - new Select(getPushModeSelect()).selectByVisibleText("DISABLED"); - } } diff --git a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java index 0861e618a2..f5c015ad12 100644 --- a/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java +++ b/uitest/src/com/vaadin/tests/push/PushConfigurationStreamingTest.java @@ -15,16 +15,12 @@ */ package com.vaadin.tests.push; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.util.List; - import org.junit.Test; -import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.Select; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; + public class PushConfigurationStreamingTest extends PushConfigurationTest { @Test diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index e5cceca6b8..fa704d7b0b 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -16,8 +16,6 @@ package com.vaadin.tests.tb3; -import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -26,14 +24,11 @@ import java.net.URL; import java.util.Collections; import java.util.List; +import com.vaadin.testbench.TestBenchElement; import org.junit.After; import org.junit.Before; import org.junit.runner.RunWith; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.Platform; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.*; import org.openqa.selenium.interactions.HasInputDevices; import org.openqa.selenium.interactions.Keyboard; import org.openqa.selenium.interactions.Mouse; @@ -50,12 +45,13 @@ import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; import com.vaadin.server.LegacyApplication; import com.vaadin.server.UIProvider; import com.vaadin.testbench.TestBench; -import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.TestBenchTestCase; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.tests.tb3.MultiBrowserTest.Browser; import com.vaadin.ui.UI; +import static com.vaadin.tests.tb3.TB3Runner.localWebDriverIsUsed; + /** * Base class for TestBench 3+ tests. All TB3+ tests in the project should * extend this class. @@ -157,8 +153,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } protected WebElement getTooltipElement() { - return getDriver().findElement( - com.vaadin.testbench.By.className("v-tooltip-text")); + return getDriver().findElement(com.vaadin.testbench.By.className("v-tooltip-text")); } protected Coordinates getCoordinates(TestBenchElement element) { @@ -215,22 +210,7 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { * {@link #isPush()}. */ protected void openTestURL() { - openTestURL(""); - } - - /** - * Opens the given test (defined by {@link #getTestUrl()}, optionally with - * debug window and/or push (depending on {@link #isDebug()} and - * {@link #isPush()}. - */ - protected void openTestURL(String extraParameters) { - String url = getTestUrl(); - if (url.contains("?")) { - url = url + "&" + extraParameters; - } else { - url = url + "?" + extraParameters; - } - driver.get(url); + driver.get(getTestUrl()); } /** @@ -1030,7 +1010,19 @@ public abstract class AbstractTB3Test extends TestBenchTestCase { } protected void openDebugLogTab() { - findElement(By.xpath("//button[@title='Debug message log']")).click(); + + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + WebElement element = getDebugLogButton(); + return element != null; + } + }, 15); + getDebugLogButton().click(); + } + + private WebElement getDebugLogButton() { + return findElement(By.xpath("//button[@title='Debug message log']")); } } diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java deleted file mode 100644 index 8989d88164..0000000000 --- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFly.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.themes; - -import com.vaadin.annotations.Theme; -import com.vaadin.server.ThemeResource; -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.tests.util.PersonContainer; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.GridLayout; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.Image; -import com.vaadin.ui.Label; -import com.vaadin.ui.Table; - -@Theme("reindeer") -public class ThemeChangeOnTheFly extends AbstractTestUIWithLog { - - @Override - protected void setup(VaadinRequest request) { - Button inject = new Button("Inject blue background"); - inject.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getPage().getStyles().add( - ".v-app { background: blue !important;}"); - - } - }); - addComponent(inject); - - GridLayout gl = new GridLayout(2, 4); - gl.setCaption("Change theme by clicking a button"); - for (final String theme : new String[] { "reindeer", "runo", - "chameleon", "base", null }) { - Button b = new Button(theme); - b.setId(theme + ""); - b.addClickListener(new ClickListener() { - - @Override - public void buttonClick(ClickEvent event) { - getUI().setTheme(theme); - } - }); - gl.addComponent(b); - } - - Table t = new Table(); - PersonContainer pc = PersonContainer.createWithTestData(); - pc.addNestedContainerBean("address"); - t.setContainerDataSource(pc); - gl.addComponent(t, 0, 3, 1, 3); - gl.setRowExpandRatio(3, 1); - - gl.setWidth("500px"); - gl.setHeight("800px"); - - HorizontalLayout images = new HorizontalLayout(); - images.setSpacing(true); - - Label l = new Label("Chameleon theme image in caption"); - l.setIcon(new ThemeResource("img/magnifier.png")); - images.addComponent(l); - Image image = new Image("Runo theme image", new ThemeResource( - "icons/64/ok.png")); - images.addComponent(image); - image = new Image("Reindeer theme image", new ThemeResource( - "button/img/left-focus.png")); - images.addComponent(image); - addComponent(images); - addComponent(gl); - - getLayout().setSpacing(true); - } - - @Override - protected String getTestDescription() { - return "Test that you can change theme on the fly"; - } - - @Override - protected Integer getTicketNumber() { - return 2874; - } - -} diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java deleted file mode 100644 index 681a7d762b..0000000000 --- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2000-2013 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.tests.themes; - -import java.io.IOException; -import java.util.List; - -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.support.ui.ExpectedCondition; - -import com.vaadin.testbench.elements.ButtonElement; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class ThemeChangeOnTheFlyTest extends MultiBrowserTest { - - /* - * (non-Javadoc) - * - * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() - */ - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - // Seems like stylesheet onload is not fired on PhantomJS - List<DesiredCapabilities> l = super.getBrowsersToTest(); - l.remove(Browser.PHANTOMJS.getDesiredCapabilities()); - return l; - } - - @Test - public void injectedStyleAndThemeChange() throws IOException { - openTestURL(); - $(ButtonElement.class).caption("Inject blue background").first() - .click(); - changeTheme("runo"); - compareScreen("runo-blue-background"); - } - - @Test - public void reindeerToOthers() throws IOException { - openTestURL(); - compareScreen("reindeer"); - - changeThemeAndCompare("runo"); - changeThemeAndCompare("chameleon"); - changeThemeAndCompare("base"); - - } - - @Test - public void runoToReindeer() throws IOException { - openTestURL("theme=runo"); - compareScreen("runo"); - changeThemeAndCompare("reindeer"); - } - - @Test - public void reindeerToNullToReindeer() throws IOException { - openTestURL(); - - changeThemeAndCompare("null"); - changeThemeAndCompare("reindeer"); - } - - private void changeThemeAndCompare(String theme) throws IOException { - changeTheme(theme); - compareScreen(theme); - } - - private void changeTheme(String theme) { - $(ButtonElement.class).id(theme).click(); - if (theme.equals("null")) { - waitForThemeToChange(""); - } else { - waitForThemeToChange(theme); - } - } - - private void waitForThemeToChange(final String theme) { - - final WebElement rootDiv = findElement(By - .xpath("//div[contains(@class,'v-app')]")); - waitUntil(new ExpectedCondition<Boolean>() { - - @Override - public Boolean apply(WebDriver input) { - String rootClass = rootDiv.getAttribute("class").trim(); - String expected = "v-app " + theme; - expected = expected.trim(); - return rootClass.equals(expected); - } - }, 30); - } -} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java new file mode 100644 index 0000000000..43d96afd2b --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcButtonConnector.java @@ -0,0 +1,123 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client.gwtrpc; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.google.gwt.core.shared.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.DialogBox; +import com.google.gwt.user.client.ui.Label; +import com.vaadin.client.ui.AbstractComponentConnector; +import com.vaadin.shared.ui.Connect; +import com.vaadin.tests.widgetset.server.gwtrpc.GwtRpcButton; + +/** + * Dummy connector to test our Vaadin/GWT RPC bug. In a Vaadin environment with + * DevMode enabled, a pure GWT RPC call would throw an exception. See #11709. + * + * @author Vaadin Ltd + */ +@SuppressWarnings("serial") +@Connect(GwtRpcButton.class) +public class GwtRpcButtonConnector extends AbstractComponentConnector { + + static Logger logger = Logger.getLogger(GwtRpcButtonConnector.class + .getName()); + static { + logger.setLevel(Level.ALL); + } + + @Override + public Button getWidget() { + return (Button) super.getWidget(); + } + + @Override + protected Button createWidget() { + return GWT.create(Button.class); + } + + private void log(String message) { + logger.log(Level.INFO, message); + } + + @Override + public void init() { + super.init(); + + log("GwtRpcButtonTestConnector init"); + + getWidget().setText("Click me"); + getWidget().addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + doRPC(); + } + + }); + } + + /** + * The ID of the label in case the test is successful. + */ + public static final String SUCCESS_LABEL_ID = "yes"; + + /** + * The ID of the label in case the test failed. + */ + public static final String FAIL_LABEL_ID = "no"; + + /* + * Make an RPC to test our bug. + */ + private void doRPC() { + log("GwtRpcButtonTestConnector onClick"); + + GwtRpcServiceTestAsync service = GWT.create(GwtRpcServiceTest.class); + + service.giveMeThat("honey", "sugar", new AsyncCallback<String>() { + + @Override + public void onSuccess(String result) { + showResult(result, SUCCESS_LABEL_ID); + } + + @Override + public void onFailure(Throwable caught) { + showResult(caught.getMessage(), FAIL_LABEL_ID); + } + + /* + * Show the result box. + */ + private void showResult(String result, String labelID) { + DialogBox box = new DialogBox(true); + Label label = new Label(result); + label.getElement().setId(labelID); + box.add(label); + box.center(); + box.show(); + } + + }); + } +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTest.java b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTest.java new file mode 100644 index 0000000000..16df928d77 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client.gwtrpc; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +/** + * Test GWT RPC in Vaadin DevMode. + * + * @author Vaadin Ltd + */ +@RemoteServiceRelativePath("GwtRpcTest") +public interface GwtRpcServiceTest extends RemoteService { + + /* + * Dummy method to verify if RPC works. + */ + String giveMeThat(String that, String haveThis); + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTestAsync.java b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTestAsync.java new file mode 100644 index 0000000000..93eda8ca34 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/client/gwtrpc/GwtRpcServiceTestAsync.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.client.gwtrpc; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +/** + * Test GWT RPC in Vaadin DevMode. + * + * @author Vaadin Ltd + */ +public interface GwtRpcServiceTestAsync { + + /* + * Dummy async method to verify if RPC works. + */ + void giveMeThat(String that, String haveThis, AsyncCallback<String> callback); + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpc.java b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpc.java new file mode 100644 index 0000000000..c9f949c465 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpc.java @@ -0,0 +1,56 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server.gwtrpc; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.tests.widgetset.TestingWidgetSet; + +/** + * Test the GWT RPC with Vaadin DevMode. See #11709. + * + * @author Vaadin Ltd + */ +@SuppressWarnings("serial") +@Widgetset(TestingWidgetSet.NAME) +public class GwtRpc extends AbstractTestUI { + + /** + * Id of the button triggering the test case. + */ + public final static String BUTTON_ID = "gwtRpcButton"; + + @Override + protected void setup(VaadinRequest request) { + GwtRpcButton button = new GwtRpcButton(); + button.setId(BUTTON_ID); + button.setCaption("Press me"); + + addComponent(button); + } + + @Override + protected String getTestDescription() { + return "Cannot call RPC in development mode"; + } + + @Override + protected Integer getTicketNumber() { + return 11709; + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcButton.java b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcButton.java new file mode 100644 index 0000000000..c04800713d --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcButton.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server.gwtrpc; + +import com.vaadin.ui.AbstractComponent; + +/** + * Dummy client connector to link with the client functionality where the GWT + * RPC is triggered. + * + * @since + * @author Vaadin Ltd + */ +@SuppressWarnings("serial") +public class GwtRpcButton extends AbstractComponent { + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcServletTest.java b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcServletTest.java new file mode 100644 index 0000000000..df01b4dc81 --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcServletTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server.gwtrpc; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; +import com.vaadin.tests.widgetset.client.gwtrpc.GwtRpcServiceTest; + +/** + * Test GWT RPC in Vaadin DevMode. + * + * @author Vaadin Ltd + */ +@SuppressWarnings("serial") +public class GwtRpcServletTest extends RemoteServiceServlet implements + GwtRpcServiceTest { + + @Override + public String giveMeThat(String that, String haveThis) { + return "Take " + that + " for " + haveThis; + } + +} diff --git a/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcTest.java b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcTest.java new file mode 100644 index 0000000000..d27884a13a --- /dev/null +++ b/uitest/src/com/vaadin/tests/widgetset/server/gwtrpc/GwtRpcTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.widgetset.server.gwtrpc; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.widgetset.client.gwtrpc.GwtRpcButtonConnector; + +/** + * Test the GWT RPC with Vaadin DevMode. See #11709. + * + * @author Vaadin Ltd + */ +public class GwtRpcTest extends MultiBrowserTest { + + @Test + public void testGwtRpc() { + openTestURL(); + + getDriver().findElement(By.id(GwtRpc.BUTTON_ID)).click(); + + By label = By.id(GwtRpcButtonConnector.SUCCESS_LABEL_ID); + + waitForElementToBePresent(label); + getDriver().findElement(label); + } + +} |