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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
/**
* @author Vaadin Ltd
*/
public class GridAriaRowcountTest extends SingleBrowserTest {
private GridElement grid;
@Test
public void checkGridAriaRowcount() {
openTestURL();
grid = $(GridElement.class).first();
// default grid should contain at least one of each role
String gridHtml = grid.getHTML();
assertTrue("Grid should contain a role=\"rowheader\"",
gridHtml.contains("role=\"rowheader\""));
assertTrue("Grid should contain a role=\"columnheader\"",
gridHtml.contains("role=\"columnheader\""));
assertTrue("Grid should contain a role=\"row\"",
gridHtml.contains("role=\"row\""));
assertTrue("Grid should contain a role=\"gridcell\"",
gridHtml.contains("role=\"gridcell\""));
assertTrue("Grid should contain a role=\"rowgroup\"",
gridHtml.contains("role=\"rowgroup\""));
// 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) + "\"");
}
}
|