diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2017-03-14 15:06:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-14 15:06:07 +0200 |
commit | 1e8ad071350bc32d53f035379973aead50b75209 (patch) | |
tree | 854eb48d519d6001ae53023b7f058571578aa5d9 /uitest | |
parent | 22b9d37a0f036918ea2182d4291b5e57808588a0 (diff) | |
download | vaadin-framework-1e8ad071350bc32d53f035379973aead50b75209.tar.gz vaadin-framework-1e8ad071350bc32d53f035379973aead50b75209.zip |
Fix removing rows from the middle of Escalator (#8826)
* Fix removing rows from the middle of Escalator
Fixes #8825
Diffstat (limited to 'uitest')
3 files changed, 44 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java index 27f4c8f42b..23ff82cb10 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java @@ -540,6 +540,12 @@ public class EscalatorBasicClientFeaturesWidget insertRows(escalator.getBody(), 0, 5); } }, menupath); + addMenuCommand("Add 22 rows to top", new ScheduledCommand() { + @Override + public void execute() { + insertRows(escalator.getBody(), 0, 22); + } + }, menupath); addMenuCommand("Add 50 rows to top", new ScheduledCommand() { @Override public void execute() { @@ -560,6 +566,12 @@ public class EscalatorBasicClientFeaturesWidget escalator.getBody().getRowCount() - 50, 50); } }, menupath); + addMenuCommand("Remove 15 rows from middle", new ScheduledCommand() { + @Override + public void execute() { + removeRows(escalator.getBody(), 3, 15); + } + }, menupath); addMenuCommand("Remove 50 rows from almost bottom", new ScheduledCommand() { @Override diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java index 71e2182057..5b366db799 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java @@ -59,6 +59,8 @@ public abstract class EscalatorBasicClientFeaturesTest protected static final String SCROLL_TO = "Scroll to..."; protected static final String REMOVE_ALL_INSERT_SCROLL = "Remove all, insert 30 and scroll 40px"; + protected static final String ADD_22_ROWS_TO_TOP = "Add 22 rows to top"; + protected static final String REMOVE_15_ROWS_FROM_MIDDLE = "Remove 15 rows from middle"; protected static final String GENERAL = "General"; protected static final String DETACH_ESCALATOR = "Detach Escalator"; diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java index bd28399385..974ac559e0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorRemoveAndAddRowsTest.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; @@ -38,7 +39,6 @@ public class EscalatorRemoveAndAddRowsTest @Test public void testRemoveAllRowsAndAddThirtyThenScroll() throws IOException { - selectMenuPath(GENERAL, POPULATE_COLUMN_ROW); scrollVerticallyTo(99999); @@ -51,4 +51,33 @@ public class EscalatorRemoveAndAddRowsTest assertTrue("Escalator is not scrolled to bottom.", isElementPresent(By.xpath("//td[text() = 'Row 29: 0,129']"))); } + + @Test + public void testRemoveRowsFromMiddle() { + selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING); + selectMenuPath(COLUMNS_AND_ROWS, HEADER_ROWS, ADD_ONE_ROW_TO_BEGINNING); + selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, ADD_22_ROWS_TO_TOP); + // remove enough rows from middle, so that the total size of escalator + // rows drops to below the size of the rows shown, forcing the escalator + // to remove & move & update rows + selectMenuPath(COLUMNS_AND_ROWS, BODY_ROWS, REMOVE_15_ROWS_FROM_MIDDLE); + // first there was rows 0-21, then removed 15 rows 3-18, thus the rows + // should be 0,1,2,18,19,20,21 + verifyRow(0, 0); + verifyRow(1, 1); + verifyRow(2, 2); + verifyRow(3, 18); + verifyRow(4, 19); + verifyRow(5, 20); + verifyRow(6, 21); + } + + private void verifyRow(int escalatorIndex, int rowIndexInText) { + // the format of text in cells is + // Row: <index_when_updated>: <cell_index>,<index_when_inserted> + Assert.assertEquals("Invalid row present in index " + escalatorIndex, + "Row " + escalatorIndex + ": 0," + rowIndexInText, + getBodyCell(escalatorIndex, 0).getText()); + } + } |