dropFromCache(cached);
cached = Range.between(0, 0);
- handleMissingRows(getMaxCacheRange());
+ Range maxCacheRange = getMaxCacheRange();
+ if (!maxCacheRange.isEmpty()) {
+ handleMissingRows(maxCacheRange);
+ } else {
+ // There is nothing to fetch. We're done here.
+ getHandlers().forEach(dch -> dch
+ .dataAvailable(cached.getStart(), cached.length()));
+ }
} else {
discardStaleCacheEntries();
import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.AbstractComponentElement;
import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elementsbase.ServerClass;
import com.vaadin.tests.tb3.SingleBrowserTest;
public class DummyDataTest extends SingleBrowserTest {
+ @ServerClass("com.vaadin.tests.data.DummyData.DummyComponent")
+ public static class DummyElement extends AbstractComponentElement {
+ }
+
@Before
public void setUp() {
setDebug(true);
assertEquals("DataSource change should only cause 1 request",
"3. Backend request #0", getLogRow(0));
}
+
+ @Test
+ public void testEmptyAndRestoreContent() {
+ assertEquals("Unexpected amount of content on init.", 300,
+ $(DummyElement.class).first()
+ .findElements(By.className("v-label")).size());
+ // Change to an empty data source
+ $(ButtonElement.class).get(2).click();
+ assertEquals("Empty data source did not work as expected.", 0,
+ $(DummyElement.class).first()
+ .findElements(By.className("v-label")).size());
+ // Change back to logging data source
+ $(ButtonElement.class).get(1).click();
+ assertEquals("Data was not correctly restored.", 300,
+ $(DummyElement.class).first()
+ .findElements(By.className("v-label")).size());
+ }
+
}