summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-07-08 19:25:41 +0300
committerVaadin Code Review <review@vaadin.com>2015-07-09 07:05:43 +0000
commit730b3f3af7ea88f830e71f77626b7630c200e9b2 (patch)
treeb2aa8aadfe333d0b35053481347dd36e52a9a09f /uitest
parent94581505567f09e2fa90f4d41b7fea7cbae1b250 (diff)
downloadvaadin-framework-730b3f3af7ea88f830e71f77626b7630c200e9b2.tar.gz
vaadin-framework-730b3f3af7ea88f830e71f77626b7630c200e9b2.zip
Fix Grid detaching with open details rows (#18415)
Change-Id: I035808b02edb5ba8181a5a0baec3432c2283699d
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java138
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java41
2 files changed, 179 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java
new file mode 100644
index 0000000000..c25ad287b7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetach.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Grid.DetailsGenerator;
+import com.vaadin.ui.Grid.RowReference;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridDetailsDetach extends AbstractTestUI {
+
+ private Grid currentGrid;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final VerticalLayout layout = new VerticalLayout();
+ layout.setSizeFull();
+
+ Button button = new Button("Test");
+ layout.addComponent(button);
+ layout.setExpandRatio(button, 0f);
+
+ currentGrid = generateGrid();
+ layout.addComponent(currentGrid);
+ layout.setExpandRatio(currentGrid, 1f);
+
+ button.addClickListener(new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Grid newGrid = generateGrid();
+ layout.replaceComponent(currentGrid, newGrid);
+ currentGrid = newGrid;
+ }
+ });
+
+ addComponent(layout);
+ }
+
+ private Grid generateGrid() {
+ BeanItemContainer<GridExampleBean> container = new BeanItemContainer<GridExampleBean>(
+ GridExampleBean.class);
+ for (int i = 0; i < 1000; i++) {
+ container.addItem(new GridExampleBean("Bean " + i, i * i, i / 10d));
+ }
+
+ final Grid grid = new Grid(container);
+ grid.setColumnOrder("name", "amount", "count");
+ grid.setSizeFull();
+
+ grid.setDetailsGenerator(new DetailsGenerator() {
+ @Override
+ public Component getDetails(RowReference rowReference) {
+ final GridExampleBean bean = (GridExampleBean) rowReference
+ .getItemId();
+ VerticalLayout layout = new VerticalLayout(new Label(
+ "Extra data for " + bean.getName()));
+ layout.setMargin(true);
+ return layout;
+ }
+ });
+
+ grid.addItemClickListener(new ItemClickListener() {
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ Object itemId = event.getItemId();
+ grid.setDetailsVisible(itemId, !grid.isDetailsVisible(itemId));
+ }
+ });
+ return grid;
+ }
+
+ public class GridExampleBean {
+
+ private String name;
+
+ private int count;
+
+ private double amount;
+
+ public GridExampleBean() {
+ }
+
+ public GridExampleBean(String name, int count, double amount) {
+ this.name = name;
+ this.count = count;
+ this.amount = amount;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public double getAmount() {
+ return amount;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java
new file mode 100644
index 0000000000..f9071dd3da
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/grid/GridDetailsDetachTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@TestCategory("grid")
+public class GridDetailsDetachTest extends MultiBrowserTest {
+
+ @Test
+ public void testDetachGridWithDetailsOpen() {
+ setDebug(true);
+ openTestURL();
+
+ $(GridElement.class).first().getCell(3, 0).click();
+
+ assertNoErrorNotifications();
+
+ $(ButtonElement.class).first().click();
+
+ assertNoErrorNotifications();
+ }
+}