summaryrefslogtreecommitdiffstats
path: root/uitest/src/test
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2018-02-08 11:20:32 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-02-08 11:20:32 +0200
commit1817a82ed8f3c8839c18d9ce6b68e5838940a22c (patch)
tree3a110ba043aa4bea415b4060c4eba4439703711b /uitest/src/test
parent299520fac11dac9b31d6fd762a3eb76ef827ec5b (diff)
downloadvaadin-framework-1817a82ed8f3c8839c18d9ce6b68e5838940a22c.tar.gz
vaadin-framework-1817a82ed8f3c8839c18d9ce6b68e5838940a22c.zip
Add recursive expand and collapse method to TreeGrid and Tree (#10283)
Diffstat (limited to 'uitest/src/test')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java19
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandCollapseRecursivelyTest.java105
2 files changed, 124 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
index 43c08415df..a96e2d3c1d 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
@@ -95,6 +95,25 @@ public class TreeGridBasicFeaturesTest extends MultiBrowserTest {
assertEquals(3, grid.getRowCount());
assertCellTexts(0, 0, new String[] { "0 | 0", "0 | 1", "0 | 2" });
+ // expand 0 | 0 recursively
+ selectMenuPath("Component", "Features", "Server-side expand",
+ "Expand 0 | 0 recursively");
+ assertEquals(15, grid.getRowCount());
+ assertCellTexts(0, 0, new String[] { "0 | 0", "1 | 0", "2 | 0" });
+
+ // collapse 0 | 0 recursively
+ selectMenuPath("Component", "Features", "Server-side collapse",
+ "Collapse 0 | 0 recursively");
+ assertEquals(3, grid.getRowCount());
+ assertCellTexts(0, 0, new String[] { "0 | 0", "0 | 1", "0 | 2" });
+
+ // expanding 0 | 0 should result in 3 additional nodes after recursive
+ // collapse
+ selectMenuPath("Component", "Features", "Server-side expand",
+ "Expand 0 | 0");
+ assertEquals(6, grid.getRowCount());
+ assertCellTexts(1, 0, new String[] { "1 | 0", "1 | 1", "1 | 2" });
+
assertNoSystemNotifications();
assertNoErrorNotifications();
}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandCollapseRecursivelyTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandCollapseRecursivelyTest.java
new file mode 100644
index 0000000000..6e2451b96a
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandCollapseRecursivelyTest.java
@@ -0,0 +1,105 @@
+package com.vaadin.tests.components.treegrid;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.RadioButtonGroupElement;
+import com.vaadin.testbench.elements.TreeGridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+import static org.junit.Assert.assertEquals;
+
+public class TreeGridExpandCollapseRecursivelyTest extends SingleBrowserTest {
+
+ private static final int rowCount0 = 5;
+ private static final int rowCount1 = rowCount0 + rowCount0 * 5;
+ private static final int rowCount2 =
+ rowCount1 + (rowCount1 - rowCount0) * 5;
+ private static final int rowCount3 =
+ rowCount2 + (rowCount2 - rowCount1) * 5;
+ private static final int rowCount4 =
+ rowCount3 + (rowCount3 - rowCount2) * 5;
+
+ private TreeGridElement grid;
+ private RadioButtonGroupElement depthSelector;
+ private ButtonElement expandButton;
+ private ButtonElement collapseButton;
+
+ @Before
+ public void before() {
+ openTestURL();
+ grid = $(TreeGridElement.class).first();
+ depthSelector = $(RadioButtonGroupElement.class).first();
+ expandButton = $(ButtonElement.class).get(0);
+ collapseButton = $(ButtonElement.class).get(1);
+ }
+
+ @Test
+ public void expandVariousDepth() {
+ assertEquals(rowCount0, grid.getRowCount());
+
+ selectDepth(0);
+ expandButton.click();
+
+ assertEquals(rowCount1, grid.getRowCount());
+
+ selectDepth(1);
+ expandButton.click();
+
+ assertEquals(rowCount2, grid.getRowCount());
+
+ selectDepth(2);
+ expandButton.click();
+
+ assertEquals(rowCount3, grid.getRowCount());
+
+ selectDepth(3);
+ expandButton.click();
+
+ assertEquals(rowCount4, grid.getRowCount());
+ }
+
+ @Test(timeout = 5000)
+ public void expandAndCollapseAllItems() {
+ assertEquals(rowCount0, grid.getRowCount());
+
+ selectDepth(3);
+ expandButton.click();
+
+ assertEquals(rowCount4, grid.getRowCount());
+
+ collapseButton.click();
+
+ assertEquals(rowCount0, grid.getRowCount());
+ }
+
+ @Test
+ public void partialCollapse() {
+ assertEquals(rowCount0, grid.getRowCount());
+
+ selectDepth(3);
+ expandButton.click();
+
+ assertEquals(rowCount4, grid.getRowCount());
+
+ selectDepth(1);
+ collapseButton.click();
+
+ assertEquals(rowCount0, grid.getRowCount());
+
+ selectDepth(0);
+ expandButton.click();
+
+ assertEquals(rowCount1, grid.getRowCount());
+
+ // Open just one subtree to see if it is still fully expanded
+ grid.getExpandElement(2, 0).click();
+
+ assertEquals(rowCount1 + rowCount2, grid.getRowCount());
+ }
+
+ private void selectDepth(int depth) {
+ depthSelector.setValue(String.valueOf(depth));
+ }
+}