blob: 3b6894151233d6924da769f2959454931e330a1b (
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
|
package com.vaadin.tests.components.table;
import static com.vaadin.tests.components.table.ExpandingContainerVisibleRowRaceCondition.TABLE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.util.List;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class ExpandingContainerVisibleRowRaceConditionTest
extends MultiBrowserTest {
private static final int ROW_HEIGHT = 20;
@Test
public void testScrollingWorksWithoutJumpingWhenItemSetChangeOccurs() {
openTestURL();
sleep(1000);
WebElement table = vaadinElementById(TABLE);
assertFirstRowIdIs("ROW #120");
testBenchElement(table.findElement(By.className("v-scrollable")))
.scroll(320 * ROW_HEIGHT);
sleep(1000);
assertRowIdIsInThePage("ROW #330");
assertScrollPositionIsNotVisible();
}
private void assertFirstRowIdIs(String expected) {
List<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
WebElement first = cellsOfFirstColumn.get(0);
assertEquals(expected, first.getText());
}
private void assertRowIdIsInThePage(String expected) {
List<WebElement> cellsOfFirstColumn = getCellsOfFirstColumn();
for (WebElement rowId : cellsOfFirstColumn) {
if (expected.equals(rowId.getText())) {
return;
}
}
fail("Expected row was not found");
}
private void assertScrollPositionIsNotVisible() {
WebElement table = vaadinElementById(TABLE);
WebElement scrollPosition = table
.findElement(By.className("v-table-scrollposition"));
assertFalse(scrollPosition.isDisplayed());
}
private List<WebElement> getCellsOfFirstColumn() {
WebElement table = vaadinElementById(TABLE);
List<WebElement> firstCellOfRows = table
.findElements(By.cssSelector(".v-table-table tr > td"));
return firstCellOfRows;
}
}
|