aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/grid/DateFieldHeaderScrollWithFrozenTest.java
blob: 8d8b3e838279a874137ef95ae7c374c57e1940f1 (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
package com.vaadin.tests.components.grid;

import static org.junit.Assert.assertTrue;

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

import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.tests.tb3.MultiBrowserTest;

public class DateFieldHeaderScrollWithFrozenTest extends MultiBrowserTest {

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

        waitForElementPresent(By.className("v-datefield-button"));

        GridElement gridElement = $(GridElement.class).first();
        WebElement buttonElement = findElement(
                By.className("v-datefield-button"));
        GridCellElement frozenElement = gridElement.getHeaderCell(1, 1);

        gridElement.getHorizontalScroller().scrollLeft(60);
        sleep(100); // wait for scrolling to finish

        int buttonRight = buttonElement.getLocation().getX()
                + buttonElement.getRect().getWidth();
        int frozenRight = frozenElement.getLocation().getX()
                + frozenElement.getRect().getWidth();
        assertTrue(buttonRight + " is not smaller than " + frozenRight
                + ", not enough scrolling", buttonRight < frozenRight);

        Integer buttonZ = Integer.valueOf(buttonElement.getCssValue("z-index"));
        Integer frozenZ = Integer.valueOf(frozenElement.getCssValue("z-index"));
        assertTrue(
                buttonZ + " is not smaller than " + frozenZ
                        + ", button not hidden beneath frozen column",
                buttonZ < frozenZ);
    }
}