summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorJuuso Valli <juuso@vaadin.com>2014-06-06 12:55:56 +0300
committerJuuso Valli <juuso@vaadin.com>2014-06-11 16:06:21 +0300
commit534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf (patch)
treebfbf47e13fe2ee7e91690f7a22d4477ef54c48ce /uitest
parent3e5c5bc10752ae011ee74c82530452ba26521833 (diff)
downloadvaadin-framework-534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf.tar.gz
vaadin-framework-534485ded6e7ec8e5534b11ade5fdd5b8abbc2bf.zip
Make tooltips stationary when hovering (#13981)
Change-Id: I44acce87ea5c37d7b210e6c6c3dd9cd511192524
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java5
-rw-r--r--uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java19
-rw-r--r--uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java4
-rw-r--r--uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java11
-rw-r--r--uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java10
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java31
-rw-r--r--uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java77
7 files changed, 132 insertions, 25 deletions
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java
index 197963a612..3cfe30a991 100644
--- a/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuBarTooltipsNearEdgeTest.java
@@ -29,7 +29,6 @@ import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.remote.DesiredCapabilities;
-import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -62,8 +61,4 @@ public class MenuBarTooltipsNearEdgeTest extends MultiBrowserTest {
- tooltip.getSize().getWidth())));
}
-
- private WebElement getTooltipElement() {
- return getDriver().findElement(By.className("v-tooltip-text"));
- }
}
diff --git a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
index b4bae160b9..bb8f87daaa 100644
--- a/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
+++ b/uitest/src/com/vaadin/tests/components/menubar/MenuTooltipTest.java
@@ -23,12 +23,9 @@ 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;
@@ -43,20 +40,14 @@ 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;
- };
+ return getBrowsersExcludingIE();
+ }
@Test
public void testToolTipDelay() throws InterruptedException {
openTestURL();
- Coordinates elementCoordinates = ((Locatable) $(MenuBarElement.class)
- .first().getWrappedElement()).getCoordinates();
+ Coordinates elementCoordinates = getCoordinates($(MenuBarElement.class).first());
Mouse mouse = ((HasInputDevices) getDriver()).getMouse();
@@ -74,8 +65,4 @@ public class MenuTooltipTest extends MultiBrowserTest {
is(greaterThan(elementCoordinates.onPage().getX())));
assertThat(getTooltipElement().getText(), is("TOOLTIP 1"));
}
-
- private WebElement getTooltipElement() {
- return getDriver().findElement(By.className("v-tooltip-text"));
- }
}
diff --git a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java
index 06fb659d4a..412fd3049d 100644
--- a/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java
+++ b/uitest/src/com/vaadin/tests/components/window/TooltipInWindowTest.java
@@ -74,10 +74,6 @@ public class TooltipInWindowTest extends MultiBrowserTest {
}
- private WebElement getTooltipElement() {
- return getDriver().findElement(By.className("v-tooltip-text"));
- }
-
private WebElement getTooltipContainerElement() {
return getDriver().findElement(By.className("v-tooltip"));
}
diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
index c8e4e3c9a9..8783a4dc42 100644
--- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
+++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
@@ -24,6 +24,7 @@ import java.net.URL;
import java.util.Collections;
import java.util.List;
+import com.vaadin.testbench.TestBenchElement;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -35,6 +36,8 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.HasInputDevices;
import org.openqa.selenium.interactions.Keyboard;
import org.openqa.selenium.interactions.Mouse;
+import org.openqa.selenium.interactions.internal.Coordinates;
+import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
@@ -153,6 +156,14 @@ public abstract class AbstractTB3Test extends TestBenchTestCase {
}
+ protected WebElement getTooltipElement() {
+ return getDriver().findElement(com.vaadin.testbench.By.className("v-tooltip-text"));
+ }
+
+ protected Coordinates getCoordinates(TestBenchElement element) {
+ return ((Locatable) element.getWrappedElement()).getCoordinates();
+ }
+
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RunLocally {
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
index 74073af217..ccbb6ca872 100644
--- a/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserTest.java
@@ -40,6 +40,16 @@ import org.openqa.selenium.remote.DesiredCapabilities;
*/
public abstract class MultiBrowserTest extends PrivateTB3Configuration {
+ protected List<DesiredCapabilities> getBrowsersExcludingIE() {
+ List<DesiredCapabilities> browsers = new ArrayList<DesiredCapabilities>(getAllBrowsers());
+ browsers.remove(Browser.IE8.getDesiredCapabilities());
+ browsers.remove(Browser.IE9.getDesiredCapabilities());
+ browsers.remove(Browser.IE10.getDesiredCapabilities());
+ browsers.remove(Browser.IE11.getDesiredCapabilities());
+
+ return browsers;
+ }
+
public enum Browser {
FIREFOX(BrowserUtil.firefox(24)), CHROME(BrowserUtil.chrome(33)), SAFARI(
BrowserUtil.safari(7)), IE8(BrowserUtil.ie(8)), IE9(BrowserUtil
diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java
new file mode 100644
index 0000000000..5c7b52d96f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltip.java
@@ -0,0 +1,31 @@
+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.VerticalLayout;
+
+public class StationaryTooltip extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ VerticalLayout vl = new VerticalLayout();
+ Button button = new Button("Button");
+ button.setDescription("description");
+
+ button.setWidth("200px");
+ vl.addComponent(button);
+
+ addComponent(vl);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return null;
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return null;
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java
new file mode 100644
index 0000000000..6b751e7a6b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tooltip/StationaryTooltipTest.java
@@ -0,0 +1,77 @@
+package com.vaadin.tests.tooltip;
+
+import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.interactions.Mouse;
+import org.openqa.selenium.interactions.internal.Coordinates;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class StationaryTooltipTest extends MultiBrowserTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // With IEDriver, the cursor seems to jump to default position after the
+ // mouse move,
+ // so we are not able to test the tooltip behaviour properly.
+ return getBrowsersExcludingIE();
+ }
+
+ @Test
+ public void tooltipShouldBeStationary() throws InterruptedException {
+ openTestURL();
+
+ Mouse mouse = getMouse();
+
+ moveMouseToButtonUpperLeftCorner(mouse);
+ sleep(3000); // wait for the tooltip to become visible
+ int originalTooltipLocationX = getTooltipLocationX();
+
+ moveMouseToButtonBottomRightCorner(mouse);
+ int actualTooltipLocationX = getTooltipLocationX();
+
+ assertThat(actualTooltipLocationX, is(greaterThan(0)));
+ assertThat(actualTooltipLocationX, is(originalTooltipLocationX));
+ }
+
+ private Coordinates getButtonCoordinates() {
+ return getCoordinates(getButtonElement());
+ }
+
+ private ButtonElement getButtonElement() {
+ return $(ButtonElement.class).first();
+ }
+
+ private void moveMouseToButtonBottomRightCorner(Mouse mouse) {
+ Coordinates buttonCoordinates = getButtonCoordinates();
+ Dimension buttonDimensions = getButtonDimensions();
+
+ mouse.mouseMove(buttonCoordinates, buttonDimensions.getWidth() - 1,
+ buttonDimensions.getHeight() - 1);
+ }
+
+ private void moveMouseToButtonUpperLeftCorner(Mouse mouse) {
+ Coordinates buttonCoordinates = getButtonCoordinates();
+
+ mouse.mouseMove(buttonCoordinates, 0, 0);
+ }
+
+ private org.openqa.selenium.Dimension getButtonDimensions() {
+ ButtonElement buttonElement = getButtonElement();
+
+ return buttonElement.getWrappedElement().getSize();
+ }
+
+ private int getTooltipLocationX() {
+ return getTooltipElement().getLocation().getX();
+ }
+
+} \ No newline at end of file