summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2016-09-05 12:24:20 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2016-09-05 17:06:19 +0300
commit2cafb5f128f718399b112a0c87e9a3d303018371 (patch)
treea67b91151c36480d38009ede17e1ed36855c1748
parentc4a38e2502a6f7ce1cd0487fa95b0b3661de5518 (diff)
downloadvaadin-framework-2cafb5f128f718399b112a0c87e9a3d303018371.tar.gz
vaadin-framework-2cafb5f128f718399b112a0c87e9a3d303018371.zip
Add new base class for Listing UI tests
Change-Id: I6901fc49379d9bd740e24c01de6ce9d530bbc585
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java
new file mode 100644
index 0000000000..e9fd2d0c36
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java
@@ -0,0 +1,60 @@
+package com.vaadin.tests.components.abstractlisting;
+
+import java.util.LinkedHashMap;
+import java.util.stream.IntStream;
+
+import com.vaadin.tests.components.AbstractComponentTest;
+import com.vaadin.ui.AbstractListing;
+
+public abstract class AbstractListingTestUI<T extends AbstractListing<Object, ?>, V>
+ extends AbstractComponentTest<T> {
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ createItemsSelect();
+ createSelectionSelect();
+ }
+
+ protected void createItemsSelect() {
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<>();
+ for (int i = 0; i <= 10; i++) {
+ options.put(String.valueOf(i), i);
+ }
+ options.put("20", 20);
+ options.put("100", 100);
+ options.put("1000", 1000);
+ options.put("10000", 10000);
+ options.put("100000", 100000);
+
+ createSelectAction("Items", "Data source", options, "20",
+ (c, number, data) -> {
+ c.setItems(createItems(number));
+ });
+ }
+
+ protected void createSelectionSelect() {
+ LinkedHashMap<String, String> options = new LinkedHashMap<>();
+ options.put("None", null);
+ options.put("Item 0", "Item 0");
+ options.put("Item 1", "Item 1");
+ options.put("Item 2", "Item 2");
+ options.put("Item 10", "Item 10");
+ options.put("Item 100", "Item 100");
+
+ createSelectAction("Select", "Selection", options, "None",
+ (c, selected, data) -> {
+ if (selected != null) {
+ c.select(selected);
+ } else {
+ c.getSelectedItems().forEach(c::deselect);
+ }
+ });
+ }
+
+ protected Object[] createItems(int number) {
+ return IntStream.rangeClosed(0, number)
+ .mapToObj(i -> "Item " + i)
+ .toArray();
+ }
+}