]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix menu item tooltips showing up too early (#13914)
authorJuuso Valli <juuso@vaadin.com>
Mon, 2 Jun 2014 14:28:49 +0000 (17:28 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 3 Jun 2014 13:32:53 +0000 (13:32 +0000)
Change-Id: Id324ed06e45e73a9383667e86651ea794c3ff322

client/src/com/vaadin/client/VTooltip.java
uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java [new file with mode: 0644]

index 487f577ae3ce0021f116547ddb418b161471adf6..1410d1345e47cc59611bae4ea048a5b195f663b4 100644 (file)
@@ -234,8 +234,10 @@ public class VTooltip extends VWindowOverlay {
             // already about to close
             return;
         }
-        closeTimer.schedule(getCloseTimeout());
-        closing = true;
+        if (isActuallyVisible()) {
+            closeTimer.schedule(getCloseTimeout());
+            closing = true;
+        }
     }
 
     @Override
@@ -348,8 +350,6 @@ public class VTooltip extends VWindowOverlay {
         /**
          * Handle hide event
          * 
-         * @param event
-         *            Event causing hide
          */
         private void handleHideEvent() {
             hideTooltip();
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java
new file mode 100644 (file)
index 0000000..2c9d432
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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.menubar;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.MenuBar;
+import com.vaadin.ui.MenuBar.Command;
+import com.vaadin.ui.MenuBar.MenuItem;
+
+/**
+ * Test to see if tooltips on menu items obscure other items on the menu.
+ * 
+ * @author Vaadin Ltd
+ */
+public class MenuTooltip extends AbstractTestUI {
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+     * VaadinRequest)
+     */
+    @Override
+    protected void setup(VaadinRequest request) {
+
+        addComponent(buildMenu());
+
+        getTooltipConfiguration().setOpenDelay(2000);
+
+    }
+
+    private Component buildMenu() {
+        MenuBar menu = new MenuBar();
+        MenuItem item = menu.addItem("Menu", null);
+
+        item.addItem("Item 1", null).setDescription("TOOLTIP 1");
+        item.addItem("Item 2", null).setDescription("TOOLTIP 2");
+        item.addItem("Item 3", null).setDescription("TOOLTIP 3");
+        item.addItem("Item 4", null).setDescription("TOOLTIP 4");
+
+        return menu;
+    }
+
+    private Command buildCommand() {
+        Command command = new Command() {
+
+            @Override
+            public void menuSelected(MenuItem selectedItem) {
+
+            }
+        };
+        return command;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+     */
+    @Override
+    protected String getTestDescription() {
+        return "Menu item tooltips should not abscure other menu items";
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+     */
+    @Override
+    protected Integer getTicketNumber() {
+        return 13914;
+    }
+}
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
new file mode 100644 (file)
index 0000000..b4bae16
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * 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.menubar;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.HasInputDevices;
+import org.openqa.selenium.interactions.Mouse;
+import org.openqa.selenium.interactions.internal.Coordinates;
+import org.openqa.selenium.internal.Locatable;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.elements.MenuBarElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to see if tooltips on menu items obscure other items on the menu.
+ * 
+ * @author Vaadin Ltd
+ */
+public class MenuTooltipTest extends MultiBrowserTest {
+
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        List<DesiredCapabilities> browsers = super.getBrowsersToTest();
+        browsers.remove(Browser.IE8.getDesiredCapabilities());
+        browsers.remove(Browser.IE9.getDesiredCapabilities());
+        browsers.remove(Browser.IE10.getDesiredCapabilities());
+        browsers.remove(Browser.IE11.getDesiredCapabilities());
+        return browsers;
+    };
+
+    @Test
+    public void testToolTipDelay() throws InterruptedException {
+        openTestURL();
+
+        Coordinates elementCoordinates = ((Locatable) $(MenuBarElement.class)
+                .first().getWrappedElement()).getCoordinates();
+
+        Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
+
+        mouse.click(elementCoordinates);
+        mouse.mouseMove(elementCoordinates, 15, 40);
+
+        sleep(1000);
+
+        assertThat(getTooltipElement().getLocation().getX(),
+                is(lessThan(-1000)));
+
+        sleep(3000);
+
+        assertThat(getTooltipElement().getLocation().getX(),
+                is(greaterThan(elementCoordinates.onPage().getX())));
+        assertThat(getTooltipElement().getText(), is("TOOLTIP 1"));
+    }
+
+    private WebElement getTooltipElement() {
+        return getDriver().findElement(By.className("v-tooltip-text"));
+    }
+}