summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/VTooltip.java8
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java88
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java81
3 files changed, 173 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/VTooltip.java b/client/src/com/vaadin/client/VTooltip.java
index 487f577ae3..1410d1345e 100644
--- a/client/src/com/vaadin/client/VTooltip.java
+++ b/client/src/com/vaadin/client/VTooltip.java
@@ -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
index 0000000000..2c9d43290f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltip.java
@@ -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
index 0000000000..b4bae160b9
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
@@ -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"));
+ }
+}