You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GridEditorEventsTest.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.vaadin.tests.components.grid;
  2. import static org.junit.Assert.assertEquals;
  3. import org.junit.Test;
  4. import org.openqa.selenium.WebElement;
  5. import com.vaadin.testbench.elements.GridElement;
  6. import com.vaadin.testbench.elements.GridElement.GridEditorElement;
  7. import com.vaadin.tests.tb3.MultiBrowserTest;
  8. public class GridEditorEventsTest extends MultiBrowserTest {
  9. @Test
  10. public void editorEvents() throws InterruptedException {
  11. openTestURL();
  12. GridElement grid = $(GridElement.class).first();
  13. assertEditorEvents(0, grid);
  14. assertEditorEvents(1, grid);
  15. }
  16. private void assertEditorEvents(int index, GridElement grid) {
  17. GridEditorElement editor = updateField(index, grid, "foo");
  18. editor.save();
  19. assertEquals((index * 4 + 1) + ". editor is opened", getLogRow(1));
  20. assertEquals((index * 4 + 2) + ". editor is saved", getLogRow(0));
  21. editor = updateField(index, grid, "bar");
  22. editor.cancel();
  23. assertEquals((index * 4 + 3) + ". editor is opened", getLogRow(1));
  24. assertEquals((index * 4 + 4) + ". editor is canceled", getLogRow(0));
  25. }
  26. private GridEditorElement updateField(int index, GridElement grid,
  27. String text) {
  28. grid.getRow(index).doubleClick();
  29. GridEditorElement editor = grid.getEditor();
  30. WebElement focused = getFocusedElement();
  31. assertEquals("input", focused.getTagName());
  32. focused.sendKeys(text);
  33. return editor;
  34. }
  35. }