summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-05-05 10:46:38 +0300
committerGitHub <noreply@github.com>2020-05-05 10:46:38 +0300
commit1dcf3dc338fc5587575211d0463721e85b586691 (patch)
tree1903c25b319a4392de6367ff4a6cbbac0842219f /uitest
parent35e441f2ecf19b779fb99ccc58d658dc29c03d80 (diff)
downloadvaadin-framework-1dcf3dc338fc5587575211d0463721e85b586691.tar.gz
vaadin-framework-1dcf3dc338fc5587575211d0463721e85b586691.zip
Take overlays into account in getConnectorForElement. (#11980)
* Take overlays into account in getConnectorForElement. Fixes #11212
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/tooltip/NestedOverlayTooltip.java120
-rw-r--r--uitest/src/test/java/com/vaadin/tests/tooltip/NestedOverlayTooltipTest.java73
2 files changed, 193 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/tooltip/NestedOverlayTooltip.java b/uitest/src/main/java/com/vaadin/tests/tooltip/NestedOverlayTooltip.java
new file mode 100644
index 0000000000..9dd23e8dd4
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/tooltip/NestedOverlayTooltip.java
@@ -0,0 +1,120 @@
+package com.vaadin.tests.tooltip;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.MenuItem;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class NestedOverlayTooltip extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Button openWindowButton = createOpenWindowButton();
+ PopupView openPopUpViewLink = createOpenPopUpViewButton();
+
+ MenuBar menuBar = new MenuBar();
+ MenuItem menuItem = menuBar.addItem("First item");
+ MenuItem firstDropdownItem = menuItem.addItem("Dropdown item");
+ firstDropdownItem.setDescription("Dropdown Item tooltip");
+
+ addComponents(openWindowButton, openPopUpViewLink, menuBar);
+ }
+
+ private Button createOpenWindowButton() {
+ Button openWindowButton = new Button("Open window");
+ openWindowButton.setDescription("Button tooltip");
+ openWindowButton.addClickListener(event -> {
+ Window window = new Window();
+ window.center();
+ window.setWidth("500px");
+ window.setHeight("500px");
+
+ Button openInnerWindowButton = new Button("Open inner window");
+ openInnerWindowButton.setDescription("Button tooltip");
+ openInnerWindowButton.addClickListener(innerEvent -> {
+ Window innerWindow = new Window();
+ innerWindow.center();
+ innerWindow.setWidth("400px");
+ innerWindow.setHeight("400px");
+
+ Button dummyButton = new Button(
+ "This button doesn't do a thing");
+ dummyButton.setDescription("DummyButton tooltip");
+
+ MenuBar innerWindowMenuBar = new MenuBar();
+ innerWindowMenuBar.setDescription("MenuBar tooltip");
+ MenuItem menuItem = innerWindowMenuBar
+ .addItem("First item in inner window");
+ MenuItem firstDropdownItem = menuItem
+ .addItem("Inner window dropdown item");
+ firstDropdownItem
+ .setDescription("Inner window dropdown item tooltip");
+
+ innerWindow.setContent(
+ new VerticalLayout(dummyButton, innerWindowMenuBar));
+ addWindow(innerWindow);
+ });
+
+ MenuBar windowMenuBar = new MenuBar();
+ windowMenuBar.setDescription("MenuBar tooltip");
+ MenuItem menuItem = windowMenuBar.addItem("First item in window");
+ MenuItem firstDropdownItem = menuItem
+ .addItem("Window dropdown item");
+ firstDropdownItem.setDescription("Window dropdown item tooltip");
+
+ window.setContent(
+ new VerticalLayout(openInnerWindowButton, windowMenuBar));
+ addWindow(window);
+ });
+ return openWindowButton;
+ }
+
+ private PopupView createOpenPopUpViewButton() {
+ PopupView dummyView = new PopupView("Open empty popupView",
+ new VerticalLayout());
+ dummyView.setDescription("This dummy popupView has no content");
+
+ MenuBar innerPopupMenuBar = new MenuBar();
+ innerPopupMenuBar.setDescription("MenuBar tooltip");
+ MenuItem innerPopupMenuItem = innerPopupMenuBar
+ .addItem("First item in inner popupView");
+ MenuItem firstDropdownInnerPopupItem = innerPopupMenuItem
+ .addItem("Inner popupView dropdown item");
+ firstDropdownInnerPopupItem
+ .setDescription("Inner popupView dropdown item tooltip");
+
+ PopupView innerView = new PopupView("Open inner popupView",
+ new VerticalLayout(dummyView, innerPopupMenuBar));
+ innerView.setDescription("This inner popupView has content");
+
+ MenuBar popupMenuBar = new MenuBar();
+ popupMenuBar.setDescription("MenuBar tooltip");
+ MenuItem popupMenuItem = popupMenuBar
+ .addItem("First item in popupView");
+ MenuItem firstDropdownPopupItem = popupMenuItem
+ .addItem("PopupView dropdown item");
+ firstDropdownPopupItem
+ .setDescription("PopupView dropdown item tooltip");
+
+ PopupView popupView = new PopupView("Open popupView",
+ new VerticalLayout(innerView, innerView, popupMenuBar));
+ popupView.setDescription("This popupView has content");
+ return popupView;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "MenuItem's tooltip should be visible even when "
+ + "the MenuBar is located within a Window, PopupView, "
+ + "or some other component that extends VOverlay";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11212;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/tooltip/NestedOverlayTooltipTest.java b/uitest/src/test/java/com/vaadin/tests/tooltip/NestedOverlayTooltipTest.java
new file mode 100644
index 0000000000..c8c5bc1eac
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/tooltip/NestedOverlayTooltipTest.java
@@ -0,0 +1,73 @@
+package com.vaadin.tests.tooltip;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.PopupViewElement;
+import com.vaadin.testbench.elements.UIElement;
+import com.vaadin.testbench.elements.WindowElement;
+import com.vaadin.tests.tb3.TooltipTest;
+
+public class NestedOverlayTooltipTest extends TooltipTest {
+
+ @Override
+ public void setup() throws Exception {
+ super.setup();
+ openTestURL();
+ }
+
+ private void openDropDownAndTestTooltip(WebElement base, String firstItem,
+ String tooltip) throws Exception {
+ WebElement menuBar = base.findElement(By.className("v-menubar"));
+ menuBar.findElement(By.vaadin("#" + firstItem)).click();
+ WebElement popup = findElement(By.className("v-menubar-popup"));
+ WebElement item = popup.findElement(By.className("v-menubar-menuitem"));
+ checkTooltip(item, tooltip);
+ }
+
+ @Test
+ public void testMenuItemTooltip() throws Exception {
+ UIElement ui = $(UIElement.class).first();
+ openDropDownAndTestTooltip(ui, "First item", "Dropdown Item tooltip");
+ }
+
+ @Test
+ public void testMenuItemTooltipWithinWindow() throws Exception {
+ $(ButtonElement.class).first().click();
+ WindowElement window = $(WindowElement.class).first();
+ openDropDownAndTestTooltip(window, "First item in window",
+ "Window dropdown item tooltip");
+ }
+
+ @Test
+ public void testMenuItemTooltipWithinNestedWindow() throws Exception {
+ $(ButtonElement.class).first().click();
+ WindowElement window = $(WindowElement.class).first();
+ window.$(ButtonElement.class).first().click();
+ WindowElement subWindow = $(WindowElement.class).get(1);
+ openDropDownAndTestTooltip(subWindow, "First item in inner window",
+ "Inner window dropdown item tooltip");
+ }
+
+ @Test
+ public void testMenuItemTooltipWithinPopupView() throws Exception {
+ $(PopupViewElement.class).first().click();
+ WebElement popup = findElement(By.className("v-popupview-popup"));
+ openDropDownAndTestTooltip(popup, "First item in popupView",
+ "PopupView dropdown item tooltip");
+ }
+
+ @Test
+ public void testMenuItemTooltipWithinNestedPopupView() throws Exception {
+ $(PopupViewElement.class).first().click();
+ WebElement popup = findElement(By.className("v-popupview-popup"));
+ popup.findElement(By.className("v-popupview")).click();
+ WebElement innerPopup = findElements(By.className("v-popupview-popup"))
+ .get(1);
+ openDropDownAndTestTooltip(innerPopup, "First item in inner popupView",
+ "Inner popupView dropdown item tooltip");
+ }
+
+}