diff options
author | Mehdi Javan <32511762+mehdi-vaadin@users.noreply.github.com> | 2018-09-17 16:17:28 +0300 |
---|---|---|
committer | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2018-09-17 16:17:28 +0300 |
commit | 663f12b7f6b6da213ce94c48aef1e789669eb22a (patch) | |
tree | b4c7ce8685490a8086780495f24f109cc38a1080 | |
parent | 7ac738ed8557bd4157224ba1cafc2b0e634246d6 (diff) | |
download | vaadin-framework-663f12b7f6b6da213ce94c48aef1e789669eb22a.tar.gz vaadin-framework-663f12b7f6b6da213ce94c48aef1e789669eb22a.zip |
Fixing RadioButtonGroup exception in Window (#11181)
* discardStaleCacheEntries is moved to a proper place before updating indexToRowMap and keyToIndexMap maps. In its previous place, it cleared the data that was just put in the maps.
Fixes #11143
* Adding test
* Removing extra annotations
* Updating chrome version to 69 in tests (#11182)
* Updating Chrome version to 69
* Updating screenshots taken in Chrome 69
* Fixing screenshots
* Fixing screenshots
* Adding some wait commands to tests
* Fixing screenshots
* Revert: Fixing screenshots
* More screenshots
* - Adding wait commands to make sure the transitions end before screenshot
- Fixing a screenshot
* Correcting a mistake of using wait instead of sleep
* Fixing more screenshots
* Increasing the height of ContextMenu (Because of limitation of new Chrome 69 in terms of minimum window height, ContextMenu size can't be tested with a small height.)
3 files changed, 96 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java b/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java index 139612517e..7a52b0ef95 100644 --- a/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java +++ b/client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java @@ -496,6 +496,9 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> { Range newUsefulData = partition[1]; if (!newUsefulData.isEmpty()) { + if (!cached.isEmpty()) + discardStaleCacheEntries(); + // Update the parts that are actually inside int start = newUsefulData.getStart(); for (int i = start; i < newUsefulData.getEnd(); i++) { @@ -515,7 +518,6 @@ public abstract class AbstractRemoteDataSource<T> implements DataSource<T> { if (cached.isEmpty()) { cached = newUsefulData; } else { - discardStaleCacheEntries(); /* * everything might've become stale so we need to re-check for diff --git a/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindow.java b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindow.java new file mode 100644 index 0000000000..d8b3c43fbc --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindow.java @@ -0,0 +1,48 @@ +package com.vaadin.tests.components.radiobuttongroup; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.RadioButtonGroup; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class RadioButtonGroupInWindow extends AbstractTestUI { + public static final String DEFAULT_DAY_TEXT_FIELD_ID = "defaultDay"; + public static final String OPEN_WINDOW_BUTTON_ID = "openWindowButton"; + public static final String WEEK_DAYS_RADIO_BUTTON_GROUP_ID = "weekDaysRadioButtonGroup"; + + @Override + protected void setup(VaadinRequest request) { + String[] weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", + "Friday", "Saturday", "Sunday" }; + final VerticalLayout layout = new VerticalLayout(); + final RadioButtonGroup<String> radioButtonGroup = new RadioButtonGroup<>(); + radioButtonGroup.setId(WEEK_DAYS_RADIO_BUTTON_GROUP_ID); + radioButtonGroup.setItems(weekdays); + + Window selectDayWindow = new Window("Select day window"); + selectDayWindow.setWidth("500px"); + selectDayWindow.setHeight("500px"); + VerticalLayout verticalLayout = new VerticalLayout(radioButtonGroup); + selectDayWindow.setContent(verticalLayout); + selectDayWindow.setModal(true); + + final TextField defaultDay = new TextField("Default day"); + defaultDay.setId(DEFAULT_DAY_TEXT_FIELD_ID); + defaultDay.setValue(weekdays[3]); + layout.addComponent(defaultDay); + + final UI ui = getUI(); + Button openWindowButton = new Button("Select a day", event -> { + radioButtonGroup.setValue(defaultDay.getValue()); + ui.addWindow(selectDayWindow); + }); + openWindowButton.setId(OPEN_WINDOW_BUTTON_ID); + layout.addComponents(openWindowButton); + + addComponent(layout); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindowTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindowTest.java new file mode 100644 index 0000000000..cdf13e80a6 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindowTest.java @@ -0,0 +1,45 @@ +package com.vaadin.tests.components.radiobuttongroup; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.RadioButtonGroupElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Assert; +import org.junit.Test; + +public class RadioButtonGroupInWindowTest extends MultiBrowserTest { + @Test + public void radioButtonGroup_setFirstItemInWindow_valueShouldBeSet() { + testSetDayInRadioButtonGroup("Monday"); + } + + @Test + public void radioButtonGroup_setLastItemInWindow_valueShouldBeSet() { + testSetDayInRadioButtonGroup("Sunday"); + } + + @Test + public void radioButtonGroup_setMiddleItemInWindow_valueShouldBeSet() { + testSetDayInRadioButtonGroup("Thursday"); + } + + private void testSetDayInRadioButtonGroup(String day) { + openTestURL(); + + TextFieldElement defaultDay = $(TextFieldElement.class) + .id(RadioButtonGroupInWindow.DEFAULT_DAY_TEXT_FIELD_ID); + defaultDay.setValue(day); + ButtonElement openWindowButton = $(ButtonElement.class) + .id(RadioButtonGroupInWindow.OPEN_WINDOW_BUTTON_ID); + openWindowButton.click(); + waitForElementPresent(By + .id(RadioButtonGroupInWindow.WEEK_DAYS_RADIO_BUTTON_GROUP_ID)); + RadioButtonGroupElement radioButtonGroupElement = $( + RadioButtonGroupElement.class).id( + RadioButtonGroupInWindow.WEEK_DAYS_RADIO_BUTTON_GROUP_ID); + Assert.assertEquals( + "The expected value is not set in RadioButtonGroup.", day, + radioButtonGroupElement.getValue()); + } +} |