aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/tooltip/TooltipInWindowTest.java
blob: 0ad1d71c63a2041ac92338e539a21422ab7ea4c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.vaadin.tests.tooltip;

import org.junit.Test;
import org.openqa.selenium.WebElement;

import com.vaadin.tests.tb3.TooltipTest;

/**
 * Test if tooltips in subwindows behave correctly
 *
 * @author Vaadin Ltd
 */
public class TooltipInWindowTest extends TooltipTest {

    @Test
    public void testTooltipsInSubWindow() throws Exception {
        openTestURL();

        WebElement textfield = vaadinElementById("tf1");

        checkTooltip(textfield, "My tooltip");

        ensureVisibleTooltipPositionedCorrectly(textfield);

        clearTooltip();

        checkTooltip(textfield, "My tooltip");

        clearTooltip();
    }

    private void ensureVisibleTooltipPositionedCorrectly(WebElement textfield)
            throws InterruptedException {
        int tooltipX = getTooltip().getLocation().getX();
        int textfieldX = textfield.getLocation().getX();
        assertGreaterOrEqual("Tooltip should be positioned on the textfield ("
                + tooltipX + " < " + textfieldX + ")", tooltipX, textfieldX);
    }

}