diff options
author | Petter Holmström <petter.holmstrom@outlook.com> | 2017-09-04 16:40:38 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-04 16:40:38 +0300 |
commit | a75117689e09e507c88bc6faa4144e56b041498b (patch) | |
tree | 383a98b5e730a764e1fc053be395ed9cfb04aecc /uitest | |
parent | 73c461e33634e3db54dd9189a5a212ec8d9212cd (diff) | |
download | vaadin-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
Diffstat (limited to 'uitest')
4 files changed, 116 insertions, 0 deletions
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); + } +} |