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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
package com.vaadin.tests.components.treegrid;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import com.vaadin.testbench.elements.TreeGridElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class TreeGridCollapseDisabledTest extends SingleBrowserTest {
private TreeGridElement grid;
@Override
protected Class<?> getUIClass() {
return TreeGridBasicFeatures.class;
}
@Before
public void before() {
openTestURL();
grid = $(TreeGridElement.class).first();
}
@Test
public void collapse_disabled_for_all() {
selectMenuPath("Component", "Features", "Collapse allowed",
"all disabled");
// Assert first and second row can be expanded, but not collapsed
assertExpandRow(0);
assertCollapseRowDisabled(0);
assertExpandRow(1);
assertCollapseRowDisabled(1);
}
@Test
public void collapse_disabled_for_depth0() {
selectMenuPath("Component", "Features", "Collapse allowed",
"depth 0 disabled");
// Assert first row expands
assertExpandRow(0);
// Assert second row expands and collapses
assertExpandRow(1);
assertCollapseRow(1);
// Assert first row does not collapse
assertCollapseRowDisabled(0);
}
@Test
public void collapse_disabled_for_depth1() {
selectMenuPath("Component", "Features", "Collapse allowed",
"depth 1 disabled");
// Assert first row expands
assertExpandRow(0);
// Assert second row expands but does not collapse
assertExpandRow(1);
assertCollapseRowDisabled(1);
// Assert first row still collapses
assertCollapseRow(0);
}
@Test
public void collapse_disabled_mode_change_with_expanded_rows() {
// Assert first row expands
assertExpandRow(0);
// Assert second row expands and collapses
assertExpandRow(1);
assertCollapseRow(1);
selectMenuPath("Component", "Features", "Collapse allowed",
"depth 1 disabled");
assertTrue("First row should still be expanded",
grid.isRowExpanded(0, 0));
// Assert second row expands but does not collapse
assertExpandRow(1);
assertCollapseRowDisabled(1);
// Assert first row still collapses
assertCollapseRow(0);
}
private void assertExpandRow(int row) {
assertFalse(grid.isRowExpanded(row, 0));
grid.expandWithClick(row);
assertTrue(grid.isRowExpanded(row, 0));
}
private void assertCollapseRow(int row) {
assertTrue("Row not expanded", grid.isRowExpanded(row, 0));
grid.collapseWithClick(row);
assertFalse("Row did not collapse", grid.isRowExpanded(row, 0));
}
private void assertCollapseRowDisabled(int row) {
assertTrue("Row not expanded", grid.isRowExpanded(row, 0));
grid.collapseWithClick(row);
assertTrue("Row should not collapse", grid.isRowExpanded(row, 0));
}
}
|