]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix exception when Grid is inside a PopupView (#8157)
authorArtur <artur@vaadin.com>
Tue, 10 Jan 2017 13:22:31 +0000 (15:22 +0200)
committerAleksi Hietanen <aleksi@vaadin.com>
Tue, 10 Jan 2017 13:22:31 +0000 (15:22 +0200)
Fixes #7695

client/src/main/java/com/vaadin/client/ui/VPopupView.java
uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupView.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupViewTest.java [new file with mode: 0644]

index 11a38b67375c537647bb139048b70c4a7ae06478..28ad7d66c4ed0665dfebdd3faaa71e2fa14a0b0a 100644 (file)
@@ -373,9 +373,14 @@ public class VPopupView extends HTML
                 }
             } else if (popupComponentWidget2 instanceof HasWidgets) {
                 HasWidgets hw = (HasWidgets) popupComponentWidget2;
-                Iterator<Widget> iterator = hw.iterator();
-                while (iterator.hasNext()) {
-                    checkForRTE(iterator.next());
+                try {
+                    Iterator<Widget> iterator = hw.iterator();
+                    while (iterator.hasNext()) {
+                        checkForRTE(iterator.next());
+                    }
+                } catch (UnsupportedOperationException e) {
+                    // At least Grid refuses to provide child widgets through
+                    // iterator()
                 }
             }
         }
diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupView.java b/uitest/src/main/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupView.java
new file mode 100644 (file)
index 0000000..ad76fb2
--- /dev/null
@@ -0,0 +1,45 @@
+package com.vaadin.tests.layouts.layouttester.GridLayout;
+
+import com.vaadin.event.SelectionEvent;
+import com.vaadin.event.SelectionEvent.SelectionListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.tests.util.Person;
+import com.vaadin.tests.util.PersonContainer;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.PopupView;
+import com.vaadin.ui.PopupView.Content;
+import com.vaadin.ui.VerticalLayout;
+
+public class GridInPopupView extends AbstractTestUIWithLog {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final Grid grid = new Grid(PersonContainer.createWithTestData(100));
+        grid.addSelectionListener(new SelectionListener() {
+            @Override
+            public void select(SelectionEvent event) {
+                String sel = "";
+                for (Object o : event.getSelected()) {
+                    sel += ((Person) o).getFirstName();
+                }
+                log("Selection: " + sel);
+            }
+        });
+        PopupView pv = new PopupView(new Content() {
+            @Override
+            public Component getPopupComponent() {
+                return new VerticalLayout(grid);
+            }
+
+            @Override
+            public String getMinimizedValueAsHTML() {
+                return "foo";
+            }
+        });
+        pv.setHideOnMouseOut(false);
+        addComponent(pv);
+    }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupViewTest.java b/uitest/src/test/java/com/vaadin/tests/layouts/layouttester/GridLayout/GridInPopupViewTest.java
new file mode 100644 (file)
index 0000000..6a04119
--- /dev/null
@@ -0,0 +1,25 @@
+package com.vaadin.tests.layouts.layouttester.GridLayout;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.testbench.elements.PopupViewElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class GridInPopupViewTest extends SingleBrowserTest {
+
+    @Test
+    public void popupViewClosedProperly() {
+        openTestURL();
+        PopupViewElement pv = $(PopupViewElement.class).first();
+        pv.click();
+        GridElement grid = $(GridElement.class).first();
+        grid.getCell(5, 0).click();
+        findElement(By.className("v-ui")).click();
+
+        Assert.assertTrue($(GridElement.class).all().isEmpty());
+        Assert.assertEquals("1. Selection: Alice", getLogRow(0));
+    }
+}