blob: 1d9de0fe7964cbb785d11d9a086aa4e89fe43183 (
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
|
package com.vaadin.tests.components.table;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
import com.vaadin.tests.tb3.MultiBrowserTest;
/**
* Tests checks that column width is restored after removing expand ratios.
*
* @author Vaadin Ltd
*/
public class TableAfterRemovingExpandRatiosTest extends MultiBrowserTest {
private WebElement initialHeader;
private WebElement expandedHeader;
private WebElement expandButton;
private WebElement unExpandButton;
@Override
public void setup() throws Exception {
super.setup();
openTestURL();
List<WebElement> tables = driver.findElements(By.className("v-table"));
initialHeader = tables.get(0)
.findElement(By.className("v-table-header-cell"));
expandedHeader = tables.get(1)
.findElement(By.className("v-table-header-cell"));
expandButton = getDriver().findElement(By.id("expand-button"));
unExpandButton = getDriver().findElement(By.id("unexpand-button"));
}
@Test
public void testRemovingExpandRatios() {
clickAndWait(expandButton);
assertThat("Column widths should not be equal after expanding",
initialHeader.getSize().getWidth(),
not(expandedHeader.getSize().getWidth()));
clickAndWait(unExpandButton);
assertThat("Column widths should be equal after unexpanding",
initialHeader.getSize().getWidth(),
is(expandedHeader.getSize().getWidth()));
}
@Test
public void testRemovingExpandRatiosAfterAddingNewItem() {
WebElement addItemButton = getDriver().findElement(By.id("add-button"));
clickAndWait(expandButton);
clickAndWait(addItemButton);
clickAndWait(unExpandButton);
assertThat(
"Column widths should be equal after adding item and unexpanding",
initialHeader.getSize().getWidth(),
is(expandedHeader.getSize().getWidth()));
}
private void clickAndWait(WebElement elem) {
elem.click();
testBench(driver).waitForVaadin();
}
}
|