diff options
author | Jonni Nakari <jonni@vaadin.com> | 2016-03-30 23:22:14 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-05-31 13:02:42 +0000 |
commit | 68784363dca98529286420206b22a9a8881c70dc (patch) | |
tree | 4d00913073808eee1e1a935b3e4395c9d8ab7d1b /uitest | |
parent | 72c067a2d1913642b4cda591c2f76ad87d7279cb (diff) | |
download | vaadin-framework-68784363dca98529286420206b22a9a8881c70dc.tar.gz vaadin-framework-68784363dca98529286420206b22a9a8881c70dc.zip |
Suggestion pop-up width API for ComboBox (#19685)
Added API setPopupWidth(String) to ComboBox. The suggestion pop-up now
has three different width modes:
1. Legacy "null"-mode: width is determined by the longest item
caption for each page. This looks & feels like the old implementation.
This is the default mode
2. Relative to the ComboBox. e.g. 100%
3. fixed width using any CSS definition
Change-Id: Id60a6996ee82726196b84d50c2d0d18a6cfb5ebf
Diffstat (limited to 'uitest')
8 files changed, 393 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidth.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidth.java new file mode 100644 index 0000000000..86e5b54cb6 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidth.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.components.combobox; + +import java.util.Arrays; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +public class ComboBoxSuggestionPopupWidth extends AbstractTestUI { + + private static List<String> items = Arrays + .asList("abc", + "cde", + "efg", + "ghi", + "ijk", + "more items 1", + "more items 2", + "more items 3", + "Ridicilously long item caption so we can see how the ComboBox displays ridicilously long captions in the suggestion pop-up", + "more items 4", "more items 5", "more items 6", + "more items 7"); + + @Override + protected void setup(VaadinRequest request) { + ComboBox cb = new ComboBox( + "200px wide ComboBox with 100% wide suggestion popup", + items); + cb.setPopupWidth("100%"); + cb.setWidth("200px"); + cb.addStyleName("width-as-percentage"); + addComponent(cb); + + } + + @Override + protected String getTestDescription() { + return "Suggestion pop-up's width should be the same width as the ComboBox itself"; + } + + @Override + protected Integer getTicketNumber() { + return 19685; + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacy.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacy.java new file mode 100644 index 0000000000..091b5f9aab --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacy.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.components.combobox; + +import java.util.Arrays; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +public class ComboBoxSuggestionPopupWidthLegacy extends AbstractTestUI { + + private static List<String> items = Arrays + .asList("abc", + "cde", + "efg", + "ghi", + "ijk", + "more items 1", + "more items 2", + "more items 3", + "Ridicilously long item caption so we can see how the ComboBox displays ridicilously long captions in the suggestion pop-up", + "more items 4", "more items 5", "more items 6", + "more items 7"); + + @Override + protected void setup(VaadinRequest request) { + ComboBox legacy = new ComboBox( + "200px wide ComboBox with legacy mode suggestion popup setPopupWidth(null)", + items); + legacy.addStyleName("legacy"); + legacy.setWidth("200px"); + legacy.setPopupWidth(null); + addComponent(legacy); + + } + + @Override + protected String getTestDescription() { + return "Suggestion pop-up's width should respect the item captions width"; + } + + @Override + protected Integer getTicketNumber() { + return 19685; + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentage.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentage.java new file mode 100644 index 0000000000..1ddc666a44 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentage.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.components.combobox; + +import java.util.Arrays; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +public class ComboBoxSuggestionPopupWidthPercentage extends AbstractTestUI { + + private static List<String> items = Arrays + .asList("abc", + "cde", + "efg", + "ghi", + "ijk", + "more items 1", + "more items 2", + "more items 3", + "Ridicilously long item caption so we can see how the ComboBox displays ridicilously long captions in the suggestion pop-up", + "more items 4", "more items 5", "more items 6", + "more items 7"); + + @Override + protected void setup(VaadinRequest request) { + ComboBox percentage = new ComboBox( + "200px wide ComboBox with 200% wide suggestion popup", items); + percentage.addStyleName("percentage"); + percentage.setWidth("200px"); + percentage.setPopupWidth("200%"); + addComponent(percentage); + + } + + @Override + protected String getTestDescription() { + return "Suggestion pop-up's width should be 200% of the ComboBox itself (400px)"; + } + + @Override + protected Integer getTicketNumber() { + return 19685; + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixels.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixels.java new file mode 100644 index 0000000000..623f4c904f --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixels.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.components.combobox; + +import java.util.Arrays; +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +public class ComboBoxSuggestionPopupWidthPixels extends AbstractTestUI { + + private static List<String> items = Arrays + .asList("abc", + "cde", + "efg", + "ghi", + "ijk", + "more items 1", + "more items 2", + "more items 3", + "Ridicilously long item caption so we can see how the ComboBox displays ridicilously long captions in the suggestion pop-up", + "more items 4", "more items 5", "more items 6", + "more items 7"); + + @Override + protected void setup(VaadinRequest request) { + ComboBox pixels = new ComboBox( + "200px wide ComboBox with 300px wide suggestion popup", items); + pixels.addStyleName("pixels"); + pixels.setWidth("200px"); + pixels.setPopupWidth("300px"); + addComponent(pixels); + + } + + @Override + protected String getTestDescription() { + return "Suggestion pop-up's width should 300px"; + } + + @Override + protected Integer getTicketNumber() { + return 19685; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacyTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacyTest.java new file mode 100644 index 0000000000..d18dd68bd5 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthLegacyTest.java @@ -0,0 +1,52 @@ +/* + * 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 org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + */ +public class ComboBoxSuggestionPopupWidthLegacyTest extends MultiBrowserTest { + + @Test + public void suggestionPopupLegacyWidthTest() throws Exception { + openTestURL(); + + waitForElementVisible(By.className("legacy")); + + WebElement selectTextbox = $(ComboBoxElement.class).first() + .findElement(By.vaadin("#textbox")); + selectTextbox.click(); + + CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); + cb.openPopup(); + WebElement popup = cb.getSuggestionPopup(); + + int width = popup.getSize().getWidth(); + assertGreater("Legacy mode popup should be quite wide", width, 600); + assertLessThan( + "Even legacy mode popup should not be over 1000px wide with the set item captions ", + width, 1000); + + } + +}; diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentageTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentageTest.java new file mode 100644 index 0000000000..2e5dcb380e --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPercentageTest.java @@ -0,0 +1,52 @@ +/* + * 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 static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + */ +public class ComboBoxSuggestionPopupWidthPercentageTest extends + MultiBrowserTest { + + @Test + public void suggestionPopupPersentageWidthTest() throws Exception { + openTestURL(); + + waitForElementVisible(By.className("percentage")); + + WebElement selectTextbox = $(ComboBoxElement.class).first() + .findElement(By.vaadin("#textbox")); + selectTextbox.click(); + + CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); + cb.openPopup(); + WebElement popup = cb.getSuggestionPopup(); + + int width = popup.getSize().getWidth(); + assertTrue(width == 400); + + } + +}; diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixelsTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixelsTest.java new file mode 100644 index 0000000000..f5a0d9dc52 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthPixelsTest.java @@ -0,0 +1,51 @@ +/* + * 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 static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + */ +public class ComboBoxSuggestionPopupWidthPixelsTest extends MultiBrowserTest { + + @Test + public void suggestionPopupFixedWidthTest() throws Exception { + openTestURL(); + + waitForElementVisible(By.className("pixels")); + + WebElement selectTextbox = $(ComboBoxElement.class).first() + .findElement(By.vaadin("#textbox")); + selectTextbox.click(); + + CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); + cb.openPopup(); + WebElement popup = cb.getSuggestionPopup(); + + int width = popup.getSize().getWidth(); + assertTrue(width == 300); + + } + +}; diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthTest.java new file mode 100644 index 0000000000..11e7629b2d --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSuggestionPopupWidthTest.java @@ -0,0 +1,52 @@ +/* + * 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 static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + */ +public class ComboBoxSuggestionPopupWidthTest extends MultiBrowserTest { + + @Test + public void suggestionPopupWidthTest() throws Exception { + openTestURL(); + + waitForElementVisible(By + .className("width-as-percentage")); + + WebElement selectTextbox = $(ComboBoxElement.class).first() + .findElement(By.vaadin("#textbox")); + selectTextbox.click(); + + CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); + cb.openPopup(); + WebElement popup = cb.getSuggestionPopup(); + + int width = popup.getSize().getWidth(); + assertTrue(width == 200); + + } + +}; |