diff options
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/data/DummyData.java | 3 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java index 60b3af7681..8b4083d834 100644 --- a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java +++ b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java @@ -112,6 +112,9 @@ public class DummyData extends AbstractTestUIWithLog { controls.addComponent(new Button("Reset data source", e -> { dummy.setDataSource(new LoggingDataSource(items)); })); + controls.addComponent(new Button("Remove all data", e -> { + dummy.setDataSource(new LoggingDataSource(Collections.emptyList())); + })); addComponent(dummy); } } 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 48001ef27f..1e9f0f9ade 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java @@ -10,11 +10,17 @@ import org.junit.Test; 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); @@ -57,4 +63,22 @@ public class DummyDataTest extends SingleBrowserTest { 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()); + } + } |