summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tooltip/MenuBarTooltipTest.java
blob: 9b2f7d13d6132ed028967d8abaf2f4951e02130d (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
package com.vaadin.tests.tooltip;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;

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

import com.vaadin.testbench.elements.MenuBarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
import com.vaadin.ui.themes.ChameleonTheme;
import com.vaadin.ui.themes.Reindeer;
import com.vaadin.ui.themes.Runo;
import com.vaadin.ui.themes.ValoTheme;

public class MenuBarTooltipTest extends MultiBrowserTest {

    @Test
    public void toolTipShouldBeOnTopOfMenuItem() {
        String[] themes = new String[] {
                ValoTheme.THEME_NAME,
                Reindeer.THEME_NAME,
                Runo.THEME_NAME,
                ChameleonTheme.THEME_NAME
        };

        for(String theme : themes) {
           assertZIndices(theme);
        }
    }

    public void assertZIndices(String theme) {
        openTestURL("theme=" + theme);

        $(MenuBarElement.class).first().clickItem("Menu item");

        assertThat(String.format("Invalid z-index for theme %s.", theme),
                getZIndex("v-tooltip"), greaterThan(getZIndex("v-menubar-popup")));
    }

    private int getZIndex(String className) {
        return Integer.parseInt(
                findElement(By.className(className)).getCssValue("z-index"));
    }

}