aboutsummaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2013-02-21 15:55:57 +0200
committerJohn Ahlroos <john@vaadin.com>2013-02-21 15:55:57 +0200
commit834275130dce0fee314e2c5b0b092579ba3905a4 (patch)
tree04afb32714682eec56248016f5cf072a5a9f626e /server/tests
parentc2cd910f53bd55e3472b3eb11c32f0cd28e5ee8e (diff)
downloadvaadin-framework-834275130dce0fee314e2c5b0b092579ba3905a4.tar.gz
vaadin-framework-834275130dce0fee314e2c5b0b092579ba3905a4.zip
Fixed memory leak in Tree #11053
Change-Id: I4c58367d4041b5e61989fca5be6b037f7f8e0c01
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java
index 16a7091947..f467a42339 100644
--- a/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/tree/TreeTest.java
@@ -1,5 +1,8 @@
package com.vaadin.tests.server.component.tree;
+import java.lang.reflect.Field;
+import java.util.HashSet;
+
import junit.framework.TestCase;
import com.vaadin.data.Container;
@@ -71,4 +74,42 @@ public class TreeTest extends TestCase {
assertTrue(Container.Hierarchical.class.isAssignableFrom(tree4
.getContainerDataSource().getClass()));
}
+
+ public void testRemoveExpandedItems() throws Exception {
+ tree.expandItem("parent");
+ tree.expandItem("child");
+
+ Field expandedField = tree.getClass()
+ .getDeclaredField("expanded");
+ Field expandedItemIdField = tree.getClass().getDeclaredField(
+ "expandedItemId");
+
+ expandedField.setAccessible(true);
+ expandedItemIdField.setAccessible(true);
+
+ HashSet<Object> expanded = (HashSet<Object>) expandedField.get(tree);
+ Object expandedItemId = expandedItemIdField.get(tree);
+
+ assertEquals(2, expanded.size());
+ assertTrue("Contains parent", expanded.contains("parent"));
+ assertTrue("Contains child", expanded.contains("child"));
+ assertEquals("child", expandedItemId);
+
+ tree.removeItem("parent");
+
+ expanded = (HashSet<Object>) expandedField.get(tree);
+ expandedItemId = expandedItemIdField.get(tree);
+
+ assertEquals(1, expanded.size());
+ assertTrue("Contains child", expanded.contains("child"));
+ assertEquals("child", expandedItemId);
+
+ tree.removeItem("child");
+
+ expanded = (HashSet<Object>) expandedField.get(tree);
+ expandedItemId = expandedItemIdField.get(tree);
+
+ assertEquals(0, expanded.size());
+ assertNull(expandedItemId);
+ }
}