summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAntti Tanhuanpää <antti@vaadin.com>2014-06-30 17:07:50 +0300
committerVaadin Code Review <review@vaadin.com>2014-07-28 11:53:51 +0000
commit28702c006fe124988c03c99eea4e2d609407e47e (patch)
tree5232db1537cb4b049dcbe27b39ef0d5970251a2b /uitest/src
parent9b19675dffec603bc7e8fe6d973ed4edafaff136 (diff)
downloadvaadin-framework-28702c006fe124988c03c99eea4e2d609407e47e.tar.gz
vaadin-framework-28702c006fe124988c03c99eea4e2d609407e47e.zip
Add scrollbars to ComboBox suggestion popup if low on screen estate (#11929)
Change-Id: Idfeb20a385fc68c6527f1947bdbf238d9d4af918
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java76
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java84
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/fi.pngbin0 -> 25094 bytes
-rw-r--r--uitest/src/com/vaadin/tests/components/combobox/fi_small.pngbin0 -> 3576 bytes
4 files changed, 160 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java
new file mode 100644
index 0000000000..044214cecf
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreen.java
@@ -0,0 +1,76 @@
+/*
+ * 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 com.vaadin.data.Item;
+import com.vaadin.server.ClassResource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.ComboBox;
+
+/**
+ * Test UI for issue #11929 where ComboBox suggestion popup hides the ComboBox
+ * itself obscuring the text input field.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComboBoxOnSmallScreen extends AbstractTestUI {
+
+ private static final String PID = "captionPID";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ addComponents(createComboBox());
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Combobox hides what you are typing on small screen";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11929;
+ }
+
+ private ComboBox createComboBox() {
+ ComboBox cb = new ComboBox();
+ cb.addContainerProperty(PID, String.class, "");
+ cb.setItemCaptionPropertyId(PID);
+
+ Object selectId = null;
+
+ for (int i = 1; i < 22; ++i) {
+ final String v = "Item #" + i;
+ Object itemId = cb.addItem();
+
+ if (i == 9) {
+ selectId = itemId;
+ }
+
+ Item item = cb.getItem(itemId);
+ item.getItemProperty(PID).setValue(v);
+ int flagIndex = i % 3;
+ cb.setItemIcon(itemId, new ClassResource(
+ flagIndex == 0 ? "fi_small.png" : flagIndex == 1 ? "fi.gif"
+ : "se.gif"));
+ }
+
+ cb.select(selectId);
+
+ return cb;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java
new file mode 100644
index 0000000000..f48f2bbdeb
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxOnSmallScreenTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebDriver.Window;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.client.ui.VFilterSelect;
+import com.vaadin.testbench.elements.ComboBoxElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * ComboBox suggestion popup should not obscure the text input box.
+ *
+ * @author Vaadin Ltd
+ */
+public class ComboBoxOnSmallScreenTest extends MultiBrowserTest {
+
+ private static final Dimension TARGETSIZE = new Dimension(600, 300);
+ private static final String POPUPCLASSNAME = VFilterSelect.CLASSNAME
+ + "-suggestpopup";
+
+ ComboBoxElement combobox;
+ WebElement popup;
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+
+ openTestURL();
+
+ getWindow().setSize(TARGETSIZE);
+
+ combobox = $(ComboBoxElement.class).first();
+ combobox.openPopup();
+
+ popup = findElement(By.className(POPUPCLASSNAME));
+ }
+
+ @Test
+ public void testSuggestionPopupOverlayPosition() {
+ final int popupTop = popup.getLocation().y;
+ final int popupBottom = popupTop + popup.getSize().getHeight();
+ final int cbTop = combobox.getLocation().y;
+ final int cbBottom = cbTop + combobox.getSize().getHeight();
+
+ assertThat("Popup overlay overlaps with the textbox",
+ popupTop >= cbBottom || popupBottom <= cbTop, is(true));
+ }
+
+ @Test
+ public void testSuggestionPopupOverlaySize() {
+ final int popupTop = popup.getLocation().y;
+ final int popupBottom = popupTop + popup.getSize().getHeight();
+ final int rootHeight = findElement(By.tagName("body")).getSize().height;
+
+ assertThat("Popup overlay out of the screen", popupTop < 0
+ || popupBottom > rootHeight, is(false));
+ }
+
+ private Window getWindow() {
+ return getDriver().manage().window();
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/combobox/fi.png b/uitest/src/com/vaadin/tests/components/combobox/fi.png
new file mode 100644
index 0000000000..976a9663ce
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/fi.png
Binary files differ
diff --git a/uitest/src/com/vaadin/tests/components/combobox/fi_small.png b/uitest/src/com/vaadin/tests/components/combobox/fi_small.png
new file mode 100644
index 0000000000..2908973fa4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/combobox/fi_small.png
Binary files differ