diff options
author | Artur Signell <artur@vaadin.com> | 2014-04-23 20:45:14 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-04-23 20:45:39 +0300 |
commit | 41cb27e85f61f5abb029a98af66217ce400b2196 (patch) | |
tree | 609df412869abde48131079d45b2981bcb210744 /uitest | |
parent | 9f30eb285252348c349e9a759ac71098eb74a06a (diff) | |
parent | 0d4080ba5e5931fa928675ba6c95540e34b2f281 (diff) | |
download | vaadin-framework-41cb27e85f61f5abb029a98af66217ce400b2196.tar.gz vaadin-framework-41cb27e85f61f5abb029a98af66217ce400b2196.zip |
Merge changes from origin/7.1
0d4080b ContainerEventProvider returns style names from container. Fixes #10718
6e91bdf Add test for TransactionalPropertyWrapper memory leaks
f0aaf89 Fixed resetting of ComboBox if focused and new items allowed (#13413).
e033fcd Always initialize WebBrowser for new sessions (#13571)
168de1f Revert "Drag image for text-area should contain text of text-area (#13557)"
35e2a34 Fix FieldGroup and TransactionalPropertyWrapper memory leaks (#13438)
7e5d44d Introduce a drag threshold for Drag and Drop (#13381)
f227f0c Drag image for text-area should contain text of text-area (#13557).
Change-Id: Idb01471f8ab0c7118fa884c364e6bc200d13948a
Diffstat (limited to 'uitest')
4 files changed, 215 insertions, 5 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowed.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowed.java new file mode 100644 index 0000000000..c0ac5cc392 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowed.java @@ -0,0 +1,61 @@ +/* + * 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.components.combobox; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.Label; + +public class ComboBoxSetNullWhenNewItemsAllowed extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + final ComboBox comboBox = new ComboBox("My ComboBox"); + comboBox.setImmediate(true); + comboBox.setNullSelectionAllowed(false); + comboBox.setNewItemsAllowed(true); + for (int i = 0; i < 10; i++) { + comboBox.addItem("Item " + i); + } + + final Label value = new Label("Selected: "); + + comboBox.addValueChangeListener(new Property.ValueChangeListener() { + @Override + public void valueChange(ValueChangeEvent event) { + if (comboBox.getValue() != null) { + comboBox.setValue(null); + value.setValue("Selected: " + (String) comboBox.getValue()); + } + } + }); + addComponent(comboBox); + addComponent(value); + } + + @Override + protected String getTestDescription() { + return "ComboBox should clear its value when setting to null with new items."; + } + + @Override + protected Integer getTicketNumber() { + return 13413; + } +} diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java new file mode 100644 index 0000000000..1794b9865f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxSetNullWhenNewItemsAllowedTest.java @@ -0,0 +1,55 @@ +/* + * 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.components.combobox; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * ComboBox should clear its value when setting to null with new items. + */ +public class ComboBoxSetNullWhenNewItemsAllowedTest extends MultiBrowserTest { + + @Test + public void testNewValueIsClearedAppropriately() + throws InterruptedException { + setDebug(true); + openTestURL(); + Thread.sleep(1000); + + WebElement element = findElement(); + ((TestBenchElementCommands) element).click(8, 7); + element.clear(); + element.sendKeys("New value"); + assertEquals("New value", element.getAttribute("value")); + element.sendKeys(Keys.RETURN); + assertEquals("", element.getAttribute("value")); + } + + private WebElement findElement() { + return getDriver() + .findElement( + By.vaadin("runcomvaadintestscomponentscomboboxComboBoxSetNullWhenNewItemsAllowed::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VFilterSelect[0]#textbox")); + } + +} diff --git a/uitest/src/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java b/uitest/src/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java new file mode 100644 index 0000000000..9147d0fe50 --- /dev/null +++ b/uitest/src/com/vaadin/tests/requesthandlers/UnsupportedBrowserHandlerUserAgents.java @@ -0,0 +1,76 @@ +/* + * 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.requesthandlers; + +import java.net.HttpURLConnection; +import java.net.URL; + +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.PrivateTB3Configuration; + +public class UnsupportedBrowserHandlerUserAgents { + /* + * This test doesn't use testbench, but it's still in the uitest source + * folder since it should be run with the testing server deployed. + */ + + @Test + public void ie7NotSupported() { + String response = requestWithUserAgent("Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727)"); + Assert.assertTrue("IE7 should not be supported", + response.contains("your browser is not supported")); + } + + @Test + public void ie9Supported() { + String response = requestWithUserAgent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)"); + Assert.assertFalse("IE9 should be supported", + response.contains("your browser is not supported")); + } + + @Test + public void unknownSupported() { + String response = requestWithUserAgent("Very strange user agent, like wat"); + Assert.assertFalse("Unkonwn user agent should be supported", + response.contains("your browser is not supported")); + } + + private String requestWithUserAgent(String userAgent) { + try { + String url = "http://" + + PrivateTB3Configuration.getConfiguredDeploymentHostname() + + ":" + + PrivateTB3Configuration.getConfiguredDeploymentPort() + + "/run/" + + com.vaadin.tests.components.ui.UIInitTest.class.getName() + + "/"; + + HttpURLConnection connection = (HttpURLConnection) new URL(url) + .openConnection(); + connection.setRequestProperty("User-Agent", userAgent); + + String response = IOUtils.toString(connection.getInputStream()); + connection.disconnect(); + + return response; + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java index a00ff7ab4d..97150f96ab 100644 --- a/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java +++ b/uitest/src/com/vaadin/tests/tb3/PrivateTB3Configuration.java @@ -25,6 +25,7 @@ import java.net.SocketException; import java.util.Enumeration; import java.util.Properties; +import org.apache.commons.io.IOUtils; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxBinary; @@ -44,9 +45,8 @@ import com.vaadin.testbench.TestBench; public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { private static final String HOSTNAME_PROPERTY = "com.vaadin.testbench.deployment.hostname"; private static final String PORT_PROPERTY = "com.vaadin.testbench.deployment.port"; - private final Properties properties = new Properties(); - - public PrivateTB3Configuration() { + private static final Properties properties = new Properties(); + static { File file = new File("work", "eclipse-run-selected-test.properties"); if (file.exists()) { try { @@ -57,7 +57,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { } } - private String getProperty(String name) { + private static String getProperty(String name) { String property = properties.getProperty(name); if (property == null) { property = System.getProperty(name); @@ -86,6 +86,15 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { if (getClass().getAnnotation(RunLocally.class) != null) { return "localhost"; } + return getConfiguredDeploymentHostname(); + } + + /** + * Gets the hostname that tests are configured to use. + * + * @return the host name configuration value + */ + public static String getConfiguredDeploymentHostname() { String hostName = getProperty(HOSTNAME_PROPERTY); if (hostName == null || "".equals(hostName)) { @@ -97,6 +106,15 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { @Override protected int getDeploymentPort() { + return getConfiguredDeploymentPort(); + } + + /** + * Gets the port that tests are configured to use. + * + * @return the port configuration value + */ + public static int getConfiguredDeploymentPort() { String portString = getProperty(PORT_PROPERTY); int port = 8888; @@ -115,7 +133,7 @@ public abstract class PrivateTB3Configuration extends ScreenshotTB3Test { * @throws RuntimeException * if there was an error or no IP was found */ - private String findAutoHostname() { + private static String findAutoHostname() { try { Enumeration<NetworkInterface> interfaces = NetworkInterface .getNetworkInterfaces(); |