summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-09-29 09:19:35 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2016-09-29 12:46:55 +0000
commit599b61bc8598db35fa111880dd4db57f9da2adda (patch)
tree42bde1178019eab0546df58538e20890674fd839 /uitest/src
parentc4b17ca879c0bb51c7da390fcbd25c96b73486fb (diff)
downloadvaadin-framework-599b61bc8598db35fa111880dd4db57f9da2adda.tar.gz
vaadin-framework-599b61bc8598db35fa111880dd4db57f9da2adda.zip
Fix item caption generators in RadioButton/CheckBoxGroup
This patch corrects the behavior of setting caption generators that may return null. Additionally renames RadioButtonGroup's ItemIconProviders to generators, unifying it with other select components. Change-Id: I5e8491834dccce1c37ab9c2002acc475e8945f4b
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java25
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java27
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java13
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java16
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java15
5 files changed, 62 insertions, 34 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java
index fadd94a4be..71fd0fd37d 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java
@@ -1,11 +1,13 @@
package com.vaadin.tests.components.abstractlisting;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.vaadin.shared.data.selection.SelectionModel.Multi;
import com.vaadin.ui.AbstractMultiSelect;
+import com.vaadin.ui.ItemCaptionGenerator;
public abstract class AbstractMultiSelectTestUI<MULTISELECT extends AbstractMultiSelect<Object>>
extends AbstractListingTestUI<MULTISELECT> {
@@ -21,19 +23,18 @@ public abstract class AbstractMultiSelectTestUI<MULTISELECT extends AbstractMult
}
protected void createItemCaptionGeneratorMenu() {
- createBooleanAction("Use Item Caption Generator", "Item Generator",
- false, this::useItemCaptionProvider);
- }
+ LinkedHashMap<String, ItemCaptionGenerator<Object>> options = new LinkedHashMap<>();
+ options.put("Null Caption Generator", item -> null);
+ options.put("Default Caption Generator", item -> item.toString());
+ options.put("Custom Caption Generator",
+ item -> item.toString() + " Caption");
- private void useItemCaptionProvider(MULTISELECT select, boolean activate,
- Object data) {
- if (activate) {
- select.setItemCaptionGenerator(
- item -> item.toString() + " Caption");
- } else {
- select.setItemCaptionGenerator(item -> item.toString());
- }
- select.getDataSource().refreshAll();
+ createSelectAction("Item Caption Generator", "Item Generator", options,
+ "None", (abstractMultiSelect, captionGenerator, data) -> {
+ abstractMultiSelect
+ .setItemCaptionGenerator(captionGenerator);
+ abstractMultiSelect.getDataSource().refreshAll();
+ }, true);
}
protected void createSelectionMenu() {
diff --git a/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java
index 19d9ffd3f3..041c578f1b 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java
@@ -15,10 +15,12 @@
*/
package com.vaadin.tests.components.radiobutton;
+import java.util.LinkedHashMap;
import java.util.stream.IntStream;
import com.vaadin.shared.data.selection.SelectionModel;
import com.vaadin.tests.components.abstractlisting.AbstractListingTestUI;
+import com.vaadin.ui.ItemCaptionGenerator;
import com.vaadin.ui.RadioButtonGroup;
/**
@@ -42,7 +44,7 @@ public class RadioButtonGroupTestUI
super.createActions();
createListenerMenu();
createSelectionMenu();
- createItemProviderMenu();
+ createItemGeneratorMenu();
}
protected void createSelectionMenu() {
@@ -59,19 +61,18 @@ public class RadioButtonGroupTestUI
selectionCategory, toggleSelection, item));
}
- private void createItemProviderMenu() {
- createBooleanAction("Use Item Caption Provider", "Item Provider", false,
- this::useItemCaptionProvider);
- }
+ private void createItemGeneratorMenu() {
+ LinkedHashMap<String, ItemCaptionGenerator<Object>> options = new LinkedHashMap<>();
+ options.put("Null Caption Generator", item -> null);
+ options.put("Default Caption Generator", item -> item.toString());
+ options.put("Custom Caption Generator",
+ item -> item.toString() + " Caption");
- private void useItemCaptionProvider(RadioButtonGroup<Object> group,
- boolean activate, Object data) {
- if (activate) {
- group.setItemCaptionProvider(item -> item.toString() + " Caption");
- } else {
- group.setItemCaptionProvider(item -> item.toString());
- }
- group.getDataSource().refreshAll();
+ createSelectAction("Item Caption Generator", "Item Generator", options,
+ "None", (radioButtonGroup, captionGenerator, data) -> {
+ radioButtonGroup.setItemCaptionGenerator(captionGenerator);
+ radioButtonGroup.getDataSource().refreshAll();
+ }, true);
}
private void toggleSelection(String item) {
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 4bb1defbf6..b4e462a983 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
@@ -123,12 +123,21 @@ public class CheckBoxGroupTest extends MultiBrowserTest {
@Test
public void itemCaptionGenerator() {
- selectMenuPath("Component", "Item Generator",
- "Use Item Caption Generator");
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Custom Caption Generator");
assertItems(20, " Caption");
}
@Test
+ public void nullItemCaptionGenerator() {
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Null Caption Generator");
+ for (String text : getSelect().getOptions()) {
+ Assert.assertEquals("", text);
+ }
+ }
+
+ @Test
public void itemIconGenerator() {
selectMenuPath("Component", "Item Generator",
"Use Item Icon Generator");
diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java
index c909333290..42d912edd6 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java
@@ -112,13 +112,22 @@ public class RadioButtonGroupTest extends MultiBrowserTest {
}
@Test
- public void itemCaptionProvider() {
- selectMenuPath("Component", "Item Provider",
- "Use Item Caption Provider");
+ public void itemCaptionGenerator() {
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Custom Caption Generator");
assertItems(20, " Caption");
}
@Test
+ public void nullItemCaptionGenerator() {
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Null Caption Generator");
+ for (String text : getSelect().getOptions()) {
+ Assert.assertEquals("", text);
+ }
+ }
+
+ @Test
public void selectProgramatically() {
selectMenuPath("Component", "Listeners", "Selection listener");
@@ -162,5 +171,4 @@ public class RadioButtonGroupTest extends MultiBrowserTest {
}
assertEquals("Number of items", count, i);
}
-
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java
index e5f44a405b..ad2752112f 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java
@@ -167,13 +167,22 @@ public class TwinColSelectTest extends MultiBrowserTest {
}
@Test
- public void itemCaptionProvider() {
- selectMenuPath("Component", "Item Generator",
- "Use Item Caption Generator");
+ public void itemCaptionGenerator() {
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Custom Caption Generator");
assertItems(20, " Caption");
}
@Test
+ public void nullItemCaptionGenerator() {
+ selectMenuPath("Component", "Item Generator", "Item Caption Generator",
+ "Null Caption Generator");
+ for (String text : getTwinColSelect().getOptions()) {
+ Assert.assertEquals("", text);
+ }
+ }
+
+ @Test
public void selectProgramatically() {
selectMenuPath("Component", "Listeners", "Selection listener");