~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/structures/TreeSettingsTest.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
 
10
 *******************************************************************************/
 
11
 
 
12
package org.eclipse.linuxtools.systemtap.ui.ide.test.structures;
 
13
 
 
14
import org.eclipse.linuxtools.systemtap.ui.ide.structures.TreeSettings;
 
15
 
 
16
import org.eclipse.linuxtools.systemtap.ui.structures.TreeNode;
 
17
 
 
18
import junit.framework.TestCase;
 
19
 
 
20
public class TreeSettingsTest extends TestCase {
 
21
 
 
22
        public static void main(String[] args) {
 
23
                //Do not preseve what was in the trees beacuse of invalid date
 
24
        }
 
25
 
 
26
        public TreeSettingsTest(String name) {
 
27
                super(name);
 
28
        }
 
29
 
 
30
        protected void setUp() throws Exception {
 
31
                super.setUp();
 
32
                
 
33
                TreeSettings.setTrees(new TreeNode("func", false), new TreeNode("probe", false));
 
34
        }
 
35
 
 
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);
 
40
                TreeNode t3 = null;
 
41
 
 
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));
 
48
        }
 
49
        
 
50
        public void testGetTreeFileDate() {
 
51
                long d1 = TreeSettings.getTreeFileDate();
 
52
                long d2 = TreeSettings.getTreeFileDate();
 
53
                assertEquals("TreeDate same", d1, d2);
 
54
                
 
55
                TreeSettings.setTrees(new TreeNode("f", false), new TreeNode("p", false));
 
56
                d2 = TreeSettings.getTreeFileDate();
 
57
                
 
58
                assertTrue("TreeDate changed", d1 < d2);
 
59
        }
 
60
 
 
61
        public void testGetFunctionTree() {
 
62
                TreeNode temp;
 
63
                TreeNode t = new TreeNode("f", false);
 
64
                TreeNode t1 = new TreeNode(null, false);
 
65
                TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
 
66
                
 
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()));
 
72
 
 
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());
 
78
 
 
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()));
 
84
 
 
85
                t.add(t2);
 
86
                t.add(t1);
 
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()));
 
92
        }
 
93
        
 
94
        public void testGetProbeTree() {
 
95
                TreeNode temp;
 
96
                TreeNode t = new TreeNode("f", false);
 
97
                TreeNode t1 = new TreeNode(null, false);
 
98
                TreeNode t2 = new TreeNode(new StringBuilder("asfd"), true);
 
99
                
 
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()));
 
105
 
 
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());
 
111
 
 
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()));
 
117
 
 
118
                t.add(t2);
 
119
                t.add(t1);
 
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()));
 
125
 
 
126
        }
 
127
        
 
128
        protected void tearDown() throws Exception {
 
129
                super.tearDown();
 
130
        }
 
131
}