diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2017-03-21 15:53:59 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-03-21 15:53:59 +0200 |
commit | d1fa1a3efe08e0843a38947dcd8ffe65e04ed12c (patch) | |
tree | a2757bfac569b6e718b68281ba9d2e0a8c6803bb /uitest | |
parent | 2dc8c1b5ad81c0dd800225b6185f47fe952251f7 (diff) | |
download | vaadin-framework-d1fa1a3efe08e0843a38947dcd8ffe65e04ed12c.tar.gz vaadin-framework-d1fa1a3efe08e0843a38947dcd8ffe65e04ed12c.zip |
Add collapse and expand events to TreeGrid (#8889)
Closes #8760
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java | 11 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java | 28 |
2 files changed, 39 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java index 7998537a6e..3b58e6c75e 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeatures.java @@ -54,6 +54,7 @@ public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { createDataProviderSelect(); createHierarchyColumnSelect(); + createListenerMenu(); } private void initializeDataProviders() { @@ -102,6 +103,16 @@ public class TreeGridBasicFeatures extends AbstractComponentTest<TreeGrid> { (treeGrid, value, data) -> treeGrid.setHierarchyColumn(value)); } + @SuppressWarnings("unchecked") + private void createListenerMenu() { + createListenerAction("Collapse listener", "State", + treeGrid -> treeGrid.addCollapseListener(event -> log( + "Item collapsed: " + event.getCollapsedItem()))); + createListenerAction("Expand listener", "State", + treeGrid -> treeGrid.addExpandListener(event -> log( + "Item expanded: " + event.getExpandedItem()))); + } + static class HierarchicalTestBean { private final String id; 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 b01a6273e2..215bef95d2 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 @@ -119,6 +119,34 @@ public class TreeGridBasicFeaturesTest extends MultiBrowserTest { .isElementPresent(By.className("v-tree-grid-expander"))); } + @Test + public void expand_and_collapse_listeners() { + selectMenuPath("Component", "State", "Expand listener"); + selectMenuPath("Component", "State", "Collapse listener"); + + Assert.assertFalse(logContainsText("Item expanded: 0 | 0")); + Assert.assertFalse(logContainsText("Item collapsed: 0 | 0")); + + grid.collapseWithClick(0); + + Assert.assertTrue(logContainsText("Item expanded: 0 | 0")); + Assert.assertFalse(logContainsText("Item collapsed: 0 | 0")); + + grid.collapseWithClick(0); + + Assert.assertTrue(logContainsText("Item expanded: 0 | 0")); + Assert.assertTrue(logContainsText("Item collapsed: 0 | 0")); + + selectMenuPath("Component", "State", "Expand listener"); + selectMenuPath("Component", "State", "Collapse listener"); + + grid.collapseWithClick(1); + grid.collapseWithClick(1); + + Assert.assertFalse(logContainsText("Item expanded: 0 | 1")); + Assert.assertFalse(logContainsText("Item collapsed: 0 | 1")); + } + private void assertCellTexts(int startRowIndex, int cellIndex, String[] cellTexts) { int index = startRowIndex; |