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
|
package com.vaadin.tests.components.grid;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridEditorElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridEditorEventsTest extends MultiBrowserTest {
@Test
public void editorEvents() throws InterruptedException {
openTestURL();
GridElement grid = $(GridElement.class).first();
assertEditorEvents(0, grid);
assertEditorEvents(1, grid);
}
private void assertEditorEvents(int index, GridElement grid) {
GridEditorElement editor = updateField(index, grid, "foo");
editor.save();
assertEquals((index * 4 + 1) + ". editor is opened", getLogRow(1));
assertEquals((index * 4 + 2) + ". editor is saved", getLogRow(0));
editor = updateField(index, grid, "bar");
editor.cancel();
assertEquals((index * 4 + 3) + ". editor is opened", getLogRow(1));
assertEquals((index * 4 + 4) + ". editor is canceled", getLogRow(0));
}
private GridEditorElement updateField(int index, GridElement grid,
String text) {
grid.getRow(index).doubleClick();
GridEditorElement editor = grid.getEditor();
WebElement focused = getFocusedElement();
assertEquals("input", focused.getTagName());
focused.sendKeys(text);
return editor;
}
}
|