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.

GridEditorScrollSyncTest.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.vaadin.tests.components.grid;
  2. import static org.hamcrest.MatcherAssert.assertThat;
  3. import static org.hamcrest.number.IsCloseTo.closeTo;
  4. import org.junit.Assert;
  5. import org.junit.Test;
  6. import org.openqa.selenium.By;
  7. import com.vaadin.testbench.TestBenchElement;
  8. import com.vaadin.testbench.elements.GridElement;
  9. import com.vaadin.tests.tb3.MultiBrowserTest;
  10. public class GridEditorScrollSyncTest extends MultiBrowserTest {
  11. private GridElement grid;
  12. @Test
  13. public void testScrollAndEdit() {
  14. openTestURL();
  15. grid = $(GridElement.class).first();
  16. ((TestBenchElement) grid
  17. .findElement(By.className("v-grid-scroller-horizontal")))
  18. .scrollLeft(300);
  19. openEditor();
  20. GridElement.GridCellElement rowCell = grid.getCell(1, 6);
  21. TestBenchElement editorField = grid.getEditor().getField(6);
  22. assertPosition(rowCell.getLocation().getX(),
  23. editorField.getWrappedElement().getLocation().getX());
  24. }
  25. private GridElement openEditor() {
  26. grid.getCell(0, 6).doubleClick();
  27. Assert.assertTrue("Grid editor should be displayed.",
  28. grid.getEditor().isDisplayed());
  29. return grid;
  30. }
  31. private void assertPosition(double expected, double actual) {
  32. // 1px leeway for calculations
  33. assertThat("Unexpected position.", expected, closeTo(actual, 1d));
  34. }
  35. }