diff options
author | Artur <artur@vaadin.com> | 2017-04-13 10:52:19 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-04-13 09:52:19 +0200 |
commit | 22c39d36f81a6d37f729d67135487ef10cb8dc5a (patch) | |
tree | f4697f175a44753e59ae47be00c3f72cd3bf21c6 /uitest | |
parent | 71e4d797fe6a3629f9e489b06e2566e139577bfd (diff) | |
download | vaadin-framework-22c39d36f81a6d37f729d67135487ef10cb8dc5a.tar.gz vaadin-framework-22c39d36f81a6d37f729d67135487ef10cb8dc5a.zip |
Correctly set ListSelect style names
Fixes #8901
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectStyleNames.java | 55 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java | 92 |
2 files changed, 147 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectStyleNames.java b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectStyleNames.java new file mode 100644 index 0000000000..9e9ee78dd4 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectStyleNames.java @@ -0,0 +1,55 @@ +/* + * 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.listselect; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.ListSelect; +import com.vaadin.ui.NativeSelect; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class ListSelectStyleNames extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + ListSelect<String> testselect = new ListSelect<>(); + testselect.setItems("abc", "def", "ghi"); + testselect.addStyleName("custominitial"); + addComponent(testselect); + + NativeSelect<String> nativeSelect = new NativeSelect<>(); + nativeSelect.setItems("abc", "def", "ghi"); + nativeSelect.addStyleName("custominitial"); + addComponent(nativeSelect); + + Button button = new Button("Add style 'new'", e -> { + testselect.addStyleName("new"); + nativeSelect.addStyleName("new"); + }); + button.setId("add"); + addComponent(button); + + button = new Button("Change primary style to 'newprimary'", e -> { + testselect.setPrimaryStyleName("newprimary"); + nativeSelect.setPrimaryStyleName("newprimary"); + }); + button.setId("changeprimary"); + addComponent(button); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java new file mode 100644 index 0000000000..7e032ba94b --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectStyleNamesTest.java @@ -0,0 +1,92 @@ +/* + * 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.listselect; + +import java.util.Arrays; +import java.util.HashSet; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.ListSelectElement; +import com.vaadin.testbench.elements.NativeSelectElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ListSelectStyleNamesTest extends SingleBrowserTest { + + private NativeSelectElement nativeSelect; + private TestBenchElement nativeSelectSelect; + private ListSelectElement listSelect; + private TestBenchElement listSelectSelect; + + @Override + public void setup() throws Exception { + super.setup(); + openTestURL(); + nativeSelect = $(NativeSelectElement.class).first(); + nativeSelectSelect = (TestBenchElement) nativeSelect + .findElement(By.xpath("select")); + + listSelect = $(ListSelectElement.class).first(); + listSelectSelect = (TestBenchElement) listSelect + .findElement(By.xpath("select")); + + } + + @Test + public void correctInitialStyleNames() { + assertStyleNames(nativeSelect, "v-select", "v-widget", "custominitial", + "v-select-custominitial"); + assertStyleNames(nativeSelectSelect, "v-select-select"); + assertStyleNames(listSelect, "v-select", "v-widget", "custominitial", + "v-select-custominitial"); + assertStyleNames(listSelectSelect, "v-select-select"); + } + + @Test + public void addStyleName() { + $(ButtonElement.class).id("add").click(); + assertStyleNames(nativeSelect, "v-select", "v-widget", "custominitial", + "v-select-custominitial", "new", "v-select-new"); + assertStyleNames(nativeSelectSelect, "v-select-select"); + assertStyleNames(listSelect, "v-select", "v-widget", "custominitial", + "v-select-custominitial", "new", "v-select-new"); + assertStyleNames(listSelectSelect, "v-select-select"); + } + + @Test + public void changePrimaryStyleName() { + $(ButtonElement.class).id("add").click(); + $(ButtonElement.class).id("changeprimary").click(); + assertStyleNames(nativeSelect, "newprimary", "v-widget", + "custominitial", "newprimary-custominitial", "new", + "newprimary-new"); + assertStyleNames(nativeSelectSelect, "newprimary"); + assertStyleNames(listSelect, "newprimary", "v-widget", "custominitial", + "newprimary-custominitial", "new", "newprimary-new"); + assertStyleNames(listSelectSelect, "newprimary-select"); + + } + + private void assertStyleNames(TestBenchElement element, + String... styleNames) { + Assert.assertEquals(new HashSet<>(Arrays.asList(styleNames)), + element.getClassNames()); + } +} |