From 0b4ef8246ba2f026a1c1e1d7264ba2a2fcd9c0fa Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Thu, 8 Sep 2016 22:10:31 +0300 Subject: Move old NativeSelect UI tests to compatibility package Change-Id: I7d426de488747ce323e732f7ad45d30712fc6d61 --- .../components/nativeselect/NativeSelectNull.java | 25 ------- .../components/nativeselect/NativeSelects.java | 18 ----- .../components/nativeselect/NativeSelectNull.java | 25 +++++++ .../components/nativeselect/NativeSelects.java | 18 +++++ .../nativeselect/NativeSelectNullTest.java | 19 ----- ...tiveSelectsAndChromeKeyboardNavigationTest.java | 81 --------------------- .../NativeSelectsFocusAndBlurListenerTests.java | 77 -------------------- .../nativeselect/NativeSelectNullTest.java | 19 +++++ ...tiveSelectsAndChromeKeyboardNavigationTest.java | 82 ++++++++++++++++++++++ .../NativeSelectsFocusAndBlurListenerTests.java | 78 ++++++++++++++++++++ 10 files changed, 222 insertions(+), 220 deletions(-) delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelectNull.java delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java create mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNull.java create mode 100644 uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelects.java delete mode 100644 uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectNullTest.java delete mode 100644 uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java delete mode 100644 uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java create mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java create mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java create mode 100644 uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelectNull.java b/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelectNull.java deleted file mode 100644 index 62b6c541fc..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelectNull.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.vaadin.tests.components.nativeselect; - -import com.vaadin.server.VaadinRequest; -import com.vaadin.tests.components.AbstractTestUIWithLog; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.NativeSelect; - -public class NativeSelectNull extends AbstractTestUIWithLog { - @Override - protected void setup(VaadinRequest request) { - NativeSelect nativeSelect = new NativeSelect(); - nativeSelect.addItem("Item"); - nativeSelect.addValueChangeListener(new ValueChangeListener() { - - @Override - public void valueChange(ValueChangeEvent event) { - log("Value: " + event.getProperty().getValue()); - - } - }); - addComponent(nativeSelect); - } - -} diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java b/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java deleted file mode 100644 index 74c1d7c466..0000000000 --- a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.vaadin.tests.components.nativeselect; - -import com.vaadin.tests.components.select.AbstractSelectTestCase; -import com.vaadin.v7.ui.NativeSelect; - -public class NativeSelects extends AbstractSelectTestCase { - - @Override - protected Class getTestClass() { - return NativeSelect.class; - } - - @Override - protected void createActions() { - super.createActions(); - } - -} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNull.java b/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNull.java new file mode 100644 index 0000000000..ca49170ecb --- /dev/null +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNull.java @@ -0,0 +1,25 @@ +package com.vaadin.v7.tests.components.nativeselect; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.v7.data.Property.ValueChangeEvent; +import com.vaadin.v7.data.Property.ValueChangeListener; +import com.vaadin.v7.ui.NativeSelect; + +public class NativeSelectNull extends AbstractTestUIWithLog { + @Override + protected void setup(VaadinRequest request) { + NativeSelect nativeSelect = new NativeSelect(); + nativeSelect.addItem("Item"); + nativeSelect.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + log("Value: " + event.getProperty().getValue()); + + } + }); + addComponent(nativeSelect); + } + +} diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelects.java b/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelects.java new file mode 100644 index 0000000000..bb84e88d46 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/v7/tests/components/nativeselect/NativeSelects.java @@ -0,0 +1,18 @@ +package com.vaadin.v7.tests.components.nativeselect; + +import com.vaadin.tests.components.select.AbstractSelectTestCase; +import com.vaadin.v7.ui.NativeSelect; + +public class NativeSelects extends AbstractSelectTestCase { + + @Override + protected Class getTestClass() { + return NativeSelect.class; + } + + @Override + protected void createActions() { + super.createActions(); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectNullTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectNullTest.java deleted file mode 100644 index 7a687cbaaa..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectNullTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.vaadin.tests.components.nativeselect; - -import org.junit.Assert; -import org.junit.Test; - -import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; -import com.vaadin.v7.testbench.customelements.NativeSelectElement; - -public class NativeSelectNullTest extends SingleBrowserTestPhantomJS2 { - @Test - public void selectNull() { - openTestURL(); - NativeSelectElement select = $(NativeSelectElement.class).first(); - select.selectByText("Item"); - Assert.assertEquals("1. Value: Item", getLogRow(0)); - select.selectByText(""); - Assert.assertEquals("2. Value: null", getLogRow(0)); - } -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java deleted file mode 100644 index d3bece6a73..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2000-2016 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.nativeselect; - -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.testbench.parallel.Browser; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class NativeSelectsAndChromeKeyboardNavigationTest - extends MultiBrowserTest { - - @Override - public List getBrowsersToTest() { - return getBrowserCapabilities(Browser.CHROME); - } - - @Test - public void testValueChangeListenerWithKeyboardNavigation() - throws InterruptedException { - setDebug(true); - openTestURL(); - Thread.sleep(1000); - menu("Component"); - menuSub("Listeners"); - menuSub("Value change listener"); - - getDriver().findElement(By.tagName("body")).click(); - - WebElement select = getDriver().findElement(By.tagName("select")); - select.sendKeys(Keys.ARROW_DOWN); - select.sendKeys(Keys.ARROW_DOWN); - select.sendKeys(Keys.ARROW_DOWN); - - String bodytext = getDriver().findElement(By.tagName("body")).getText(); - - Assert.assertTrue(bodytext.contains("new value: 'Item 1'")); - Assert.assertTrue(bodytext.contains("new value: 'Item 2'")); - Assert.assertTrue(bodytext.contains("new value: 'Item 3'")); - - } - - @Override - protected Class getUIClass() { - return NativeSelects.class; - } - - private void menuSub(String string) { - getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) - .click(); - new Actions(getDriver()).moveByOffset(100, 0).build().perform(); - } - - private void menu(String string) { - getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) - .click(); - - } - -} diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java deleted file mode 100644 index cd45f553f4..0000000000 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2000-2016 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.nativeselect; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.parallel.BrowserUtil; -import com.vaadin.tests.tb3.MultiBrowserTest; -import com.vaadin.v7.testbench.customelements.NativeSelectElement; - -public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest { - - @Test - public void testFocusAndBlurListener() throws InterruptedException { - setDebug(true); - openTestURL(); - Thread.sleep(200); - menu("Component"); - menuSub("Listeners"); - menuSub("Focus listener"); - menu("Component"); - menuSub("Listeners"); - menuSub("Blur listener"); - - findElement(By.tagName("body")).click(); - - NativeSelectElement s = $(NativeSelectElement.class).first(); - s.selectByText("Item 3"); - getDriver().findElement(By.tagName("body")).click(); - - // 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)); - } - - } - - @Override - protected Class getUIClass() { - return NativeSelects.class; - } - - private void menuSub(String string) { - getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) - .click(); - new Actions(getDriver()).moveByOffset(100, 0).build().perform(); - } - - private void menu(String string) { - getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) - .click(); - - } - -} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java new file mode 100644 index 0000000000..cb33b9e93f --- /dev/null +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectNullTest.java @@ -0,0 +1,19 @@ +package com.vaadin.v7.tests.components.nativeselect; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.tests.tb3.SingleBrowserTestPhantomJS2; +import com.vaadin.v7.testbench.customelements.NativeSelectElement; + +public class NativeSelectNullTest extends SingleBrowserTestPhantomJS2 { + @Test + public void selectNull() { + openTestURL(); + NativeSelectElement select = $(NativeSelectElement.class).first(); + select.selectByText("Item"); + Assert.assertEquals("1. Value: Item", getLogRow(0)); + select.selectByText(""); + Assert.assertEquals("2. Value: null", getLogRow(0)); + } +} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java new file mode 100644 index 0000000000..ce85f7aa46 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsAndChromeKeyboardNavigationTest.java @@ -0,0 +1,82 @@ +/* + * Copyright 2000-2016 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.v7.tests.components.nativeselect; + +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.testbench.parallel.Browser; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.v7.tests.components.nativeselect.NativeSelects; + +public class NativeSelectsAndChromeKeyboardNavigationTest + extends MultiBrowserTest { + + @Override + public List getBrowsersToTest() { + return getBrowserCapabilities(Browser.CHROME); + } + + @Test + public void testValueChangeListenerWithKeyboardNavigation() + throws InterruptedException { + setDebug(true); + openTestURL(); + Thread.sleep(1000); + menu("Component"); + menuSub("Listeners"); + menuSub("Value change listener"); + + getDriver().findElement(By.tagName("body")).click(); + + WebElement select = getDriver().findElement(By.tagName("select")); + select.sendKeys(Keys.ARROW_DOWN); + select.sendKeys(Keys.ARROW_DOWN); + select.sendKeys(Keys.ARROW_DOWN); + + String bodytext = getDriver().findElement(By.tagName("body")).getText(); + + Assert.assertTrue(bodytext.contains("new value: 'Item 1'")); + Assert.assertTrue(bodytext.contains("new value: 'Item 2'")); + Assert.assertTrue(bodytext.contains("new value: 'Item 3'")); + + } + + @Override + protected Class getUIClass() { + return NativeSelects.class; + } + + private void menuSub(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + new Actions(getDriver()).moveByOffset(100, 0).build().perform(); + } + + private void menu(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + + } + +} diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java new file mode 100644 index 0000000000..d0d9bcbe3d --- /dev/null +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/nativeselect/NativeSelectsFocusAndBlurListenerTests.java @@ -0,0 +1,78 @@ +/* + * Copyright 2000-2016 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.v7.tests.components.nativeselect; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.parallel.BrowserUtil; +import com.vaadin.tests.components.nativeselect.NativeSelects; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.v7.testbench.customelements.NativeSelectElement; + +public class NativeSelectsFocusAndBlurListenerTests extends MultiBrowserTest { + + @Test + public void testFocusAndBlurListener() throws InterruptedException { + setDebug(true); + openTestURL(); + Thread.sleep(200); + menu("Component"); + menuSub("Listeners"); + menuSub("Focus listener"); + menu("Component"); + menuSub("Listeners"); + menuSub("Blur listener"); + + findElement(By.tagName("body")).click(); + + NativeSelectElement s = $(NativeSelectElement.class).first(); + s.selectByText("Item 3"); + getDriver().findElement(By.tagName("body")).click(); + + // 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)); + } + + } + + @Override + protected Class getUIClass() { + return NativeSelects.class; + } + + private void menuSub(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + new Actions(getDriver()).moveByOffset(100, 0).build().perform(); + } + + private void menu(String string) { + getDriver().findElement(By.xpath("//span[text() = '" + string + "']")) + .click(); + + } + +} -- cgit v1.2.3