summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/data/AbstractRemoteDataSource.java4
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindow.java48
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/radiobuttongroup/RadioButtonGroupInWindowTest.java45
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());
+ }
+}