Search in sources :

Example 1 with TreeWith3Levels

use of org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeWith3Levels in project scout.rt by eclipse.

the class JsonTreeTest method testDispose.

@Test
public void testDispose() {
    ITree tree = new TreeWith3Levels();
    tree.initTree();
    JsonTree<ITree> object = UiSessionTestUtility.newJsonAdapter(m_uiSession, tree, null);
    WeakReference<JsonTree> ref = new WeakReference<JsonTree>(object);
    object.dispose();
    m_uiSession = null;
    object = null;
    TestingUtility.assertGC(ref);
}
Also used : WeakReference(java.lang.ref.WeakReference) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) TreeWith3Levels(org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeWith3Levels) Test(org.junit.Test)

Example 2 with TreeWith3Levels

use of org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeWith3Levels in project scout.rt by eclipse.

the class JsonTreeTest method testNodeDisposalRec.

// @Test
// public void testNodeAndUserFilter() throws JSONException {
// TreeNode node0 = new TreeNode();
// TreeNode node1 = new TreeNode();
// TreeNode node2 = new TreeNode();
// List<ITreeNode> nodes = new ArrayList<ITreeNode>();
// nodes.add(node0);
// nodes.add(node1);
// nodes.add(node2);
// ITree tree = createTree(nodes);
// JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
// jsonTree.toJson();
// 
// String node0Id = jsonTree.getOrCreateNodeId(nodes.get(0));
// assertNotNull(node0Id);
// assertNotNull(jsonTree.getNode(node0Id));
// 
// node0.setEnabled(false);
// tree.addNodeFilter(new ITreeNodeFilter() {
// 
// @Override
// public boolean accept(ITreeNode node, int level) {
// return node.isEnabled();
// }
// });
// 
// JsonEvent event = createJsonRowsFilteredEvent(row0Id, row2Id);
// jsonTree.handleUiEvent(event);
// 
// JsonTestUtility.processBufferedEvents(m_uiSession);
// assertNull(jsonTree.getNodeId(nodes.get(0)));
// assertNull(jsonTree.getNode(node0Id));
// 
// List<JsonEvent> events = m_uiSession.currentJsonResponse().getEventList();
// assertEquals(1, events.size());
// assertEventTypeAndNodeIds(events.get(0), "nodesDeleted", node0Id);
// }
/**
 * Tests whether the child nodes gets removed from the maps after deletion (m_treeNodes, m_treeNodeIds)
 */
@Test
public void testNodeDisposalRec() throws JSONException {
    ITree tree = new TreeWith3Levels();
    tree.initTree();
    List<ITreeNode> allNodes = getAllTreeNodes(tree);
    List<String> allNodeIds = new LinkedList<String>();
    JsonTree<ITree> jsonTree = m_uiSession.createJsonAdapter(tree, null);
    for (ITreeNode node : allNodes) {
        String nodeId = jsonTree.getOrCreateNodeId(node);
        allNodeIds.add(nodeId);
        assertNotNull(nodeId);
        assertNotNull(jsonTree.optTreeNodeForNodeId(nodeId));
        assertNotNull(jsonTree.getParentNode(node));
    }
    tree.removeNode(allNodes.get(0));
    JsonTestUtility.processBufferedEvents(m_uiSession);
    for (ITreeNode node : allNodes) {
        assertNull(jsonTree.optNodeId(node));
        assertNull(jsonTree.getParentNode(node));
        assertEquals(0, jsonTree.getChildNodes(node).size());
    }
    for (String nodeId : allNodeIds) {
        assertNull(jsonTree.optTreeNodeForNodeId(nodeId));
    }
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) TreeWith3Levels(org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeWith3Levels) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)2 TreeWith3Levels (org.eclipse.scout.rt.ui.html.json.tree.fixtures.TreeWith3Levels)2 Test (org.junit.Test)2 WeakReference (java.lang.ref.WeakReference)1 LinkedList (java.util.LinkedList)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1