aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridAriaRowcountTest.java
blob: 24c1187e14b5c5f412d3cbe3dde589955187ef77 (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
51
52
53
54
55
56
57
58
59
package com.vaadin.tests.components.treegrid;

import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.TreeGridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

/**
 * @author Vaadin Ltd
 */
public class TreeGridAriaRowcountTest extends SingleBrowserTest {

    private TreeGridElement grid;

    @Test
    public void checkTreeGridAriaRowcount() {
        openTestURL();

        grid = $(TreeGridElement.class).first();

        // default with 1 header row and 2 body rows.
        assertTrue("Grid should have 3 rows", containsRows(3));

        $(ButtonElement.class).caption("addFooter").first().click();
        // 1 header row, 2 body rows and 1 footer row.
        assertTrue("Grid should have 4 rows", containsRows(4));

        $(ButtonElement.class).caption("removeFooter").first().click();
        // 1 header row and 2 body rows.
        assertTrue("Grid should have 3 rows", containsRows(3));

        $(ButtonElement.class).caption("addHeader").first().click();
        // 2 header row and 2 body rows.
        assertTrue("Grid should have 4 rows", containsRows(4));

        $(ButtonElement.class).caption("removeHeader").first().click();
        // 1 header row and 2 body rows.
        assertTrue("Grid should have 3 rows", containsRows(3));

        $(ButtonElement.class).caption("setItemsTo3").first().click();
        // 1 header row and 3 body rows.
        assertTrue("Grid should have 4 rows", containsRows(4));

        $(ButtonElement.class).caption("setItemsTo6").first().click();
        // 1 header row and 6 body rows.
        assertTrue("Grid should have 7 rows", containsRows(7));

        $(ButtonElement.class).caption("updateAll").first().click();
        // 2 header rows, 4 body rows and 1 footer row.
        assertTrue("Grid should have 7 rows", containsRows(7));
    }

    private boolean containsRows(int rowcount) {
        return grid.getHTML()
                .contains("aria-rowcount=\"" + String.valueOf(rowcount) + "\"");
    }
}