summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-08-23 14:02:20 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2017-08-23 14:02:20 +0300
commitf09d8c74dfb44854b4982a0b54de8564ff324d00 (patch)
tree12e4406c9372dd322a00a2b475b30382a9a6d8cf /uitest
parent139c4cf40b6e914df65ec474d5a8523849489e24 (diff)
downloadvaadin-framework-f09d8c74dfb44854b4982a0b54de8564ff324d00.tar.gz
vaadin-framework-f09d8c74dfb44854b4982a0b54de8564ff324d00.zip
Add item description to RadioButtonGroup and CheckBoxGroup (#9841)
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java19
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java17
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java23
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java23
4 files changed, 82 insertions, 0 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 88006fd68a..71c3a6147f 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
@@ -15,10 +15,13 @@
*/
package com.vaadin.tests.components.checkbox;
+import java.util.LinkedHashMap;
+
import com.vaadin.icons.VaadinIcons;
import com.vaadin.tests.components.abstractlisting.AbstractMultiSelectTestUI;
import com.vaadin.ui.CheckBoxGroup;
import com.vaadin.ui.IconGenerator;
+import com.vaadin.ui.components.grid.DescriptionGenerator;
/**
* Test UI for CheckBoxGroup component
@@ -49,6 +52,7 @@ public class CheckBoxGroupTestUI
protected void createActions() {
super.createActions();
createItemIconGenerator();
+ createItemDescriptionGeneratorMenu();
}
private void createItemIconGenerator() {
@@ -56,6 +60,21 @@ public class CheckBoxGroupTestUI
this::useItemIconProvider);
}
+ private void createItemDescriptionGeneratorMenu() {
+ LinkedHashMap<String, DescriptionGenerator<Object>> options = new LinkedHashMap<>();
+ options.put("Null Description Generator", item -> null);
+ options.put("Default Description Generator", item -> item.toString());
+ options.put("Custom Description Generator",
+ item -> item.toString() + " Description");
+
+ createSelectAction("Item Description Generator",
+ "Item Description Generator", options, "None",
+ (checkBoxGroup, generator, data) -> {
+ checkBoxGroup.setItemDescriptionGenerator(generator);
+ checkBoxGroup.getDataProvider().refreshAll();
+ }, true);
+ }
+
private void useItemIconProvider(CheckBoxGroup<Object> group,
boolean activate, Object data) {
if (activate) {
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 20314fd347..d9161a6a46 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
@@ -22,6 +22,7 @@ import com.vaadin.icons.VaadinIcons;
import com.vaadin.tests.components.abstractlisting.AbstractListingTestUI;
import com.vaadin.ui.ItemCaptionGenerator;
import com.vaadin.ui.RadioButtonGroup;
+import com.vaadin.ui.components.grid.DescriptionGenerator;
/**
* Test UI for RadioButtonGroup component
@@ -46,6 +47,7 @@ public class RadioButtonGroupTestUI
createSelectionMenu();
createItemIconGeneratorMenu();
createItemCaptionGeneratorMenu();
+ createItemDescriptionGeneratorMenu();
}
protected void createSelectionMenu() {
@@ -92,6 +94,21 @@ public class RadioButtonGroupTestUI
}, true);
}
+ private void createItemDescriptionGeneratorMenu() {
+ LinkedHashMap<String, DescriptionGenerator<Object>> options = new LinkedHashMap<>();
+ options.put("Null Description Generator", item -> null);
+ options.put("Default Description Generator", item -> item.toString());
+ options.put("Custom Description Generator",
+ item -> item.toString() + " Description");
+
+ createSelectAction("Item Description Generator",
+ "Item Description Generator", options, "None",
+ (radioButtonGroup, generator, data) -> {
+ radioButtonGroup.setItemDescriptionGenerator(generator);
+ radioButtonGroup.getDataProvider().refreshAll();
+ }, true);
+ }
+
private void toggleSelection(String item) {
if (getComponent().isSelected(item)) {
getComponent().setValue(null);
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 5d7c37c754..98d9cc03e5 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
@@ -33,6 +33,7 @@ import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.icons.VaadinIcons;
+import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.CheckBoxGroupElement;
import com.vaadin.tests.components.checkbox.CheckBoxGroupTestUI;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -195,6 +196,28 @@ public class CheckBoxGroupTest extends MultiBrowserTest {
assertSelected("Item 1");
}
+ @Test
+ public void testItemDescriptionGenerators() {
+ TestBenchElement label;
+
+ selectMenuPath("Component", "Item Description Generator",
+ "Item Description Generator", "Default Description Generator");
+
+ label = (TestBenchElement) findElements(By.tagName("label")).get(5);
+ label.showTooltip();
+ Assert.assertEquals("Tooltip should contain the same text as caption",
+ label.getText(), getTooltipElement().getText());
+
+ selectMenuPath("Component", "Item Description Generator",
+ "Item Description Generator", "Custom Description Generator");
+
+ label = (TestBenchElement) findElements(By.tagName("label")).get(5);
+ label.showTooltip();
+ Assert.assertEquals("Tooltip should contain caption + ' Description'",
+ label.getText() + " Description",
+ getTooltipElement().getText());
+ }
+
private void assertSelected(String... expectedSelection) {
Assert.assertEquals(Arrays.asList(expectedSelection),
getSelect().getValue());
diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java
index 2c53903d29..6c0b60be78 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java
@@ -27,6 +27,7 @@ import org.openqa.selenium.WebElement;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.testbench.By;
+import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.RadioButtonGroupElement;
import com.vaadin.tests.components.radiobutton.RadioButtonGroupTestUI;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -189,6 +190,28 @@ public class RadioButtonGroupTest extends MultiBrowserTest {
assertSelected("Item 5");
}
+ @Test
+ public void testItemDescriptionGenerators() {
+ TestBenchElement label;
+
+ selectMenuPath("Component", "Item Description Generator",
+ "Item Description Generator", "Default Description Generator");
+
+ label = (TestBenchElement) findElements(By.tagName("label")).get(5);
+ label.showTooltip();
+ Assert.assertEquals("Tooltip should contain the same text as caption",
+ label.getText(), getTooltipElement().getText());
+
+ selectMenuPath("Component", "Item Description Generator",
+ "Item Description Generator", "Custom Description Generator");
+
+ label = (TestBenchElement) findElements(By.tagName("label")).get(5);
+ label.showTooltip();
+ Assert.assertEquals("Tooltip should contain caption + ' Description'",
+ label.getText() + " Description",
+ getTooltipElement().getText());
+ }
+
private void assertSelected(String expectedSelection) {
Assert.assertEquals(expectedSelection, getSelect().getValue());
}