aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPontus Boström <pontus@vaadin.com>2015-11-20 17:08:44 +0200
committerIlia Motornyi <elmot@vaadin.com>2016-06-23 11:40:03 +0000
commit37ee1f2e7adc62096a3184f09deb1ce4c282da90 (patch)
treef4ddcce7707ae911342bc97ccf6f79cde57f0c10
parentf27a8a9314ba1919c049bad4986f28f77c9ba1af (diff)
downloadvaadin-framework-37ee1f2e7adc62096a3184f09deb1ce4c282da90.tar.gz
vaadin-framework-37ee1f2e7adc62096a3184f09deb1ce4c282da90.zip
Fixed tooltips for sub-windows (#19073)
The subwindows tooltip is now also shown in header and footer of the subwindow. Added also tests for the feature. Change-Id: I4e8fb0eb47355d1c35ccfa9f053f5594a5ffc88a
-rw-r--r--client/src/com/vaadin/client/ui/VWindow.java25
-rw-r--r--uitest/src/com/vaadin/tests/components/window/ToolTipInWindow.java46
-rw-r--r--uitest/src/com/vaadin/tests/components/window/ToolTipInWindowTest.java77
3 files changed, 142 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java
index 737af90b1f..de465f6c1f 100644
--- a/client/src/com/vaadin/client/ui/VWindow.java
+++ b/client/src/com/vaadin/client/ui/VWindow.java
@@ -997,21 +997,35 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
event.preventDefault();
headerDragPending = event;
- } else if ((type == Event.ONMOUSEMOVE || type == Event.ONTOUCHMOVE)
+ bubble = false;
+ } else if (type == Event.ONMOUSEMOVE
&& headerDragPending != null) {
// ie won't work unless this is set here
dragging = true;
onDragEvent(headerDragPending);
onDragEvent(event);
headerDragPending = null;
+ bubble = false;
+ } else if (type != Event.ONMOUSEMOVE) {
+ // The event can propagate to the parent in case it is a
+ // mouse move event. This is needed for tooltips to work in
+ // header and footer, see Ticket #19073
+ headerDragPending = null;
+ bubble = false;
} else {
headerDragPending = null;
}
- bubble = false;
}
if (type == Event.ONCLICK) {
activateOnClick();
}
+ } else if (footer.isOrHasChild(target) && !dragging) {
+ onDragEvent(event);
+ if (type != Event.ONMOUSEMOVE) {
+ // This is needed for tooltips to work in header and footer, see
+ // Ticket #19073
+ bubble = false;
+ }
} else if (dragging || !contents.isOrHasChild(target)) {
onDragEvent(event);
bubble = false;
@@ -1031,11 +1045,10 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner,
if (!bubble) {
event.stopPropagation();
- } else {
- // Super.onBrowserEvent takes care of Handlers added by the
- // ClickEventHandler
- super.onBrowserEvent(event);
}
+ // Super.onBrowserEvent takes care of Handlers added by the
+ // ClickEventHandler
+ super.onBrowserEvent(event);
}
private void activateOnClick() {
diff --git a/uitest/src/com/vaadin/tests/components/window/ToolTipInWindow.java b/uitest/src/com/vaadin/tests/components/window/ToolTipInWindow.java
new file mode 100644
index 0000000000..144b5a0d3f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/ToolTipInWindow.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2015 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.window;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Window;
+
+/**
+ * Test to demonstrate that tooltips are shown for both Window header and
+ * content
+ *
+ * @author Vaadin Ltd
+ */
+public class ToolTipInWindow extends AbstractTestUI {
+
+ Window window;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+
+ window = new Window("Caption", new Label("A label content"));
+ window.setPositionX(300);
+ window.setPositionY(200);
+ window.setWidth("200px");
+ window.setHeight("200px");
+ window.setDescription("Tooltip");
+ addWindow(window);
+
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/window/ToolTipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/ToolTipInWindowTest.java
new file mode 100644
index 0000000000..40332e7730
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/window/ToolTipInWindowTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2000-2015 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.window;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class ToolTipInWindowTest extends MultiBrowserTest {
+
+ @Test
+ public void testToolTipInHeader() throws Exception {
+
+ openTestURL();
+
+ WebElement header = driver.findElement(By
+ .className("v-window-outerheader"));
+ new Actions(driver).moveToElement(
+ driver.findElement(By.className("v-ui")), 0, 0).perform();
+ sleep(500);
+ new Actions(driver).moveToElement(header).perform();
+ sleep(1100);
+
+ WebElement ttip = findElement(By.className("v-tooltip"));
+ assertNotNull(ttip);
+ assertEquals("Tooltip", ttip.getText());
+
+ }
+
+ @Test
+ public void testToolTipInContent() throws Exception {
+
+ openTestURL();
+
+ WebElement header = driver.findElement(By
+ .className("v-window-contents"));
+ new Actions(driver).moveToElement(
+ driver.findElement(By.className("v-ui")), 0, 300).perform();
+ sleep(500);
+ new Actions(driver).moveToElement(header).perform();
+ sleep(1000);
+
+ WebElement ttip = findElement(By.className("v-tooltip"));
+ assertNotNull(ttip);
+ assertEquals("Tooltip", ttip.getText());
+
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // Test with the same browsers as in the other tooltip tests
+ return getBrowsersExcludingIE();
+ }
+
+}