diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-03-24 11:03:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-24 11:03:16 +0200 |
commit | e7abf49988534a231ffb5e2ed23eceb7f5f986b9 (patch) | |
tree | be12edd642c18bb5e9f067a984dea43bba992eca /uitest | |
parent | e5240607490d8d2f68683139df9c8dee14b66b27 (diff) | |
download | vaadin-framework-e7abf49988534a231ffb5e2ed23eceb7f5f986b9.tar.gz vaadin-framework-e7abf49988534a231ffb5e2ed23eceb7f5f986b9.zip |
Further tweaks to ComboBox popup positioning. (#11910) (#11921)
* 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); + } + +} |