diff options
author | Artur Signell <artur@vaadin.com> | 2015-01-14 10:18:39 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-01-14 10:18:39 +0200 |
commit | 032bcef30f5ada7dc1ca6eade07ee596afa25bb3 (patch) | |
tree | a036581c2b7ae7e82fdd60ba92b2fe392b85df7a /uitest/src | |
parent | 8a544b5a6e78337b24a5e56bcde1a21ff6087fae (diff) | |
parent | b356e7e3bba9b08ad9d1ecdfb4d628b8179ef20a (diff) | |
download | vaadin-framework-032bcef30f5ada7dc1ca6eade07ee596afa25bb3.tar.gz vaadin-framework-032bcef30f5ada7dc1ca6eade07ee596afa25bb3.zip |
Merge remote-tracking branch 'origin/master' into grid
Conflicts:
client/src/com/vaadin/client/communication/AtmospherePushConnection.java
server/tests/src/com/vaadin/data/fieldgroup/FieldGroupTests.java
shared/src/com/vaadin/shared/util/SharedUtil.java
Change-Id: I300b5a92bde562390a56b720adf9a37b795c9513
Diffstat (limited to 'uitest/src')
9 files changed, 326 insertions, 60 deletions
diff --git a/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java new file mode 100644 index 0000000000..d398ead622 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParameters.java @@ -0,0 +1,36 @@ +/* + * 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.applicationservlet; + +import com.vaadin.launcher.CustomDeploymentConfiguration; +import com.vaadin.launcher.CustomDeploymentConfiguration.Conf; +import com.vaadin.server.Constants; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; + +@CustomDeploymentConfiguration({ @Conf(name = Constants.SERVLET_PARAMETER_SENDURLSASPARAMETERS, value = "false") }) +public class DisableSendUrlAsParameters extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + try { + log("Init location: " + getPage().getLocation()); + } catch (IllegalStateException e) { + log("Init location exception: " + e.getMessage()); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.java new file mode 100644 index 0000000000..f10f281646 --- /dev/null +++ b/uitest/src/com/vaadin/tests/applicationservlet/DisableSendUrlAsParametersTest.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.applicationservlet; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class DisableSendUrlAsParametersTest extends SingleBrowserTest { + + @Test + public void testInitLocation() { + openTestURL(); + + String logRow = getLogRow(0); + + Assert.assertEquals( + "1. Init location exception: Location is not available as the sendUrlsAsParameters parameter is configured as false", + logRow); + } +} diff --git a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java index 3a7d42e29c..dba055a65a 100644 --- a/uitest/src/com/vaadin/tests/components/AbstractTestUI.java +++ b/uitest/src/com/vaadin/tests/components/AbstractTestUI.java @@ -46,6 +46,11 @@ public abstract class AbstractTestUI extends UI { } protected void warnIfWidgetsetMaybeNotCompiled() { + // Can't check location if sendUrlAsParameters is disabled + if (!getSession().getConfiguration().isSendUrlsAsParameters()) { + return; + } + // Ignore if using debug mode String query = getPage().getLocation().getQuery(); if (query != null && query.matches(".*[&?]gwt\\.codesvr.*")) { diff --git a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java index 29c8c27883..bf81ca4390 100644 --- a/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java +++ b/uitest/src/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java @@ -15,102 +15,58 @@ */ package com.vaadin.tests.components.nativeselect; -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.WebElement; import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.remote.DesiredCapabilities; +import com.vaadin.testbench.elements.NativeSelectElement; import com.vaadin.tests.tb3.MultiBrowserTest; -/** - * - * @since - * @author Vaadin Ltd - */ public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest { - /* - * (non-Javadoc) - * - * @see com.vaadin.tests.tb3.MultiBrowserTest#getBrowsersToTest() - */ - @Override - public List<DesiredCapabilities> getBrowsersToTest() { - return Collections.singletonList(Browser.CHROME - .getDesiredCapabilities()); - } - @Test - public void testFocusListener() throws InterruptedException { + public void testFocusAndBlurListener() throws InterruptedException { setDebug(true); openTestURL(); - Thread.sleep(1000); + Thread.sleep(200); menu("Component"); menuSub("Listeners"); menuSub("Focus listener"); - - getDriver().findElement(By.tagName("body")).click(); - - WebElement select = getDriver().findElement(By.tagName("select")); - select.click(); - - String bodytext = getDriver().findElement(By.tagName("body")).getText(); - - Assert.assertTrue(bodytext.contains("FocusEvent")); - - } - - @Test - public void testBlurListener() throws InterruptedException { - setDebug(true); - openTestURL(); - Thread.sleep(1000); menu("Component"); menuSub("Listeners"); menuSub("Blur listener"); - getDriver().findElement(By.tagName("body")).click(); - - WebElement select = getDriver().findElement(By.tagName("select")); - select.click(); + findElement(By.tagName("body")).click(); + NativeSelectElement s = $(NativeSelectElement.class).first(); + s.selectByText("Item 3"); getDriver().findElement(By.tagName("body")).click(); - String bodytext = getDriver().findElement(By.tagName("body")).getText(); - - Assert.assertTrue(bodytext.contains("BlurEvent")); + // Somehow selectByText causes focus + blur + focus + blur on + // Chrome/PhantomJS + if (BrowserUtil.isChrome(getDesiredCapabilities()) + || BrowserUtil.isPhantomJS(getDesiredCapabilities())) { + Assert.assertEquals("4. FocusEvent", getLogRow(1)); + Assert.assertEquals("5. BlurEvent", getLogRow(0)); + } else { + Assert.assertEquals("2. FocusEvent", getLogRow(1)); + Assert.assertEquals("3. BlurEvent", getLogRow(0)); + } } - /* - * (non-Javadoc) - * - * @see com.vaadin.tests.tb3.AbstractTB3Test#getUIClass() - */ @Override protected Class<?> getUIClass() { return NativeSelects.class; } - /** - * @since - * @param string - */ private void menuSub(String string) { getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) .click(); new Actions(getDriver()).moveByOffset(100, 0).build().perform(); } - /** - * @since - * @param string - */ private void menu(String string) { getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) .click(); diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java new file mode 100644 index 0000000000..96210b2027 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtml.java @@ -0,0 +1,38 @@ +/* + * 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.ui; + +import com.vaadin.annotations.JavaScript; +import com.vaadin.annotations.StyleSheet; +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; + +@JavaScript("uiDependency.js") +@StyleSheet("theme://uiDependency.css") +@Theme("tests-valo") +public class UiDependenciesInHtml extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Label statusBox = new Label("Status box"); + statusBox.setId("statusBox"); + addComponent(statusBox); + + getPage().getJavaScript().execute("window.reportUiDependencyStatus();"); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java new file mode 100644 index 0000000000..188a0aea3e --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/UiDependenciesInHtmlTest.java @@ -0,0 +1,37 @@ +/* + * 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.ui; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class UiDependenciesInHtmlTest extends SingleBrowserTest { + + @Test + public void testUiDependencisInHtml() { + openTestURL(); + + String statusText = findElement(By.id("statusBox")).getText(); + + Assert.assertEquals( + "Script loaded before vaadinBootstrap.js: true\nStyle tag before vaadin theme: true", + statusText); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/ui/uiDependency.js b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js new file mode 100644 index 0000000000..4a5775c57f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/uiDependency.js @@ -0,0 +1,24 @@ +(function() { + var loadedBeforeVaadin = (window.vaadin === undefined); + + window.reportUiDependencyStatus = function() { + var styleIndex = 1000; + var themeIndex = -1; + + var stylesheets = document.querySelectorAll("link[rel=stylesheet]"); + for(var i = 0; i < stylesheets.length; i++) { + var stylesheet = stylesheets[i]; + var href = stylesheet.getAttribute("href"); + if (href.indexOf("uiDependency.css") > -1) { + styleIndex = i; + } else if (href.indexOf("styles.css" > -1)) { + themeIndex = i; + } + } + + var status = "Script loaded before vaadinBootstrap.js: " + loadedBeforeVaadin; + status += "<br />Style tag before vaadin theme: " + (styleIndex < themeIndex); + + document.getElementById("statusBox").innerHTML = status; + } +})();
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.java new file mode 100644 index 0000000000..f3df1a1176 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayout.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.extensions; + +import com.vaadin.server.Responsive; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Label; + +public class SetThemeAndResponsiveLayout extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + getLayout().setSizeFull(); + CssLayout responsiveLayout = new CssLayout(); + responsiveLayout.addStyleName("width-and-height"); + responsiveLayout.setSizeFull(); + setContent(responsiveLayout); + responsiveLayout + .addComponent(new Label( + "First set the theme using the button and then resize the browser window in both dimensions to see the background color change.")); + Button setThemeButton = new Button("Set theme"); + setThemeButton.addClickListener(new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + setTheme("tests-responsive"); + } + }); + responsiveLayout.addComponent(setThemeButton); + Responsive.makeResponsive(responsiveLayout); + } + + @Override + protected String getTestDescription() { + return "This test verifies that responsive works also when theme is set using setTheme method"; + }; + + @Override + protected Integer getTicketNumber() { + return 15281; + }; + +} diff --git a/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java new file mode 100644 index 0000000000..8a1fbde245 --- /dev/null +++ b/uitest/src/com/vaadin/tests/extensions/SetThemeAndResponsiveLayoutTest.java @@ -0,0 +1,76 @@ +/* + * 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.extensions; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.CssLayoutElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class SetThemeAndResponsiveLayoutTest extends MultiBrowserTest { + + @Before + public void setUp() throws Exception { + // We need this in order to ensure that the initial width-range is + // width: 600px- and height: 500px- + testBench().resizeViewPortTo(1024, 768); + } + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // Seems like stylesheet onload is not fired on PhantomJS + // https://github.com/ariya/phantomjs/issues/12332 + return super.getBrowsersExcludingPhantomJS(); + } + + @Test + public void testWidthAndHeightRanges() throws Exception { + openTestURL(); + // IE sometimes has trouble waiting long enough. + new WebDriverWait(getDriver(), 30).until(ExpectedConditions + .presenceOfElementLocated(By + .cssSelector(".v-csslayout-width-and-height"))); + // set the theme programmatically + $(ButtonElement.class).caption("Set theme").first().click(); + new WebDriverWait(getDriver(), 30).until(ExpectedConditions + .presenceOfElementLocated(By.xpath("//div[@width-range]"))); + + // Verify both width-range and height-range. + assertEquals("600px-", + $(CssLayoutElement.class).first().getAttribute("width-range")); + assertEquals("500px-", + $(CssLayoutElement.class).first().getAttribute("height-range")); + + // Resize + testBench().resizeViewPortTo(550, 450); + + // Verify updated width-range and height-range. + assertEquals("0-599px", + $(CssLayoutElement.class).first().getAttribute("width-range")); + assertEquals("0-499px", + $(CssLayoutElement.class).first().getAttribute("height-range")); + } +} |