diff options
author | Denis Anisimov <denis@vaadin.com> | 2016-09-19 16:26:32 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2016-11-25 08:36:02 +0200 |
commit | 24b43d902c71ea469e2105f3a1c8be2f84610f04 (patch) | |
tree | 89ec5aa0c72433443b7ac5664d2ba293ba41e431 /uitest | |
parent | 4e8eb29c548128a50a000699f60259243e4695ed (diff) | |
download | vaadin-framework-24b43d902c71ea469e2105f3a1c8be2f84610f04.tar.gz vaadin-framework-24b43d902c71ea469e2105f3a1c8be2f84610f04.zip |
Data should be updated when it's set for disabled components.
Fixes vaadin/framework8-issues#286
Change-Id: I0d6cf49addfd558d43671ad2953dee54529392cd
Diffstat (limited to 'uitest')
8 files changed, 224 insertions, 9 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroup.java b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroup.java new file mode 100644 index 0000000000..6af172fa38 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2016 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.checkboxgroup; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CheckBoxGroup; + +/** + * @author Vaadin Ltd + * + */ +public class DisabledCheckBoxGroup extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + CheckBoxGroup<String> group = new CheckBoxGroup<>(); + group.setEnabled(false); + group.setItems("a", "b", "c"); + addComponent(group); + } + +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroup.java b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroup.java new file mode 100644 index 0000000000..255fb074d9 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroup.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2016 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.radiobuttongroup; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.RadioButtonGroup; + +/** + * @author Vaadin Ltd + * + */ +public class DisabledRadioButtonGroup extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + RadioButtonGroup<String> group = new RadioButtonGroup<>(); + group.setEnabled(false); + group.setItems("a", "b", "c"); + addComponent(group); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index 65c12e2687..db630511f1 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -60,12 +60,35 @@ public class CheckBoxGroupTest extends MultiBrowserTest { } @Test + public void disabled_reduceItemCount_containsCorrectItems() { + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "5"); + assertItems(5); + } + + @Test public void initialItems_increaseItemCount_containsCorrectItems() { selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } @Test + public void disabled_increaseItemCountWithinPushRows_containsCorrectItems() { + selectMenuPath("Component", "Data provider", "Items", "5"); + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "20"); + assertItems(20); + } + + @Test + public void disabled_increaseItemCountBeyondPushRows_containsCorrectItems() { + selectMenuPath("Component", "Data provider", "Items", "5"); + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "100"); + assertItems(100); + } + + @Test public void clickToSelect() { selectMenuPath("Component", "Listeners", "Selection listener"); diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java new file mode 100644 index 0000000000..00d6d81cca --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/DisabledCheckBoxGroupTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2016 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.checkboxgroup; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.customelements.CheckBoxGroupElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + * + */ +public class DisabledCheckBoxGroupTest extends MultiBrowserTest { + + @Test + public void initialDataInDisabledCheckBoxGroup() { + openTestURL(); + List<String> options = $(CheckBoxGroupElement.class).first() + .getOptions(); + Assert.assertEquals(3, options.size()); + Assert.assertEquals("a", options.get(0)); + Assert.assertEquals("b", options.get(1)); + Assert.assertEquals("c", options.get(2)); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java index e57b8d3efe..8e15183435 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/InitiallyDisabledGridTest.java @@ -3,7 +3,6 @@ package com.vaadin.tests.components.grid; import java.util.List; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.openqa.selenium.WebElement; @@ -27,12 +26,6 @@ public class InitiallyDisabledGridTest extends SingleBrowserTest { } @Test - @Ignore - /* - * The test fails at the moment because of issues related (or exactly the - * same) as https://github.com/vaadin/framework8-issues/issues/286. It - * should be enabled once it's fixed. - */ public void worksWhenEnabled() { openTestURL(); $(ButtonElement.class).first().click(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java new file mode 100644 index 0000000000..b54737dd72 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/DisabledRadioButtonGroupTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2016 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.radiobuttongroup; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.customelements.RadioButtonGroupElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * @author Vaadin Ltd + * + */ +public class DisabledRadioButtonGroupTest extends MultiBrowserTest { + + @Test + public void initialDataInDisabledCheckBoxGroup() { + openTestURL(); + List<String> options = $(RadioButtonGroupElement.class).first() + .getOptions(); + Assert.assertEquals(3, options.size()); + Assert.assertEquals("a", options.get(0)); + Assert.assertEquals("b", options.get(1)); + Assert.assertEquals("c", options.get(2)); + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java index 0b204aaaeb..c0e0b9cd63 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupTest.java @@ -57,12 +57,35 @@ public class RadioButtonGroupTest extends MultiBrowserTest { } @Test + public void disabled_reduceItemCount_containsCorrectItems() { + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "5"); + assertItems(5); + } + + @Test public void initialItems_increaseItemCount_containsCorrectItems() { selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } @Test + public void disabled_increaseItemCountWithinPushRows_containsCorrectItems() { + selectMenuPath("Component", "Data provider", "Items", "5"); + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "20"); + assertItems(20); + } + + @Test + public void disabled_increaseItemCountBeyondPushRows_containsCorrectItems() { + selectMenuPath("Component", "Data provider", "Items", "5"); + selectMenuPath("Component", "State", "Enabled"); + selectMenuPath("Component", "Data provider", "Items", "100"); + assertItems(100); + } + + @Test public void clickToSelect() { selectMenuPath("Component", "Listeners", "Selection listener"); diff --git a/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java b/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java index b05c64e713..e6eabd8967 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java @@ -60,8 +60,26 @@ public class DummyDataTest extends SingleBrowserTest { public void testDataProviderChangeOnlyOneRequest() { // Change to a new logging data provider $(ButtonElement.class).get(1).click(); - assertEquals("DataProvider change should only cause 1 request", - "3. Backend request #0", getLogRow(0)); + /* + * There are two requests between the server and the client. + * + * But current implementation sends some data in both requests: + * + * - the first roundtrip contains data for initial range (normally + * 0..40) + * + * - the second roundtrip initiated by the client sends remaining data ( + * from 41 to the whole size()) + * + * This differs from the previous behavior: when data provider is + * updated (it doesn't apply for the initially set data provider) no + * data is sent to the client. So this first roundtrip is useless. And + * only the second rountrip is used to send the whole data. + */ + assertEquals("DataProvider change should cause 2 requests", + "3. Backend request #0", getLogRow(1)); + assertEquals("DataProvider change should cause 2 request", + "4. Backend request #1", getLogRow(0)); } @Test |