diff options
author | elmot <elmot@vaadin.com> | 2016-09-14 12:13:14 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-09-19 05:44:39 +0000 |
commit | edd8b9bd16a33fe6be3e5082c953aaf374884070 (patch) | |
tree | 30ff2f28aeee9411068a562b03a6e1b9e3e15740 /uitest | |
parent | 05c051717401660a857ee7a314361a1735f376e6 (diff) | |
download | vaadin-framework-edd8b9bd16a33fe6be3e5082c953aaf374884070.tar.gz vaadin-framework-edd8b9bd16a33fe6be3e5082c953aaf374884070.zip |
Test and fix a CheckBoxGroup icon provider and item enabled provider
Change-Id: Ia3ed99478d19efc041cc4adaabd856ee69f3531b
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java | 11 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java | 40 |
2 files changed, 50 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java index fef23f56d3..e8af72bfa6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java @@ -37,6 +37,17 @@ public class CheckBoxGroupTestUI return (Class) CheckBoxGroup.class; } + + @Override + protected CheckBoxGroup<Object> constructComponent() { + CheckBoxGroup<Object> checkBoxGroup = super.constructComponent(); + checkBoxGroup.setItemIconProvider( + item -> "Item 2".equals(item) ? ICON_16_HELP_PNG_CACHEABLE : + null); + checkBoxGroup.setItemEnabledProvider(item -> !"Item 10".equals(item)); + return checkBoxGroup; + } + @Override protected void createActions() { super.createActions(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index 9a8f631594..087ab55b6c 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -1,6 +1,6 @@ /* * 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 @@ -26,6 +26,16 @@ import org.junit.Test; import com.vaadin.testbench.customelements.CheckBoxGroupElement; import com.vaadin.tests.components.checkbox.CheckBoxGroupTestUI; import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Before; +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Test for CheckBoxGroup @@ -113,4 +123,32 @@ public class CheckBoxGroupTest extends MultiBrowserTest { } assertEquals("Number of items", count, i); } + + @Test + public void testDisabled() { + List<String> optionsCssClasses = getSelect().getOptionsCssClasses(); + for (int i = 0; i < optionsCssClasses.size(); i++) { + String cssClassList = optionsCssClasses.get(i); + if (i == 10) { + assertTrue("10th item should be disabled", + cssClassList.toLowerCase().contains("disabled")); + } else { + assertFalse("Only 10th item should be disabled", + cssClassList.toLowerCase().contains("disabled")); + } + } + } + + @Test + public void testIconUrl() { + List<String> optionsIcons = getSelect().getOptionsIconUrls(); + for (int i = 0; i < optionsIcons.size(); i++) { + String icon = optionsIcons.get(i); + if (i == 2) { + assertNotNull("2nd item should have icon", icon); + } else { + assertNull("Only 2nd item should have icon", icon); + } + } + } } |