aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java7
-rw-r--r--uitest/src/com/vaadin/tests/components/select/EnumSelect.java69
-rw-r--r--uitest/src/com/vaadin/tests/components/select/EnumSelectTest.java61
3 files changed, 135 insertions, 2 deletions
diff --git a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java
index 6b517e9887..252efe2824 100644
--- a/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java
+++ b/uitest/src/com/vaadin/tests/components/notification/NotificationsWaiAriaTest.java
@@ -19,6 +19,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.WebElement;
+import com.vaadin.data.util.converter.StringToEnumConverter;
import com.vaadin.shared.ui.ui.NotificationRole;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
@@ -57,7 +58,8 @@ public class NotificationsWaiAriaTest extends MultiBrowserTest {
postfix.clear();
postfix.sendKeys("- press ESC to close");
- type.selectByText(NotificationRole.ALERT.toString());
+ type.selectByText(StringToEnumConverter.enumToString(
+ NotificationRole.ALERT, null));
show.click();
waitForElementPresent(By.className("v-Notification"));
@@ -83,7 +85,8 @@ public class NotificationsWaiAriaTest extends MultiBrowserTest {
} catch (Exception e) {
}
- type.selectByText("STATUS");
+ type.selectByText(StringToEnumConverter.enumToString(
+ NotificationRole.STATUS, null));
show.click();
waitForElementPresent(By.className("v-Notification"));
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));
+ }
+}