From 929adacf733d5e685925f143061db7d0450d7b03 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Fri, 17 Jul 2015 11:52:17 +0300 Subject: [PATCH] Convert ComboBoxLargeIconsTest from TB2 to TB4 This patch also adds some subpart awareness as well as deferred worker interface to VFilterSelect to support running TB4 tests reliably. Change-Id: I41f2af38f7eba2194aa49c8d7a0d13073166cddf --- .../com/vaadin/client/ui/VFilterSelect.java | 21 ++- .../combobox/ComboBoxLargeIconsTest.java | 58 +++++++ .../combobox/ComboBoxLargeIcons.html | 152 ------------------ 3 files changed, 74 insertions(+), 157 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/combobox/ComboBoxLargeIconsTest.java delete mode 100644 uitest/tb2/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.html diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java index 1e474d3a1f..8d9e30ac6e 100644 --- a/client/src/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/com/vaadin/client/ui/VFilterSelect.java @@ -65,6 +65,7 @@ import com.vaadin.client.BrowserInfo; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ComputedStyle; import com.vaadin.client.ConnectorMap; +import com.vaadin.client.DeferredWorker; import com.vaadin.client.Focusable; import com.vaadin.client.UIDL; import com.vaadin.client.VConsole; @@ -90,7 +91,7 @@ import com.vaadin.shared.util.SharedUtil; public class VFilterSelect extends Composite implements Field, KeyDownHandler, KeyUpHandler, ClickHandler, FocusHandler, BlurHandler, Focusable, SubPartAware, HandlesAriaCaption, HandlesAriaInvalid, - HandlesAriaRequired { + HandlesAriaRequired, DeferredWorker { /** * Represents a suggestion in the suggestion popup box @@ -417,7 +418,7 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, selectPrevPage(); } else { - if(!menu.getItems().isEmpty()) { + if (!menu.getItems().isEmpty()) { selectLastItem(); } } @@ -2187,11 +2188,15 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, @Override public com.google.gwt.user.client.Element getSubPartElement(String subPart) { - if ("textbox".equals(subPart)) { + String[] parts = subPart.split("/"); + if ("textbox".equals(parts[0])) { return tb.getElement(); - } else if ("button".equals(subPart)) { + } else if ("button".equals(parts[0])) { return popupOpener.getElement(); - } else if ("popup".equals(subPart) && suggestionPopup.isAttached()) { + } else if ("popup".equals(parts[0]) && suggestionPopup.isAttached()) { + if (parts.length == 2) { + return suggestionPopup.menu.getSubPartElement(parts[1]); + } return suggestionPopup.getElement(); } return null; @@ -2235,4 +2240,10 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler, selectPopupItemWhenResponseIsReceived = Select.NONE; } + @Override + public boolean isWorkPending() { + return waitingForFilteringResponse + || suggestionPopup.lazyPageScroller.isRunning(); + } + } diff --git a/uitest/src/com/vaadin/tests/components/combobox/ComboBoxLargeIconsTest.java b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxLargeIconsTest.java new file mode 100644 index 0000000000..407ab7aa04 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/combobox/ComboBoxLargeIconsTest.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.combobox; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.NativeSelectElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import com.vaadin.tests.tb3.newelements.ComboBoxElement; + +public class ComboBoxLargeIconsTest extends MultiBrowserTest { + @Override + protected Class getUIClass() { + return com.vaadin.tests.components.combobox.Comboboxes.class; + } + + @Test + public void testComboBoxIcons() throws Exception { + openTestURL(); + NativeSelectElement iconSelect = $(NativeSelectElement.class).first(); + iconSelect.selectByText("16x16"); + + ComboBoxElement cb = $(ComboBoxElement.class).caption( + "Undefined wide select with 50 items").first(); + cb.openPopup(); + compareScreen("icons-16x16-page1"); + cb.openNextPage(); + compareScreen("icons-16x16-page2"); + cb.findElement(By.vaadin("#popup/item0")).click(); + compareScreen("icons-16x16-selected-1-3-5-9"); + + iconSelect.selectByText("32x32"); + cb.openPopup(); + compareScreen("icons-32x32-page2"); + + // Closes the popup + cb.openPopup(); + + iconSelect.selectByText("64x64"); + + ComboBoxElement pageLength0cb = $(ComboBoxElement.class).caption( + "Pagelength 0").first(); + pageLength0cb.openPopup(); + pageLength0cb.findElement(By.vaadin("#popup/item1")).click(); + + ComboBoxElement cb200px = $(ComboBoxElement.class).caption( + "200px wide select with 50 items").first(); + cb200px.openPopup(); + cb200px.findElement(By.vaadin("#popup/item1")).click(); + + ComboBoxElement cb150px = $(ComboBoxElement.class).caption( + "150px wide select with 5 items").first(); + new Actions(driver).sendKeys(cb150px, Keys.DOWN).perform(); + + compareScreen("icons-64x64-page1-highlight-first"); + } +} diff --git a/uitest/tb2/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.html b/uitest/tb2/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.html deleted file mode 100644 index ff6c82dfdb..0000000000 --- a/uitest/tb2/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.combobox.Comboboxes?restartApplication
selectvaadin=runcomvaadintestscomponentscomboboxComboboxes::PID_Sselectaction-Icon/domChild[0]label=16x16
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VFilterSelect[0]/domChild[1]13,8
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0]116,6
open/run/com.vaadin.tests.components.combobox.Comboboxes?restartApplication
selectvaadin=runcomvaadintestscomponentscomboboxComboboxes::PID_Sselectaction-Icon/domChild[0]label=16x16
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VFilterSelect[0]/domChild[1]13,8
screenCaptureicons-16x16-page1
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::Root/VFilterSelect$SuggestionPopup[0]/domChild[0]/domChild[2]/domChild[0]116,6
screenCaptureicons-16x16-page2
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item0378,1
screenCaptureicons-16x16-selected-1-3-5-9
selectvaadin=runcomvaadintestscomponentscomboboxComboboxes::PID_Sselectaction-Icon/domChild[0]label=32x32
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VFilterSelect[0]/domChild[2]8,13
screenCaptureicons-32x32-page2
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[1]409,27
selectvaadin=runcomvaadintestscomponentscomboboxComboboxes::PID_Sselectaction-Icon/domChild[0]label=64x64
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[9]/VFilterSelect[0]/domChild[1]11,13
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1213,57
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[4]535,43
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[8]/VFilterSelect[0]/domChild[1]7,12
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::Root/VFilterSelect$SuggestionPopup[0]/VFilterSelect$SuggestionMenu[0]#item1158,25
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VFilterSelect[0]/domChild[0]16,9
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VFilterSelect[0]/domChild[0]80,7
pressSpecialKeyvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VFilterSelect[0]/domChild[0]down
screenCaptureicons-64x64-page1-highlight-first
mouseClickvaadin=runcomvaadintestscomponentscomboboxComboboxes::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[6]/domChild[0]510,1
- - -- 2.39.5