diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-03-06 13:03:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 13:03:21 +0200 |
commit | 3397e396dcebb797006f1c4ae8186ea0d422a5f7 (patch) | |
tree | a4192ae4db5ef26c44582daafc0403a88af9ee9c /uitest | |
parent | d9c4969c4c32781cf65c1ea604bc96aecd85bfbf (diff) | |
download | vaadin-framework-3397e396dcebb797006f1c4ae8186ea0d422a5f7.tar.gz vaadin-framework-3397e396dcebb797006f1c4ae8186ea0d422a5f7.zip |
Further tweaks to ComboBox popup positioning. (#11910)
* Further tweaks to ComboBox popup positioning.
- Updated a comment and renamed a private method for better clarity.
- Blocked unnecessary position updates.
- Added a test for #11866 / #11894.
Diffstat (limited to 'uitest')
2 files changed, 67 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayout.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayout.java new file mode 100644 index 0000000000..5c619bafc4 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayout.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.components.combobox; + +import java.util.Arrays; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.HorizontalLayout; + +public class ComboBoxAtBottomEdgeWithinHorizontalLayout extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + ComboBox<Integer> comboBox = new ComboBox<>(); + comboBox.setItems(Arrays.asList(100, 200, 300, 400, 500)); + + HorizontalLayout horizontalLayout = new HorizontalLayout(); + horizontalLayout.addComponent(comboBox); + + getLayout().addComponent(horizontalLayout); + getLayout().setComponentAlignment(horizontalLayout, + Alignment.BOTTOM_RIGHT); + getLayout().setSizeFull(); + getLayout().getParent().setSizeFull(); + } + + @Override + protected Integer getTicketNumber() { + return 11866; + } + + @Override + protected String getTestDescription() { + return "ComboBox at bottom edge should open popup above " + + "even when within HorizontalLayout."; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayoutTest.java new file mode 100644 index 0000000000..f169e56ab5 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxAtBottomEdgeWithinHorizontalLayoutTest.java @@ -0,0 +1,29 @@ +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.MultiBrowserTest; + +public class ComboBoxAtBottomEdgeWithinHorizontalLayoutTest + extends MultiBrowserTest { + + @Test + public void ensurePopupInView() { + openTestURL(); + + ComboBoxElement cb = $(ComboBoxElement.class).first(); + cb.openPopup(); + WebElement popup = cb.getSuggestionPopup(); + + int cbBottom = cb.getLocation().getY() + cb.getSize().getHeight(); + int popupBottom = popup.getLocation().getY() + + popup.getSize().getHeight(); + assertGreaterOrEqual(String.format( + "Popup should not open below the ComboBox at the " + + "bottom edge of the viewport. ComboBox: %s, Popup: %s", + cbBottom, popupBottom), cbBottom, popupBottom); + } + +} |