aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-04-26 11:12:01 +0300
committerHenri Sara <henri.sara@gmail.com>2017-04-26 11:12:01 +0300
commita48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69 (patch)
tree9965868a6606c4ab56f9ec55b8e9090eefcef9f9 /uitest/src
parent2e5b49113439310d2dae9ec86fca3ccdf74833f5 (diff)
downloadvaadin-framework-a48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69.tar.gz
vaadin-framework-a48e5a1cb8f6c8ae18af19406d3e7ba3c9886c69.zip
Add an option for defining number of visible items in a NativeSelect (#9109)
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java19
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java42
2 files changed, 61 insertions, 0 deletions
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
index 34b78089bb..2f67f78304 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/nativeselect/NativeSelects.java
@@ -1,5 +1,7 @@
package com.vaadin.tests.components.nativeselect;
+import java.util.LinkedHashMap;
+
import com.vaadin.tests.components.abstractlisting.AbstractSingleSelectTestUI;
import com.vaadin.ui.NativeSelect;
@@ -18,4 +20,21 @@ public class NativeSelects
component.setEmptySelectionAllowed(false);
return component;
}
+
+ @Override
+ protected void createActions() {
+ super.createActions();
+ LinkedHashMap<String, Integer> options = new LinkedHashMap<>();
+ options.put("1", 1);
+ options.put("2", 2);
+ options.put("5", 5);
+ createSelectAction("Visible item count", CATEGORY_SIZE, options, "1",
+ new Command<NativeSelect<Object>, Integer>() {
+ @Override
+ public void execute(NativeSelect<Object> c, Integer value,
+ Object data) {
+ c.setVisibleItemCount(value);
+ }
+ });
+ }
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java
new file mode 100644
index 0000000000..95af50e55d
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectVisibleItemCountTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.NativeSelectElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class NativeSelectVisibleItemCountTest extends SingleBrowserTest {
+
+ @Test
+ public void changeItemCount() {
+ openTestURL();
+ WebElement select = $(NativeSelectElement.class).first()
+ .findElement(By.xpath("select"));
+ Assert.assertEquals("1", select.getAttribute("size"));
+ selectMenuPath("Component", "Size", "Visible item count", "5");
+ Assert.assertEquals("5", select.getAttribute("size"));
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return NativeSelects.class;
+ }
+}