diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2018-08-13 15:41:23 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2018-08-13 15:41:23 +0300 |
commit | 062caa5b844dd6540b101dd04c612bc8e5948ad4 (patch) | |
tree | 76afb725266b84f6e2968d5ba7eea06d98c1111a /uitest/src/test | |
parent | 378d7f5a92338135829b8a28738e427a388faaf2 (diff) | |
download | vaadin-framework-062caa5b844dd6540b101dd04c612bc8e5948ad4.tar.gz vaadin-framework-062caa5b844dd6540b101dd04c612bc8e5948ad4.zip |
Compensate for Grid editor moving out of sync horizontally. (#11092)
Fixes #10998
Diffstat (limited to 'uitest/src/test')
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java new file mode 100644 index 0000000000..50ac9b5afe --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridEditorScrollSyncTest.java @@ -0,0 +1,47 @@ +package com.vaadin.tests.components.grid; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.number.IsCloseTo.closeTo; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridCellElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridEditorScrollSyncTest extends MultiBrowserTest { + + private GridElement grid; + + @Test + public void testScrollAndEdit() { + openTestURL(); + grid = $(GridElement.class).first(); + + ((TestBenchElement) grid + .findElement(By.className("v-grid-scroller-horizontal"))) + .scrollLeft(300); + openEditor(); + + GridCellElement rowCell = grid.getCell(1, 6); + TestBenchElement editorField = grid.getEditor().getField(6); + assertPosition(rowCell.getLocation().getX(), + editorField.getWrappedElement().getLocation().getX()); + } + + private GridElement openEditor() { + grid.getCell(0, 6).doubleClick(); + Assert.assertTrue("Grid editor should be displayed.", + grid.getEditor().isDisplayed()); + return grid; + } + + private void assertPosition(double expected, double actual) { + // 1px leeway for calculations + assertThat("Unexpected position.", expected, closeTo(actual, 1d)); + } + +} |