tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core.tests / src / org / eclipse / linuxtools / lttng / core / tests / state / resource / LTTngStateResourceTest.java
CommitLineData
03c71d1e
ASL
1/*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
0c32e4c5 3 *
03c71d1e
ASL
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
0c32e4c5 8 *
03c71d1e
ASL
9 * Contributors:
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
6c13869b 12package org.eclipse.linuxtools.lttng.core.tests.state.resource;
03c71d1e
ASL
13
14import junit.framework.TestCase;
15
0c32e4c5 16import org.eclipse.linuxtools.internal.lttng.core.state.resource.ILTTngStateResource.GlobalStateMode;
5945cec9
FC
17import org.eclipse.linuxtools.internal.lttng.core.state.resource.ILttngStateContext;
18import org.eclipse.linuxtools.internal.lttng.core.state.resource.LTTngStateResource;
6c13869b
FC
19import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
20import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
03c71d1e
ASL
21
22/**
23 * For inherited methods see: LTTngTreeNodeTest
0c32e4c5 24 *
03c71d1e 25 * @author alvaro
0c32e4c5 26 *
03c71d1e 27 */
3b38ea61 28@SuppressWarnings("nls")
03c71d1e
ASL
29public class LTTngStateResourceTest extends TestCase {
30 // =======================================================================
31 // Data
32 // =======================================================================
33
34 // Common context for all tests
35 ILttngStateContext context;
36
37 LTTngStateResource node10;
38 LTTngStateResource node20;
39 LTTngStateResource node30;
40 LTTngStateResource node40;
41 LTTngStateResource node50;
42 LTTngStateResource node60;
43
44 LTTngStateResource node15;
45 LTTngStateResource node25;
46 LTTngStateResource node35;
47 LTTngStateResource node45;
48 LTTngStateResource node55;
49 LTTngStateResource node65;
50 LTTngStateResource node67;
51
52 // ========================================================================
53 // Preparations and Finish
54 // =======================================================================
55 /* (non-Javadoc)
56 * @see junit.framework.TestCase#setUp()
57 */
550d787e 58 @Override
03c71d1e
ASL
59 protected void setUp() throws Exception {
60 super.setUp();
61 context = getContext();
62 // Create state resources and assign a parent
63 node10 = new LTTngStateResource(10L, "node10", context, this);
64 node20 = new LTTngStateResource(20L, node10, "node20", context, this);
65 node30 = new LTTngStateResource(30L, node20, "node30", context, this);
66 node40 = new LTTngStateResource(40L, node30, "node40", context, this);
67 node50 = new LTTngStateResource(50L, node40, "node50", context, this);
68 node60 = new LTTngStateResource(60L, node50, "node60", context, this);
0c32e4c5 69
03c71d1e
ASL
70 //Adding first children
71 node10.addChild(node20);
72 node20.addChild(node30);
73 node30.addChild(node40);
74 node40.addChild(node50);
75 node50.addChild(node60);
0c32e4c5 76
03c71d1e
ASL
77 //create additional nodes
78 node15 = new LTTngStateResource(15L, node10, "node15", context, this);
79 node25 = new LTTngStateResource(25L, node20, "node25", context, this);
80 node35 = new LTTngStateResource(35L, node30, "node35", context, this);
81 node45 = new LTTngStateResource(45L, node40, "node45", context, this);
82 node55 = new LTTngStateResource(55L, node50, "node55", context, this);
83 node65 = new LTTngStateResource(65L, node60, "node65", context, this);
84 node67 = new LTTngStateResource(67L, node60, "node67", context, this);
0c32e4c5 85
03c71d1e
ASL
86 // Add more children to instances
87 node10.addChild(node15);
88 node20.addChild(node25);
89 node30.addChild(node35);
90 node40.addChild(node45);
91 node50.addChild(node55);
92 node60.addChild(node65);
93 node60.addChild(node67);
94 }
95
96 /**
97 * @return
98 */
99 private ILttngStateContext getContext() {
100 return new ILttngStateContext() {
101
d4011df2 102 @Override
03c71d1e
ASL
103 public TmfTimeRange getTraceTimeWindow() {
104 return null;
105 }
106
d4011df2 107 @Override
0c32e4c5 108 public ITmfTrace getTraceIdRef() {
03c71d1e
ASL
109 return null;
110 }
111
d4011df2 112 @Override
03c71d1e
ASL
113 public String getTraceId() {
114 return "Test Trace";
115 }
116
d4011df2 117 @Override
03c71d1e
ASL
118 public int getNumberOfCpus() {
119 return 1;
120 }
121
d4011df2 122 @Override
03c71d1e
ASL
123 public TmfTimeRange getExperimentTimeWindow() {
124 return null;
125 }
126
d4011df2 127 @Override
03c71d1e
ASL
128 public String getExperimentName() {
129 return "Test Experiment";
130 }
0c32e4c5 131
b12f4544
FC
132 @Override
133 public long getIdentifier() {
134 return 0;
135 }
03c71d1e
ASL
136 };
137 }
138
139 /* (non-Javadoc)
140 * @see junit.framework.TestCase#tearDown()
141 */
550d787e 142 @Override
03c71d1e
ASL
143 protected void tearDown() throws Exception {
144 super.tearDown();
145 }
146
147 // ========================================================================
148 // Methods
149 // =======================================================================
150 /**
151 * Test method for
5945cec9 152 * {@link org.eclipse.linuxtools.internal.lttng.core.state.resource.LTTngStateResource#getChildren()}
03c71d1e
ASL
153 * .
154 */
155 public void testGetChildren() {
156 LTTngStateResource[] childrensOf60 = node60.getChildren();
157 assertNotNull(childrensOf60);
158
159 int size = childrensOf60.length;
160 assertEquals(2, size);
161
162 LTTngStateResource child65 = childrensOf60[0];
163 LTTngStateResource child67 = childrensOf60[1];
164
165 assertNotNull(child65);
166 assertNotNull(child67);
167
168 assertEquals("node65", child65.getName());
169 assertEquals("node67", child67.getName());
170 }
171
172 /**
173 * Test method for
5945cec9 174 * {@link org.eclipse.linuxtools.internal.lttng.core.state.resource.LTTngStateResource#getStateMode()}
03c71d1e
ASL
175 */
176 public void testStateMode() {
177 // check default
178 assertEquals("unknown", node60.getStateMode().getInName());
179
180 // check setting
181 node60.setStateMode(GlobalStateMode.LTT_STATEMODE_WAIT_FORK);
182 assertEquals("waitfork", node60.getStateMode().getInName());
183
184 }
0c32e4c5 185
03c71d1e
ASL
186 /**
187 * Test method for
5945cec9 188 * {@link org.eclipse.linuxtools.internal.lttng.core.state.resource.LTTngStateResource#getContext()}
03c71d1e
ASL
189 */
190 public void testContext() {
191 assertEquals(context, node60.getContext());
192 }
193}
This page took 0.053125 seconds and 5 git commands to generate.