From 17b5c8dc396ea87a46ec76689fdff5771fabe5dd Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 24 Nov 2016 11:31:23 +0200 Subject: Re-add body rows when Escalator is reattached to DOM (#20477) Change-Id: I0ae9144817db3bb730c80748d5e9190484b323e7 # Conflicts: # uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/EscalatorBasicClientFeaturesWidget.java --- .../tests/components/grid/MoveGridAndAddRow.java | 45 ++++++++++++++++++++++ .../components/grid/MoveGridAndAddRowTest.java | 21 ++++++++++ 2 files changed, 66 insertions(+) create mode 100644 uitest/src/main/java/com/vaadin/tests/components/grid/MoveGridAndAddRow.java create mode 100644 uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/MoveGridAndAddRow.java b/uitest/src/main/java/com/vaadin/tests/components/grid/MoveGridAndAddRow.java new file mode 100644 index 0000000000..e27c3b5279 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/MoveGridAndAddRow.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.components.grid; + +import java.util.ArrayList; +import java.util.List; + +import com.vaadin.data.ValueProvider; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Grid; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class MoveGridAndAddRow extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + final VerticalLayout layout = new VerticalLayout(); + + final VerticalLayout anotherLayout = new VerticalLayout(); + anotherLayout.addComponent(new Label("This is another layout")); + final Grid grid = new Grid<>(); + grid.addColumn(ValueProvider.identity()).setCaption("A"); + List items = new ArrayList<>(); + items.add("1"); + grid.setItems(items); + + final Button button = new Button("Add row and remove this button"); + button.setId("add"); + button.addClickListener(event -> { + items.add("2"); + grid.setItems(items); + button.setVisible(false); + }); + + Button move = new Button("Move grid to other layout"); + move.setId("move"); + move.addClickListener(event -> anotherLayout.addComponent(grid)); + + layout.addComponents(button, move, grid); + addComponent(new HorizontalLayout(layout, anotherLayout)); + + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java new file mode 100644 index 0000000000..c6d9aa394a --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/MoveGridAndAddRowTest.java @@ -0,0 +1,21 @@ +package com.vaadin.tests.components.grid; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class MoveGridAndAddRowTest extends SingleBrowserTest { + + @Test + public void addRowAndChangeLayout() { + openTestURL(); + $(ButtonElement.class).id("add").click(); + + GridElement grid = $(GridElement.class).first(); + Assert.assertEquals("1", grid.getCell(0, 0).getText()); + Assert.assertEquals("2", grid.getCell(1, 0).getText()); + } +} -- cgit v1.2.3