aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-08-25 13:49:00 +0300
committerGitHub <noreply@github.com>2017-08-25 13:49:00 +0300
commitc67f157e4581610a1efd4208c6f7356cc28f51f6 (patch)
tree8e9b7576f88121a4c5f7682fbe50de9b13e73973 /uitest
parent74e8bd248d54a093314a2858eef65ca81248dacd (diff)
downloadvaadin-framework-c67f157e4581610a1efd4208c6f7356cc28f51f6.tar.gz
vaadin-framework-c67f157e4581610a1efd4208c6f7356cc28f51f6.zip
Move ComboBox popup with ComboBox on scroll (#9869)
Keep the ComboBox popup at the same position relative to the ComboBox when the view is scrolled. Fixes #5043
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPopupScrolling.java16
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java28
2 files changed, 40 insertions, 4 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPopupScrolling.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPopupScrolling.java
index 073aea4c95..6178b6e5c3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPopupScrolling.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPopupScrolling.java
@@ -3,27 +3,31 @@ package com.vaadin.tests.components.combobox;
import java.util.ArrayList;
import java.util.List;
+import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+@Widgetset("com.vaadin.DefaultWidgetSet")
public class ComboboxPopupScrolling extends AbstractTestUIWithLog {
@Override
protected void setup(VaadinRequest request) {
- ComboBox combobox = new ComboBox("100px wide combobox");
+ ComboBox<String> combobox = new ComboBox<>("100px wide combobox");
combobox.setWidth("100px");
combobox.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA");
- ComboBox combobox2 = new ComboBox("250px wide combobox");
+ ComboBox<String> combobox2 = new ComboBox<>("250px wide combobox");
combobox2.setWidth("250px");
combobox2.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA");
- ComboBox combobox3 = new ComboBox("Undefined wide combobox");
+ ComboBox<String> combobox3 = new ComboBox<>("Undefined wide combobox");
combobox3.setWidth(null);
combobox3.setItems("AMERICAN SAMOA", "ANTIGUA AND BARBUDA");
- ComboBox combobox4 = new ComboBox("Another 100px wide combobox");
+ ComboBox<String> combobox4 = new ComboBox<>(
+ "Another 100px wide combobox");
combobox4.setWidth("100px");
List<String> items = new ArrayList<>();
for (int i = 0; i < 10; i++) {
@@ -35,6 +39,10 @@ public class ComboboxPopupScrolling extends AbstractTestUIWithLog {
HorizontalLayout hl = new HorizontalLayout(combobox, combobox2,
combobox3, combobox4);
addComponent(hl);
+
+ Label spacer = new Label();
+ spacer.setHeight("800px");
+ addComponent(spacer);
}
} \ No newline at end of file
diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java
index 8e15030231..3a94153eb8 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxPopupScrollingTest.java
@@ -15,11 +15,14 @@
*/
package com.vaadin.tests.components.combobox;
+import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.Point;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.testbench.elements.UIElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class ComboboxPopupScrollingTest extends MultiBrowserTest {
@@ -44,6 +47,31 @@ public class ComboboxPopupScrollingTest extends MultiBrowserTest {
testNoScrollbars("reindeer");
}
+ @Test
+ public void testComboBoxTracksScrolledPage() {
+ openTestURL("theme=valo");
+
+ ComboBoxElement cb = $(ComboBoxElement.class).last();
+ cb.openPopup();
+ WebElement popup = cb.getSuggestionPopup();
+ Point comboLocation = cb.getLocation();
+ Point popupLocation = popup.getLocation();
+
+ // scroll page
+ $(UIElement.class).first().scroll(100);
+
+ // make sure animation frame is handled
+ sleep(500);
+
+ Point newComboLocation = cb.getLocation();
+ Point newPopupLocation = popup.getLocation();
+ Assert.assertNotEquals("ComboBox didn't move on the page", 0,
+ newComboLocation.y - comboLocation.y);
+ Assert.assertEquals("Popup didn't move with the combo box",
+ newComboLocation.y - comboLocation.y,
+ newPopupLocation.y - popupLocation.y);
+ }
+
private void testNoScrollbars(String theme) {
openTestURL("theme=" + theme);