From ffe1e0c022c2098a0b719bffe0c9a707003bde05 Mon Sep 17 00:00:00 2001 From: Adam Wagner Date: Mon, 30 Oct 2017 13:31:27 +0200 Subject: Fix combo box suggestion popup height (#10256) Fixes #10214 --- .../tests/components/combobox/ComboBoxHeight.java | 25 ++++++++++++++ .../tests-valo-combobox-height/_variables.scss | 4 +++ .../themes/tests-valo-combobox-height/styles.scss | 13 ++++++++ .../components/combobox/ComboBoxHeightTest.java | 38 ++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxHeight.java create mode 100644 uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/_variables.scss create mode 100644 uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/styles.scss create mode 100644 uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxHeightTest.java (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxHeight.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxHeight.java new file mode 100644 index 0000000000..ba6956dc22 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxHeight.java @@ -0,0 +1,25 @@ +package com.vaadin.tests.components.combobox; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ComboBox; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class ComboBoxHeight extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + ComboBox comboBox = new ComboBox<>(); + comboBox.setPageLength(0); + comboBox.setItems( + IntStream.range(0, 100) + .mapToObj(i -> "Item number " + String.valueOf(i)) + .collect(Collectors.toList())); + + addComponent(comboBox); + } +} diff --git a/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/_variables.scss b/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/_variables.scss new file mode 100644 index 0000000000..d4c7111398 --- /dev/null +++ b/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/_variables.scss @@ -0,0 +1,4 @@ +$v-selection-overlay-padding-vertical: 10px; +$v-selection-overlay-padding-horizontal: 10px; + +@import "../valo/valo"; diff --git a/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/styles.scss b/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/styles.scss new file mode 100644 index 0000000000..6b3926dcf6 --- /dev/null +++ b/uitest/src/main/themes/VAADIN/themes/tests-valo-combobox-height/styles.scss @@ -0,0 +1,13 @@ +@import "variables"; +@import "../tests-valo/valotest"; + +.tests-valo-combobox-height { + @include valotest; + + .v-filterselect-suggestpopup { + margin-top: 10px !important; + margin-bottom: 10px; + padding-top: 5px; + padding-bottom: 5px; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxHeightTest.java new file mode 100644 index 0000000000..512238b759 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxHeightTest.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.components.combobox; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ComboBoxElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ComboBoxHeightTest extends SingleBrowserTest { + + @Test + public void testPopupHeight() { + openTestURL(); + assertPopupHeight(); + } + + @Test + public void testPopupHeightCustomTheme() { + openTestURL("theme=tests-valo-combobox-height"); + assertPopupHeight(); + } + + private void assertPopupHeight() { + ComboBoxElement comboBox = $(ComboBoxElement.class).first(); + + comboBox.openPopup(); + WebElement suggestionPopup = comboBox.getSuggestionPopup(); + + int suggestionPopupBottom = + suggestionPopup.getLocation().getY() + suggestionPopup.getSize() + .getHeight(); + + assertGreaterOrEqual( + "Combo box suggestion popup should not exceed the browser's viewport", + driver.manage().window().getSize().getHeight(), + suggestionPopupBottom); + } +} -- cgit v1.2.3