aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/menubar/MenuTooltipTest.java
blob: d15306bc5aa5b01e5fdf1c8ba0b3120ce06a45e1 (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
41
42
43
44
45
46
47
48
49
50
package com.vaadin.tests.components.menubar;

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.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

/**
 * Test to see if tooltips on menu items obscure other items on the menu.
 *
 * @author Vaadin Ltd
 */
public class MenuTooltipTest extends MultiBrowserTest {

    @Override
    public List<DesiredCapabilities> getBrowsersToTest() {
        return getBrowsersExcludingIE();
    }

    @Test
    public void testToolTipDelay() throws InterruptedException {
        openTestURL();

        final MenuBarElement menuBar = $(MenuBarElement.class).first();
        // Open menu bar and move on top of the first menu item
        new Actions(getDriver()).moveToElement(menuBar).click()
                .moveByOffset(0, menuBar.getSize().getHeight()).perform();

        // Make sure tooltip is outside of the screen
        assertThat(getTooltipElement().getLocation().getX(),
                is(lessThan(-1000)));

        // Wait for tooltip to open up
        sleep(3000);

        // Make sure it's the correct tooltip
        assertThat(getTooltipElement().getLocation().getX(),
                is(greaterThan(menuBar.getLocation().getX())));
        assertThat(getTooltipElement().getText(), is("TOOLTIP 1"));
    }
}