blob: fbb1ae3732236fddbcdd1d13f72a138e653b8e21 (
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
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
|
package com.vaadin.tests.components.table;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
import com.vaadin.testbench.TestBenchElement;
import com.vaadin.testbench.elements.TableElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.TextFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests Table Footer ClickListener
*
* @author Vaadin Ltd
*/
public class FooterClickTest extends MultiBrowserTest {
@Test
public void testFooter() throws IOException {
openTestURL();
TableElement table = $(TableElement.class).first();
TestBenchElement footer0 = table.getFooterCell(0);
footer0.click();
TextFieldElement tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col1", tf.getValue());
assertAnyLogText("1. Clicked on footer: col1");
table = $(TableElement.class).first();
TestBenchElement footer1 = table.getFooterCell(1);
footer1.click();
tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col2", tf.getValue());
assertAnyLogText("2. Clicked on footer: col2");
table = $(TableElement.class).first();
TestBenchElement footer2 = table.getFooterCell(2);
footer2.click();
tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col3", tf.getValue());
assertAnyLogText("3. Clicked on footer: col3");
CheckBoxElement cb = $(CheckBoxElement.class).first();
cb.click();
table = $(TableElement.class).first();
footer0 = table.getFooterCell(0);
footer0.click();
tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col1", tf.getValue());
assertAnyLogText("4. Clicked on footer: col1");
table = $(TableElement.class).first();
footer1 = table.getFooterCell(1);
footer1.click();
tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col2", tf.getValue());
assertAnyLogText("5. Clicked on footer: col2");
table = $(TableElement.class).first();
footer2 = table.getFooterCell(2);
footer2.click();
tf = $(TextFieldElement.class).id("ClickedColumn");
assertEquals("col3", tf.getValue());
assertAnyLogText("6. Clicked on footer: col3");
}
private void assertAnyLogText(String... texts) {
assertThat(String.format(
"Correct log text was not found, expected any of %s",
Arrays.asList(texts)), logContainsAnyText(texts));
}
private boolean logContainsAnyText(String... texts) {
for (String text : texts) {
if (logContainsText(text)) {
return true;
}
}
return false;
}
}
|