1
/*******************************************************************************
2
* Copyright (c) 2006 IBM Corporation.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.ui.ide.test.structures;
14
import org.eclipse.linuxtools.systemtap.ui.ide.structures.TreeSettings;
16
import org.eclipse.linuxtools.systemtap.ui.structures.TreeNode;
18
import junit.framework.TestCase;
20
public class TreeSettingsTest extends TestCase {
22
public static void main(String[] args) {
23
//Do not preseve what was in the trees beacuse of invalid date
26
public TreeSettingsTest(String name) {
30
protected void setUp() throws Exception {
33
TreeSettings.setTrees(new TreeNode("func", false), new TreeNode("probe", false));
36
public void testSetTrees() {
37
TreeNode t = new TreeNode("f", false);
38
TreeNode t1 = new TreeNode("as", "as3", false);
39
TreeNode t2 = new TreeNode(null, false);
42
assertTrue("Set tree fine1", TreeSettings.setTrees(t, t));
43
assertTrue("Set tree fine2", TreeSettings.setTrees(t1, t1));
44
assertTrue("Set tree null obj", TreeSettings.setTrees(t2, t2));
45
assertFalse("Set trees null", TreeSettings.setTrees(t3, t3));
46
assertFalse("Set func null", TreeSettings.setTrees(t3, t));
47
assertFalse("Set probe null", TreeSettings.setTrees(t, t3));
50
public void testGetTreeFileDate() {
51
long d1 = TreeSettings.getTreeFileDate();
52
long d2 = TreeSettings.getTreeFileDate();
53
assertEquals("TreeDate same", d1, d2);
55
TreeSettings.setTrees(new TreeNode("f", false), new TreeNode("p", false));
56
d2 = TreeSettings.getTreeFileDate();
58
assertTrue("TreeDate changed", d1 < d2);
61
public void testGetFunctionTree() {
63
TreeNode t = new TreeNode("f", false);
64
TreeNode t1 = new TreeNode(null, false);
65
TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
67
TreeSettings.setTrees(t, t);
68
temp = TreeSettings.getFunctionTree();
69
assertEquals("Funcs no children", 0, temp.getChildCount());
70
assertTrue("Funcs object", t.getData().toString().equals(temp.getData().toString()));
71
assertTrue("Funcs display", t.toString().equals(temp.toString()));
73
TreeSettings.setTrees(t1, t);
74
temp = TreeSettings.getFunctionTree();
75
assertEquals("Funcs no children", 0, temp.getChildCount());
76
assertEquals("Funcs object", t1.getData(), temp.getData());
77
assertEquals("Funcs display", t1.toString(), temp.toString());
79
TreeSettings.setTrees(t2, t);
80
temp = TreeSettings.getFunctionTree();
81
assertEquals("Funcs no children", 0, temp.getChildCount());
82
assertTrue("Funcs object", t2.getData().toString().equals(temp.getData()));
83
assertTrue("Funcs display", t2.toString().equals(temp.toString()));
87
TreeSettings.setTrees(t, t);
88
temp = TreeSettings.getFunctionTree();
89
assertEquals("Funcs has children", 2, temp.getChildCount());
90
assertTrue("Funcs child object", t2.getData().toString().equals(temp.getChildAt(0).getData()));
91
assertTrue("Funcs child display", t2.toString().equals(temp.getChildAt(0).toString()));
94
public void testGetProbeTree() {
96
TreeNode t = new TreeNode("f", false);
97
TreeNode t1 = new TreeNode(null, false);
98
TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
100
TreeSettings.setTrees(t, t);
101
temp = TreeSettings.getProbeTree();
102
assertEquals("Probs no children", 0, temp.getChildCount());
103
assertTrue("Probs object", t.getData().toString().equals(temp.getData().toString()));
104
assertTrue("Probs display", t.toString().equals(temp.toString()));
106
TreeSettings.setTrees(t, t1);
107
temp = TreeSettings.getProbeTree();
108
assertEquals("Probs no children", 0, temp.getChildCount());
109
assertEquals("Probs object", t1.getData(), temp.getData());
110
assertEquals("Probs display", t1.toString(), temp.toString());
112
TreeSettings.setTrees(t, t2);
113
temp = TreeSettings.getProbeTree();
114
assertEquals("Probs no children", 0, temp.getChildCount());
115
assertTrue("Probs object", t2.getData().toString().equals(temp.getData()));
116
assertTrue("Probs display", t2.toString().equals(temp.toString()));
120
TreeSettings.setTrees(t, t);
121
temp = TreeSettings.getProbeTree();
122
assertEquals("Probs has children", 2, temp.getChildCount());
123
assertTrue("Probs child object", t2.getData().toString().equals(temp.getChildAt(0).getData()));
124
assertTrue("Probs child display", t2.toString().equals(temp.getChildAt(0).toString()));
128
protected void tearDown() throws Exception {