summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2015-09-09 14:22:47 +0300
committerVaadin Code Review <review@vaadin.com>2015-09-09 12:56:23 +0000
commit8b9cb7b88e7bb442c058aa44bad454ad45460fec (patch)
treea06bbeb60625b9569352511f192bcd10530b3ea6 /uitest/src/com/vaadin
parent3356c1e1e439217909f05b1177869a051d5e3a6b (diff)
downloadvaadin-framework-8b9cb7b88e7bb442c058aa44bad454ad45460fec.tar.gz
vaadin-framework-8b9cb7b88e7bb442c058aa44bad454ad45460fec.zip
Implement ItemStyleGenerators for ComboBox (#9276)
Change-Id: I899c21e3f71bc728cb613685134b99961b557c5b
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java57
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxes2.java26
2 files changed, 83 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java
new file mode 100644
index 0000000000..20c460e342
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxItemStyleGeneratorTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.combobox;
+
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ComboBoxItemStyleGeneratorTest extends SingleBrowserTest {
+ @Test
+ public void testItemStyleGenerator() {
+ openTestURL();
+
+ ComboBoxElement comboBox = $(ComboBoxElement.class).first();
+
+ selectMenuPath("Component", "Features", "Item style generator",
+ "Bold fives");
+
+ comboBox.openPopup();
+
+ List<WebElement> boldItems = findElements(By
+ .className("v-filterselect-item-bold"));
+
+ Assert.assertEquals(1, boldItems.size());
+ Assert.assertEquals("Item 5", boldItems.get(0).getText());
+
+ selectMenuPath("Component", "Features", "Item style generator", "-");
+
+ boldItems = findElements(By.className("v-filterselect-item-bold"));
+ Assert.assertEquals(0, boldItems.size());
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return ComboBoxes2.class;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxes2.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxes2.java
index 867ef6b35c..c2ee20cf4a 100644
--- a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxes2.java
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxes2.java
@@ -6,6 +6,7 @@ import com.vaadin.server.Resource;
import com.vaadin.shared.ui.combobox.FilteringMode;
import com.vaadin.tests.components.select.AbstractSelectTestCase;
import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.ComboBox.ItemStyleGenerator;
public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> {
@@ -23,6 +24,13 @@ public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> {
}
};
+ private Command<T, ItemStyleGenerator> itemStyleGeneratorCommand = new Command<T, ItemStyleGenerator>() {
+ @Override
+ public void execute(T c, ItemStyleGenerator value, Object data) {
+ c.setItemStyleGenerator(value);
+ }
+ };
+
@Override
protected Class<T> getTestClass() {
return (Class<T>) ComboBox.class;
@@ -34,6 +42,7 @@ public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> {
createItemIconSelect(CATEGORY_DATA_SOURCE);
createInputPromptAction(CATEGORY_FEATURES);
createFilteringModeAction(CATEGORY_FEATURES);
+ createItemStyleGeneratorAction(CATEGORY_FEATURES);
createNewItemsAllowedAction(CATEGORY_STATE);
createTextInputAlowedAction(CATEGORY_STATE);
}
@@ -69,6 +78,23 @@ public class ComboBoxes2<T extends ComboBox> extends AbstractSelectTestCase<T> {
}
+ private void createItemStyleGeneratorAction(String category) {
+ LinkedHashMap<String, ItemStyleGenerator> options = new LinkedHashMap<String, ItemStyleGenerator>();
+ options.put("-", null);
+ options.put("Bold fives", new ItemStyleGenerator() {
+ @Override
+ public String getStyle(ComboBox source, Object itemId) {
+ if (String.valueOf(itemId).indexOf('5') != -1) {
+ return "bold";
+ } else {
+ return null;
+ }
+ }
+ });
+ createSelectAction("Item style generator", category, options, "-",
+ itemStyleGeneratorCommand);
+ }
+
private void createInputPromptAction(String category) {
LinkedHashMap<String, String> options = new LinkedHashMap<String, String>();
options.put("-", null);