diff options
author | Juuso Valli <juuso@vaadin.com> | 2014-06-13 15:22:29 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-06-23 12:49:48 +0000 |
commit | d2b0e97c9fb43c1cf84947b42a6de6d58b2368ca (patch) | |
tree | c9cd159ef6511dfdd576c723bde58691b621b37d | |
parent | 5fe5f05576c166600f6912345f4580b5d0bfa8a1 (diff) | |
download | vaadin-framework-d2b0e97c9fb43c1cf84947b42a6de6d58b2368ca.tar.gz vaadin-framework-d2b0e97c9fb43c1cf84947b42a6de6d58b2368ca.zip |
Upgrade tooltip tests from TB2 to TB4 (#14019)
Change-Id: I57fcffc5e9fb463759639c95a6b47fe09bfa268f
13 files changed, 289 insertions, 519 deletions
diff --git a/uitest/src/com/vaadin/tests/components/LongTooltip.html b/uitest/src/com/vaadin/tests/components/LongTooltip.html deleted file mode 100644 index a5055741f1..0000000000 --- a/uitest/src/com/vaadin/tests/components/LongTooltip.html +++ /dev/null @@ -1,324 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<!--Lower-right--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.LongTooltip?restartApplication</td> - <td></td> -</tr> -<!--Show tooltip, which should be on screen--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]</td> - <td>0,0</td> -</tr> -<!--Wait for tooltip to appear--> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-right-1</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-right-2</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[3]/VTextField[0]</td> - <td>100,20</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-right-3</td> -</tr> -<!--Upper-right--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.LongTooltip?restartApplication</td> - <td></td> -</tr> -<!--Show tooltip, which should be on screen--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]</td> - <td>0,0</td> -</tr> -<!--Wait for tooltip to appear--> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-right-1</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-right-2</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[1]/VTextField[0]</td> - <td>100,20</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-right-3</td> -</tr> -<!--Lower-left--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.LongTooltip?restartApplication</td> - <td></td> -</tr> -<!--Show tooltip, which should be on screen--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>0,0</td> -</tr> -<!--Wait for tooltip to appear--> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-left-1</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-left-2</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[2]/VTextField[0]</td> - <td>100,20</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-lower-left-3</td> -</tr> -<!--Upper-left--> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.LongTooltip?restartApplication</td> - <td></td> -</tr> -<!--Show tooltip, which should be on screen--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]</td> - <td>0,0</td> -</tr> -<!--Wait for tooltip to appear--> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-left-1</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-left-2</td> -</tr> -<!--Hide tooltip--> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/VVerticalLayout[0]/VGridLayout[0]</td> - <td>55,43</td> -</tr> -<!--Wait for tooltip to disappear. Cannot for some reason use waitForNotVisible--> -<tr> - <td>pause</td> - <td>500</td> - <td></td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VGridLayout[0]/AbsolutePanel[0]/ChildComponentContainer[0]/VTextField[0]</td> - <td>100,20</td> -</tr> -<tr> - <td>waitForVisible</td> - <td>vaadin=runcomvaadintestscomponentsLongTooltip::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>tooltip-upper-left-3</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java index df18d4082d..cb71fef3ef 100644 --- a/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java +++ b/uitest/src/com/vaadin/tests/components/form/FormTooltipsTest.java @@ -33,9 +33,7 @@ public class FormTooltipsTest extends TooltipTest { WebElement fieldElement = $(FormElement.class).first() .$(TextFieldElement.class).first(); checkTooltip(fieldElement, "Fields own tooltip"); - - moveToRoot(); - Thread.sleep(1000); + clearTooltip(); checkTooltipNotPresent(); // first name caption tooltip @@ -43,8 +41,7 @@ public class FormTooltipsTest extends TooltipTest { $(FormElement.class).first().findElement( By.className("v-caption")), "Fields own tooltip"); - moveToRoot(); - Thread.sleep(1000); + clearTooltip(); checkTooltipNotPresent(); // Form should not have a description tooltip diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html b/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html deleted file mode 100644 index 6014f557e7..0000000000 --- a/uitest/src/com/vaadin/tests/components/slider/SliderTooltip.html +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/" /> -<title>SliderTooltip</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">SliderTooltip</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.slider.SliderTest?debug&restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::PID_Smenu#item0</td> - <td>24,2</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[0]/VMenuBar[0]#item1</td> - <td>35,12</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[1]/VMenuBar[0]#item1</td> - <td>74,3</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VOverlay[2]/VMenuBar[0]#item2</td> - <td>30,6</td> -</tr> -<tr> - <td>showTooltip</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::PID_StestComponent/domChild[2]/domChild[0]</td> - <td>0,0</td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td></td> -</tr> -<tr> - <td>assertText</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>This is a semi-long text that might wrap.</td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::/VVerticalLayout[0]/ChildComponentContainer[0]/VLabel[0]</td> - <td>40,16</td> -</tr> -<tr> - <td>pause</td> - <td></td> - <td>1000</td> -</tr> -<tr> - <td>assertElementPositionLeft</td> - <td>vaadin=runcomvaadintestscomponentssliderSliderTest::Root/VTooltip[0]/FlowPanel[0]/domChild[1]</td> - <td>-5000</td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java deleted file mode 100644 index f3e7554579..0000000000 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfigurationTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2000-2013 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.ui; - -import java.util.NoSuchElementException; - -import org.junit.Assert; -import org.junit.Test; -import org.openqa.selenium.Keys; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; - -import com.vaadin.testbench.By; -import com.vaadin.tests.tb3.MultiBrowserTest; - -public class TooltipConfigurationTest extends MultiBrowserTest { - - private org.openqa.selenium.By tooltipBy = By - .vaadin("Root/VTooltip[0]/FlowPanel[0]/domChild[1]"); - - @Test - public void testTooltipConfiguration() throws Exception { - openTestURL(); - - WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); - WebElement closeTimeout = vaadinElementById("Close timeout"); - WebElement shortTooltip = vaadinElementById("shortTooltip"); - WebElement longTooltip = vaadinElementById("longTooltip"); - WebElement maxWidth = vaadinElementById("Max width"); - - selectAndType(closeTimeout, "0"); - testBenchElement(shortTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - Assert.assertEquals("This is a short tooltip", getTooltip().getText()); - - new Actions(getDriver()).moveToElement(uiRoot, 0, 0).click().perform(); - // uiRoot.click(); - checkTooltipNotPresent(); - - selectAndType(closeTimeout, "3000"); - moveMouseToTopLeft(uiRoot); - testBenchElement(shortTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - WebElement tooltip2 = getTooltip(); - Assert.assertEquals("This is a short tooltip", tooltip2.getText()); - - uiRoot.click(); - // assert that tooltip is present - getTooltip(); - selectAndType(closeTimeout, "0"); - testBenchElement(longTooltip).showTooltip(); - waitForElementToBePresent(tooltipBy); - Assert.assertEquals(500, getTooltip().getSize().getWidth()); - - uiRoot.click(); - selectAndType(maxWidth, "100"); - moveMouseToTopLeft(uiRoot); - testBenchElement(longTooltip).showTooltip(); - Assert.assertEquals(100, getTooltip().getSize().getWidth()); - } - - private WebElement getTooltip() { - return getDriver().findElement(tooltipBy); - } - - private void checkTooltipNotPresent() { - try { - WebElement tooltip = getTooltip(); - if (!"".equals(tooltip.getText()) - || tooltip.getLocation().getX() > -999) { - Assert.fail("Found tooltip that shouldn't be visible: " - + tooltip.getText() + " at " + tooltip.getLocation()); - } - } catch (NoSuchElementException e) { - Assert.fail("Tooltip element was removed completely, causing extra events to accessibility tools"); - } - } - - private void selectAndType(WebElement element, String value) { - // select and replace text - element.clear(); - // if null representation not set as "", need to move cursor to end and - // remove text "null" - // element.sendKeys("" + Keys.BACK_SPACE + Keys.BACK_SPACE - // + Keys.BACK_SPACE + Keys.BACK_SPACE); - element.sendKeys(value + Keys.ENTER); - } - - private void moveMouseToTopLeft(WebElement element) { - new Actions(getDriver()).moveToElement(element, 0, 0).perform(); - } - -}
\ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java index 86ac8c1f12..86ea44287a 100644 --- a/uitest/src/com/vaadin/tests/tb3/TooltipTest.java +++ b/uitest/src/com/vaadin/tests/tb3/TooltipTest.java @@ -16,11 +16,13 @@ package com.vaadin.tests.tb3; +import java.util.List; import java.util.NoSuchElementException; import org.junit.Assert; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; import com.vaadin.testbench.By; @@ -58,10 +60,20 @@ public abstract class TooltipTest extends MultiBrowserTest { } protected void checkTooltip(String value) throws Exception { + WebElement body = findElement(By.cssSelector("body")); WebElement tooltip = getTooltip(); Assert.assertEquals(value, tooltip.getText()); - Assert.assertTrue("Tooltip should be in viewport", tooltip + Assert.assertTrue("Tooltip overflowed to the left", tooltip .getLocation().getX() >= 0); + Assert.assertTrue("Tooltip overflowed up", + tooltip.getLocation().getY() >= 0); + Assert.assertTrue("Tooltip overflowed to the right", tooltip + .getLocation().getX() + tooltip.getSize().getWidth() < body + .getSize().getWidth()); + Assert.assertTrue("Tooltip overflowed down", tooltip.getLocation() + .getY() + tooltip.getSize().getHeight() < body.getSize() + .getHeight()); + } protected void moveToRoot() { @@ -88,7 +100,18 @@ public abstract class TooltipTest extends MultiBrowserTest { } protected void moveMouseToTopLeft(WebElement element) { - new Actions(getDriver()).moveToElement(element, 0, 0).perform(); + moveMouseTo(element, 0, 0); + } + + protected void moveMouseTo(WebElement element, int offsetX, int offsetY) { + new Actions(getDriver()).moveToElement(element, offsetX, offsetY) + .perform(); } + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // TODO Once we figure out how to get mouse hovering work with the IE + // webdriver, exclude them from these tests (#13854) + return getBrowsersExcludingIE(); + } } diff --git a/uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java index fa639918aa..d212a13058 100644 --- a/uitest/src/com/vaadin/tests/components/button/ButtonTooltips.java +++ b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltips.java @@ -1,4 +1,4 @@ -package com.vaadin.tests.components.button; +package com.vaadin.tests.tooltip; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Alignment; @@ -24,14 +24,8 @@ public class ButtonTooltips extends TestBase { button.setDescription("long descidescidescpription"); Button button2 = new Button("Two"); button2.setDescription("Another"); - Button button3 = new Button("One"); - button3.setDescription("long descidescidescpription"); - Button button4 = new Button("Two"); - button4.setDescription("Another"); vl.addComponent(button); vl.addComponent(button2); - vl.addComponent(button3); - vl.addComponent(button4); vl.setComponentAlignment(button, Alignment.TOP_RIGHT); vl.setComponentAlignment(button2, Alignment.TOP_RIGHT); addComponent(vl); diff --git a/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java new file mode 100644 index 0000000000..d64dd900a7 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/ButtonTooltipsTest.java @@ -0,0 +1,53 @@ +/* + * 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.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * Tests that tooltip sizes do not change when moving between adjacent elements + * + * @author Vaadin Ltd + */ +public class ButtonTooltipsTest extends TooltipTest { + + @Test + public void tooltipSizeWhenMovingBetweenElements() throws Exception { + openTestURL(); + + WebElement buttonOne = $(ButtonElement.class).caption("One").first(); + WebElement buttonTwo = $(ButtonElement.class).caption("Two").first(); + + checkTooltip(buttonOne, "long descidescidescpription"); + int originalWidth = getTooltipElement().getSize().getWidth(); + int originalHeight = getTooltipElement().getSize().getHeight(); + + clearTooltip(); + checkTooltip(buttonTwo, "Another"); + moveMouseTo(buttonOne, 5, 5); + sleep(100); + assertThat(getTooltipElement().getSize().getWidth(), is(originalWidth)); + assertThat(getTooltipElement().getSize().getHeight(), + is(originalHeight)); + } +} diff --git a/uitest/src/com/vaadin/tests/components/LongTooltip.java b/uitest/src/com/vaadin/tests/tooltip/LongTooltip.java index acb498bcee..0eee9d4976 100644 --- a/uitest/src/com/vaadin/tests/components/LongTooltip.java +++ b/uitest/src/com/vaadin/tests/tooltip/LongTooltip.java @@ -1,11 +1,13 @@ -package com.vaadin.tests.components; +package com.vaadin.tests.tooltip; +import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.LoremIpsum; import com.vaadin.ui.Alignment; import com.vaadin.ui.GridLayout; import com.vaadin.ui.TextField; public class LongTooltip extends TestBase { + private int tooltipCount = 0; @Override public void setup() { @@ -33,7 +35,8 @@ public class LongTooltip extends TestBase { private TextField createField() { final TextField field = new TextField(); - field.setDescription(LoremIpsum.get(1000)); + field.setDescription("Tooltip " + Integer.toString(tooltipCount++) + + ": " + LoremIpsum.get(1000)); return field; } diff --git a/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java new file mode 100644 index 0000000000..191ce6ffec --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/LongTooltipTest.java @@ -0,0 +1,47 @@ +/* + * 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 java.util.List; + +import org.junit.Test; + +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.TooltipTest; +import com.vaadin.tests.util.LoremIpsum; + +/** + * Test to see if long tooltips behave appropriately + * + * @author Vaadin Ltd + */ +public class LongTooltipTest extends TooltipTest { + + @Test + public void tooltipsDontOverflow() throws Exception { + openTestURL(); + List<TextFieldElement> elements = $(TextFieldElement.class).all(); + checkTooltipNotPresent(); + int i = 0; + for (TextFieldElement element : elements) { + checkTooltip(element, "Tooltip " + Integer.toString(i++) + ": " + + LoremIpsum.get(1000)); + clearTooltip(); + checkTooltipNotPresent(); + } + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java b/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java new file mode 100644 index 0000000000..8cf7232fab --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/SliderTooltip.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.tooltip; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Slider; + +public class SliderTooltip extends AbstractTestUI { + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server. + * VaadinRequest) + */ + @Override + protected void setup(VaadinRequest request) { + Slider slider = new Slider(); + slider.setDescription("Tooltip"); + addComponent(slider); + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription() + */ + @Override + protected String getTestDescription() { + return "Testing that sliders have tooltips."; + } + + /* + * (non-Javadoc) + * + * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber() + */ + @Override + protected Integer getTicketNumber() { + return 14019; + } + +} diff --git a/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java b/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java new file mode 100644 index 0000000000..743b7c2ab5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/SliderTooltipTest.java @@ -0,0 +1,40 @@ +/* + * 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 org.junit.Test; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.SliderElement; +import com.vaadin.tests.tb3.TooltipTest; + +/** + * Test that sliders can have tooltips + * + * @author Vaadin Ltd + */ +public class SliderTooltipTest extends TooltipTest { + + @Test + public void sliderHasTooltip() throws Exception { + openTestURL(); + WebElement slider = $(SliderElement.class).first(); + checkTooltipNotPresent(); + checkTooltip(slider, "Tooltip"); + clearTooltip(); + checkTooltipNotPresent(); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java b/uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java index eeea91b638..f67db4219f 100644 --- a/uitest/src/com/vaadin/tests/components/ui/TooltipConfiguration.java +++ b/uitest/src/com/vaadin/tests/tooltip/TooltipConfiguration.java @@ -1,4 +1,4 @@ -package com.vaadin.tests.components.ui; +package com.vaadin.tests.tooltip; import com.vaadin.data.Property; import com.vaadin.data.Property.ValueChangeEvent; diff --git a/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java b/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java new file mode 100644 index 0000000000..8f84444400 --- /dev/null +++ b/uitest/src/com/vaadin/tests/tooltip/TooltipConfigurationTest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2000-2013 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.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.By; +import com.vaadin.tests.tb3.TooltipTest; + +public class TooltipConfigurationTest extends TooltipTest { + + @Test + public void testTooltipConfiguration() throws Exception { + openTestURL(); + + WebElement uiRoot = getDriver().findElement(By.vaadin("Root")); + WebElement closeTimeout = vaadinElementById("Close timeout"); + WebElement shortTooltip = vaadinElementById("shortTooltip"); + WebElement longTooltip = vaadinElementById("longTooltip"); + WebElement maxWidth = vaadinElementById("Max width"); + + selectAndType(closeTimeout, "0"); + + checkTooltip(shortTooltip, "This is a short tooltip"); + + moveToRoot(); + + checkTooltipNotPresent(); + + selectAndType(closeTimeout, "3000"); + checkTooltip(shortTooltip, "This is a short tooltip"); + + moveToRoot(); + + // The tooltip should still be there despite being "cleared", as the + // timeout hasn't expired yet. + checkTooltip("This is a short tooltip"); + + // assert that tooltip is present + selectAndType(closeTimeout, "0"); + selectAndType(maxWidth, "100"); + + testBenchElement(longTooltip).showTooltip(); + assertThat(getDriver().findElement(By.className("popupContent")) + .getSize().getWidth(), is(100)); + } + + private void selectAndType(WebElement element, String value) { + // select and replace text + element.clear(); + // if null representation not set as "", need to move cursor to end and + // remove text "null" + element.sendKeys(value + Keys.ENTER); + } +}
\ No newline at end of file |