aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/select
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-09-25 10:27:51 +0300
committerVaadin Code Review <review@vaadin.com>2014-12-12 10:52:12 +0000
commitdfaaae821ebea039dae6923c7433673b719dd42d (patch)
tree534bfada76561bff06890b8c8fb67948f743ab23 /uitest/src/com/vaadin/tests/components/select
parent10fa4e4236ed049ef6eac337d23701bc381763ce (diff)
downloadvaadin-framework-dfaaae821ebea039dae6923c7433673b719dd42d.tar.gz
vaadin-framework-dfaaae821ebea039dae6923c7433673b719dd42d.zip
Use converter for Select/Tree/ComboBox when using item id for caption
(#11433) Change-Id: I10c47986b98e132e874b2882fbb2323409d67a25
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/select')
-rw-r--r--uitest/src/com/vaadin/tests/components/select/EnumSelect.java69
-rw-r--r--uitest/src/com/vaadin/tests/components/select/EnumSelectTest.java61
2 files changed, 130 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/select/EnumSelect.java b/uitest/src/com/vaadin/tests/components/select/EnumSelect.java
new file mode 100644
index 0000000000..5976952f8c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/select/EnumSelect.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2014 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.select;
+
+import java.util.Locale;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.combobox.FilteringMode;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.NativeSelect;
+import com.vaadin.ui.Tree;
+
+public class EnumSelect extends AbstractTestUIWithLog {
+
+ public enum Constant {
+ SOME_VALUE, SOME_OTHER_VALUE, FOO, BAR;
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ setLocale(new Locale("fi", "FI"));
+ ComboBox cb = new ComboBox();
+ cb.setFilteringMode(FilteringMode.CONTAINS);
+ for (Constant c : Constant.values()) {
+ cb.addItem(c);
+ }
+ addComponent(cb);
+
+ NativeSelect ns = new NativeSelect();
+ for (Constant c : Constant.values()) {
+ ns.addItem(c);
+ }
+ addComponent(ns);
+
+ Tree t = new Tree();
+ t.addItem(Constant.SOME_OTHER_VALUE);
+ t.addItem(2500.12);
+ t.setParent(2500.12, Constant.SOME_OTHER_VALUE);
+
+ addComponent(t);
+
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test formatting captions with enum converters in selection components";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11433;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/select/EnumSelectTest.java b/uitest/src/com/vaadin/tests/components/select/EnumSelectTest.java
new file mode 100644
index 0000000000..c0429baa31
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/select/EnumSelectTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2014 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.select;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.TestBenchElement;
+import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.testbench.elements.NativeSelectElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class EnumSelectTest extends SingleBrowserTest {
+
+ @Test
+ public void enumInNativeSelect() {
+ openTestURL();
+ NativeSelectElement ns = $(NativeSelectElement.class).first();
+ List<TestBenchElement> options = ns.getOptions();
+ Assert.assertEquals("Some value", options.get(1).getText());
+ Assert.assertEquals("Some other value", options.get(2).getText());
+ }
+
+ @Test
+ public void enumInComboBox() {
+ openTestURL();
+ ComboBoxElement cb = $(ComboBoxElement.class).first();
+ cb.openPopup();
+ List<String> options = cb.getPopupSuggestions();
+ Assert.assertEquals("Some value", options.get(1));
+ Assert.assertEquals("Some other value", options.get(2));
+ }
+
+ @Test
+ public void enumInComboBoxFiltering() {
+ openTestURL();
+ ComboBoxElement cb = $(ComboBoxElement.class).first();
+ cb.findElement(By.vaadin("#textbox")).sendKeys(" other ");
+ List<String> options = cb.getPopupSuggestions();
+ Assert.assertEquals("Only one item should match filter", 1,
+ options.size());
+ Assert.assertEquals("Invalid option matched filter",
+ "Some other value", options.get(0));
+ }
+}