summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorJuuso Valli <juuso@vaadin.com>2014-06-12 15:43:37 +0300
committerVaadin Code Review <review@vaadin.com>2014-06-17 04:49:27 +0000
commitf455b391b76b1a2ad9169c5308645ad9764505ec (patch)
treeaee74d43e9e2cb5618bbf4b36078dca517683a31 /uitest/src/com/vaadin
parentdc08a1c857d75e964a47842f4a2a9538878457b9 (diff)
downloadvaadin-framework-f455b391b76b1a2ad9169c5308645ad9764505ec.tar.gz
vaadin-framework-f455b391b76b1a2ad9169c5308645ad9764505ec.zip
Delay tooltips when moving between adjacent elements (#13998)
Change-Id: Ia0845c9439e22ecece0825aaad521e900153fc81
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java82
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java75
2 files changed, 157 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java
new file mode 100644
index 0000000000..60167e43b4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltips.java
@@ -0,0 +1,82 @@
+/*
+ * 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.tooltip;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TooltipConfiguration;
+
+/**
+ * When moving between adjacent elements, the tooltip replace should obey
+ * quickOpenDelay
+ *
+ * @author Vaadin Ltd
+ */
+public class AdjacentElementsWithTooltips extends AbstractTestUI {
+
+ private int buttonCount = 0;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+ * VaadinRequest)
+ */
+ @Override
+ protected void setup(VaadinRequest request) {
+ TooltipConfiguration ttc = super.getTooltipConfiguration();
+ ttc.setMaxWidth(350);
+ ttc.setOpenDelay(200);
+ ttc.setCloseTimeout(200);
+ ttc.setQuickOpenDelay(1000);
+ ttc.setQuickOpenTimeout(1000);
+ HorizontalLayout layout = new HorizontalLayout();
+ layout.addComponent(makeButton("first"));
+ layout.addComponent(makeButton("second"));
+ addComponent(layout);
+
+ }
+
+ private Component makeButton(String tooltip) {
+ Button button = new Button("Button " + buttonCount++);
+ button.setDescription(tooltip);
+ return button;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
+ */
+ @Override
+ protected String getTestDescription() {
+ return "Moving between adjacent elements with tooltips should open quickOpenDelay";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
+ */
+ @Override
+ protected Integer getTicketNumber() {
+ return 13998;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java
new file mode 100644
index 0000000000..b9fc788008
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/AdjacentElementsWithTooltipsTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.tooltip;
+
+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.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.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to see if tooltips obey quickOpenDelay when moving between directly
+ * adjacent elements.
+ *
+ * @author Vaadin Ltd
+ */
+public class AdjacentElementsWithTooltipsTest extends MultiBrowserTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return getBrowsersExcludingIE();
+ }
+
+ @Test
+ public void tooltipsHaveQuickOpenDelay() throws InterruptedException {
+ openTestURL();
+ Coordinates button0Coordinates = getButtonCoordinates("Button 0");
+ Coordinates button1Coordinates = getButtonCoordinates("Button 1");
+
+ Mouse mouse = getMouse();
+ mouse.mouseMove(button0Coordinates, 10, 10);
+ sleep(1000);
+ assertThat(getTooltipElement().getLocation().x, is(greaterThan(0)));
+
+ mouse.mouseMove(button1Coordinates, 10, 10);
+ assertThat(getTooltipElement().getLocation().x, is(lessThan(-1000)));
+
+ sleep(1000);
+ assertThat(getTooltipElement().getLocation().x,
+ is(greaterThan(button1Coordinates.onPage().x)));
+ }
+
+ private Coordinates getButtonCoordinates(String caption) {
+ return getCoordinates(getButton(caption));
+ }
+
+ private ButtonElement getButton(String caption) {
+ return $(ButtonElement.class)
+ .caption(caption).first();
+ }
+}