]> source.dussan.org Git - vaadin-framework.git/commitdiff
Force re-measurement of CheckBoxGroup and RadioButtonGroup (#9901)
authorPetter Holmström <petter.holmstrom@outlook.com>
Mon, 4 Sep 2017 13:40:38 +0000 (16:40 +0300)
committerHenri Sara <henri.sara@gmail.com>
Mon, 4 Sep 2017 13:40:38 +0000 (16:40 +0300)
The related tests have a workaround for another (Chrome specific) GridLayout bug #9921.
Those workarounds should be removed once that issue is fixed.

Fixes #9148

client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java
client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java
tests/screenshots
uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayout.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayout.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java [new file with mode: 0644]
uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java [new file with mode: 0644]

index 18d4019611825a5c6b5b8158a9baf63f8fe68a72..1ab5c1d5912c632179dd8dfda0656b36a057e46b 100644 (file)
@@ -89,6 +89,7 @@ public class CheckBoxGroupConnector
             items.add(item);
         }
         getWidget().buildOptions(items);
+        getLayoutManager().setNeedsMeasure(this);
     }
 
     @Override
index 882a91aa26a62f70032de7b37c463422f8d474d5..21ffec25075f42746590f29fa251d306e0a08863 100644 (file)
@@ -121,6 +121,7 @@ public class RadioButtonGroupConnector
             options.add(dataSource.getRow(i));
         }
         select.buildOptions(options);
+        getLayoutManager().setNeedsMeasure(this);
         updateSelectedItem();
     }
 
index 52b1a4148ba8b3a6a74278e4d7d041aa6d6620b7..0cff74a59932e44a89ea1146b0e4b56b9928a209 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 52b1a4148ba8b3a6a74278e4d7d041aa6d6620b7
+Subproject commit 0cff74a59932e44a89ea1146b0e4b56b9928a209
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayout.java b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayout.java
new file mode 100644 (file)
index 0000000..7a50255
--- /dev/null
@@ -0,0 +1,26 @@
+package com.vaadin.tests.components.checkboxgroup;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBoxGroup;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.themes.ValoTheme;
+
+public class CheckBoxGroupInGridLayout extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        CheckBoxGroup<String> cbGroup = new CheckBoxGroup<>(null, DataProvider.ofItems("A", "B", "C"));
+        cbGroup.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
+
+        GridLayout gridLayout = new GridLayout(2, 1);
+        gridLayout.addComponent(cbGroup, 0, 0);
+        gridLayout.setSpacing(true);
+
+        gridLayout.addComponent(new TextField(), 1, 0);
+
+        addComponent(gridLayout);
+    }
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayout.java b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayout.java
new file mode 100644 (file)
index 0000000..dcd0ab0
--- /dev/null
@@ -0,0 +1,26 @@
+package com.vaadin.tests.components.radiobuttongroup;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.RadioButtonGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.themes.ValoTheme;
+
+public class RadioButtonGroupInGridLayout extends AbstractTestUI {
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        RadioButtonGroup<String> cbGroup = new RadioButtonGroup<>(null, DataProvider.ofItems("A", "B", "C"));
+        cbGroup.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
+
+        GridLayout gridLayout = new GridLayout(2, 1);
+        gridLayout.addComponent(cbGroup, 0, 0);
+        gridLayout.setSpacing(true);
+
+        gridLayout.addComponent(new TextField(), 1, 0);
+
+        addComponent(gridLayout);
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java
new file mode 100644 (file)
index 0000000..0aade00
--- /dev/null
@@ -0,0 +1,32 @@
+package com.vaadin.tests.components.checkboxgroup;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.CheckBoxGroupElement;
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class CheckBoxGroupInGridLayoutTest extends MultiBrowserTest {
+
+    @Test
+    public void slotSizeRemainsUnchangedAfterSelectingItem() {
+        openTestURL();
+        GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
+        int before = gridLayout.getSize().getWidth();
+
+        CheckBoxGroupElement checkBoxGroup = $(CheckBoxGroupElement.class)
+                .first();
+        checkBoxGroup.setValue("A");
+        int after = gridLayout.getSize().getWidth();
+
+        boolean ok = (before == after);
+        // also accept broken layout for unrelated bug #9921 until it is fixed
+        if (!ok && BrowserUtil.isChrome(getDesiredCapabilities())) {
+            ok = (before == after + 4);
+        }
+
+        Assert.assertTrue("GridLayout size changed when selecting a value", ok);
+    }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java
new file mode 100644 (file)
index 0000000..5d7aa37
--- /dev/null
@@ -0,0 +1,32 @@
+package com.vaadin.tests.components.radiobuttongroup;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.elements.RadioButtonGroupElement;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class RadioButtonGroupInGridLayoutTest extends MultiBrowserTest {
+
+    @Test
+    public void slotSizeRemainsUnchangedAfterSelectingItem() {
+        openTestURL();
+        GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
+        int before = gridLayout.getSize().getWidth();
+
+        RadioButtonGroupElement radioButtonGroup = $(
+                RadioButtonGroupElement.class).first();
+        radioButtonGroup.setValue("A");
+        int after = gridLayout.getSize().getWidth();
+
+        boolean ok = (before == after);
+        // also accept broken layout for unrelated bug #9921 until it is fixed
+        if (!ok && BrowserUtil.isChrome(getDesiredCapabilities())) {
+            ok = (before == after + 4);
+        }
+
+        Assert.assertTrue("GridLayout size changed when selecting a value", ok);
+    }
+}