summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Holmström <petter.holmstrom@outlook.com>2017-09-04 16:40:38 +0300
committerHenri Sara <henri.sara@gmail.com>2017-09-04 16:40:38 +0300
commita75117689e09e507c88bc6faa4144e56b041498b (patch)
tree383a98b5e730a764e1fc053be395ed9cfb04aecc
parent73c461e33634e3db54dd9189a5a212ec8d9212cd (diff)
downloadvaadin-framework-a75117689e09e507c88bc6faa4144e56b041498b.tar.gz
vaadin-framework-a75117689e09e507c88bc6faa4144e56b041498b.zip
Force re-measurement of CheckBoxGroup and RadioButtonGroup (#9901)
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
-rw-r--r--client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java1
-rw-r--r--client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java1
m---------tests/screenshots0
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayout.java26
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayout.java26
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java32
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java32
7 files changed, 118 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java b/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java
index 18d4019611..1ab5c1d591 100644
--- a/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java
@@ -89,6 +89,7 @@ public class CheckBoxGroupConnector
items.add(item);
}
getWidget().buildOptions(items);
+ getLayoutManager().setNeedsMeasure(this);
}
@Override
diff --git a/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java b/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java
index 882a91aa26..21ffec2507 100644
--- a/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java
@@ -121,6 +121,7 @@ public class RadioButtonGroupConnector
options.add(dataSource.getRow(i));
}
select.buildOptions(options);
+ getLayoutManager().setNeedsMeasure(this);
updateSelectedItem();
}
diff --git a/tests/screenshots b/tests/screenshots
-Subproject 52b1a4148ba8b3a6a74278e4d7d041aa6d6620b
+Subproject 0cff74a59932e44a89ea1146b0e4b56b9928a20
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
index 0000000000..7a50255000
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayout.java
@@ -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
index 0000000000..dcd0ab08f2
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayout.java
@@ -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
index 0000000000..0aade000fd
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupInGridLayoutTest.java
@@ -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
index 0000000000..5d7aa373f4
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInGridLayoutTest.java
@@ -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);
+ }
+}