diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2015-01-28 15:50:54 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-02-25 12:20:33 +0000 |
commit | ea65f173ff5f4d7c980f1e2d1d03c42470d30a2e (patch) | |
tree | d23897feb999370319cfa7ae062a0ec0a60ec9dd /uitest | |
parent | 0dae6ff2f414874e2f05a4475f6ff1c2c6b071a4 (diff) | |
download | vaadin-framework-ea65f173ff5f4d7c980f1e2d1d03c42470d30a2e.tar.gz vaadin-framework-ea65f173ff5f4d7c980f1e2d1d03c42470d30a2e.zip |
Maintain Grid scroll position on detach and reattach (#16220)
Change-Id: I6ac5c3304bcd22e23f298c4dbdd65358aa1c64f7
Diffstat (limited to 'uitest')
2 files changed, 30 insertions, 11 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java index 3f0c9dc70b..e03d50415c 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/EscalatorBasicClientFeaturesTest.java @@ -52,6 +52,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest protected static final String GENERAL = "General"; protected static final String DETACH_ESCALATOR = "Detach Escalator"; + protected static final String ATTACH_ESCALATOR = "Attach Escalator"; protected static final String POPULATE_COLUMN_ROW = "Populate Escalator (columns, then rows)"; protected static final String POPULATE_ROW_COLUMN = "Populate Escalator (rows, then columns)"; protected static final String CLEAR_COLUMN_ROW = "Clear (columns, then rows)"; @@ -234,10 +235,10 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest } protected void scrollVerticallyTo(int px) { - executeScript("arguments[0].scrollTop = " + px, getVeticalScrollbar()); + executeScript("arguments[0].scrollTop = " + px, getVerticalScrollbar()); } - private TestBenchElement getVeticalScrollbar() { + protected TestBenchElement getVerticalScrollbar() { return (TestBenchElement) getEscalator().findElement( By.className("v-escalator-scroller-vertical")); } @@ -247,7 +248,7 @@ public abstract class EscalatorBasicClientFeaturesTest extends MultiBrowserTest getHorizontalScrollbar()); } - private TestBenchElement getHorizontalScrollbar() { + protected TestBenchElement getHorizontalScrollbar() { return (TestBenchElement) getEscalator().findElement( By.className("v-escalator-scroller-horizontal")); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java index 95ed6ab3ff..4742236ac6 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorBasicsTest.java @@ -15,11 +15,13 @@ */ package com.vaadin.tests.components.grid.basicfeatures.escalator; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import java.io.IOException; +import org.junit.Before; import org.junit.Test; import com.vaadin.testbench.elements.NotificationElement; @@ -27,20 +29,20 @@ import com.vaadin.tests.components.grid.basicfeatures.EscalatorBasicClientFeatur public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest { - @Test - public void testDetachingAnEmptyEscalator() { + @Before + public void setUp() { setDebug(true); openTestURL(); + } + @Test + public void testDetachingAnEmptyEscalator() { selectMenuPath(GENERAL, DETACH_ESCALATOR); assertEscalatorIsRemovedCorrectly(); } @Test public void testDetachingASemiPopulatedEscalator() throws IOException { - setDebug(true); - openTestURL(); - selectMenuPath(COLUMNS_AND_ROWS, ADD_ONE_OF_EACH_ROW); selectMenuPath(COLUMNS_AND_ROWS, COLUMNS, ADD_ONE_COLUMN_TO_BEGINNING); selectMenuPath(GENERAL, DETACH_ESCALATOR); @@ -49,14 +51,30 @@ public class EscalatorBasicsTest extends EscalatorBasicClientFeaturesTest { @Test public void testDetachingAPopulatedEscalator() { - setDebug(true); - openTestURL(); - selectMenuPath(GENERAL, POPULATE_COLUMN_ROW); selectMenuPath(GENERAL, DETACH_ESCALATOR); assertEscalatorIsRemovedCorrectly(); } + @Test + public void testDetachingAndReattachingAnEscalator() { + selectMenuPath(GENERAL, POPULATE_COLUMN_ROW); + + scrollVerticallyTo(50); + scrollHorizontallyTo(50); + + selectMenuPath(GENERAL, DETACH_ESCALATOR); + selectMenuPath(GENERAL, ATTACH_ESCALATOR); + + assertEquals("Vertical scroll position", "50", getVerticalScrollbar() + .getAttribute("scrollTop")); + assertEquals("Horizontal scroll position", "50", + getHorizontalScrollbar().getAttribute("scrollLeft")); + + assertEquals("First cell of first visible row", "Row 2: 0,2", + getBodyCell(0, 0).getText()); + } + private void assertEscalatorIsRemovedCorrectly() { assertFalse($(NotificationElement.class).exists()); assertNull(getEscalator()); |