aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2016-09-08 22:16:08 +0300
committerIlia Motornyi <elmot@vaadin.com>2016-09-12 09:05:41 +0000
commitf5104e34f3167fa2bf05e93272f5b71c15d00071 (patch)
treeeacc80ae807333e764239dd19e468bdafe144ca6 /uitest/src
parent0b4ef8246ba2f026a1c1e1d7264ba2a2fcd9c0fa (diff)
downloadvaadin-framework-f5104e34f3167fa2bf05e93272f5b71c15d00071.tar.gz
vaadin-framework-f5104e34f3167fa2bf05e93272f5b71c15d00071.zip
Update NativeSelect to use DataSource, extend AbstractListing
Selection and focus/blur support not yet implemented. Change-Id: I76752084442216e60055d93367475c1c0a612787
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java14
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java14
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java68
3 files changed, 90 insertions, 6 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
index e9fd2d0c36..6267890535 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java
@@ -3,20 +3,22 @@ package com.vaadin.tests.components.abstractlisting;
import java.util.LinkedHashMap;
import java.util.stream.IntStream;
+import com.vaadin.annotations.Widgetset;
import com.vaadin.tests.components.AbstractComponentTest;
import com.vaadin.ui.AbstractListing;
-public abstract class AbstractListingTestUI<T extends AbstractListing<Object, ?>, V>
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public abstract class AbstractListingTestUI<T extends AbstractListing<Object, ?>>
extends AbstractComponentTest<T> {
@Override
protected void createActions() {
super.createActions();
- createItemsSelect();
- createSelectionSelect();
+ createItemsMenu();
+ createSelectionMenu();
}
- protected void createItemsSelect() {
+ protected void createItemsMenu() {
LinkedHashMap<String, Integer> options = new LinkedHashMap<>();
for (int i = 0; i <= 10; i++) {
options.put(String.valueOf(i), i);
@@ -33,7 +35,7 @@ public abstract class AbstractListingTestUI<T extends AbstractListing<Object, ?>
});
}
- protected void createSelectionSelect() {
+ protected void createSelectionMenu() {
LinkedHashMap<String, String> options = new LinkedHashMap<>();
options.put("None", null);
options.put("Item 0", "Item 0");
@@ -53,7 +55,7 @@ public abstract class AbstractListingTestUI<T extends AbstractListing<Object, ?>
}
protected Object[] createItems(int number) {
- return IntStream.rangeClosed(0, number)
+ return IntStream.range(0, number)
.mapToObj(i -> "Item " + i)
.toArray();
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java b/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java
new file mode 100644
index 0000000000..3338f8156f
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java
@@ -0,0 +1,14 @@
+package com.vaadin.tests.components.nativeselect;
+
+import com.vaadin.tests.components.abstractlisting.AbstractListingTestUI;
+import com.vaadin.ui.NativeSelect;
+
+public class NativeSelects extends
+ AbstractListingTestUI<NativeSelect<Object>> {
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ protected Class<NativeSelect<Object>> getTestClass() {
+ return (Class) NativeSelect.class;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java
new file mode 100644
index 0000000000..ae971630ad
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.nativeselect;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.customelements.NativeSelectElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class NativeSelectTest extends MultiBrowserTest {
+
+ @Before
+ public void setUp() {
+ openTestURL();
+ }
+
+ @Test
+ public void initialLoad_containsCorrectItems() {
+ assertItems(20);
+ }
+
+ @Test
+ public void initialItems_reduceItemCount_containsCorrectItems() {
+ selectMenuPath("Component", "Data source", "Items", "5");
+ assertItems(5);
+ }
+
+ @Test
+ public void initialItems_increaseItemCount_containsCorrectItems() {
+ selectMenuPath("Component", "Data source", "Items", "100");
+ assertItems(100);
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return NativeSelects.class;
+ }
+
+ protected NativeSelectElement getSelect() {
+ return $(NativeSelectElement.class).first();
+ }
+
+ protected void assertItems(int count) {
+ int i = 0;
+ for (TestBenchElement e : getSelect().getOptions()) {
+ assertEquals("Item " + i, e.getText());
+ i++;
+ }
+ assertEquals("Number of items", count, i);
+ }
+}