Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
2ba3d0a1 | 2 | * Copyright (c) 2012, 2013 Ericsson |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
2ba3d0a1 | 11 | * Alexandre Montplaisir - Port to JUnit4 |
eb1bab5b | 12 | **********************************************************************/ |
2ba3d0a1 | 13 | |
115b4a01 | 14 | package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component; |
eb1bab5b | 15 | |
2ba3d0a1 AM |
16 | import static org.junit.Assert.*; |
17 | ||
eb1bab5b BH |
18 | import java.util.LinkedList; |
19 | import java.util.List; | |
20 | ||
ea21cd65 | 21 | import org.eclipse.core.commands.ExecutionException; |
9315aeee | 22 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState; |
115b4a01 BH |
23 | import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy; |
24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView; | |
25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; | |
26 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponentChangedListener; | |
115b4a01 BH |
27 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent; |
28 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlRoot; | |
29 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService; | |
30 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService; | |
eb1bab5b BH |
31 | import org.eclipse.swt.graphics.Image; |
32 | import org.eclipse.ui.ISharedImages; | |
33 | import org.eclipse.ui.PlatformUI; | |
2ba3d0a1 | 34 | import org.junit.Test; |
eb1bab5b BH |
35 | |
36 | /** | |
2ba3d0a1 AM |
37 | * The class <code>TraceControlComponentTest</code> contains tests for the class |
38 | * <code>{@link TraceControlComponent}</code>. | |
eb1bab5b | 39 | */ |
2ba3d0a1 | 40 | public class TraceControlComponentTest { |
cfdb727a | 41 | |
eb1bab5b BH |
42 | /** |
43 | * Run the TraceControlComponent(String) constructor test. | |
44 | */ | |
2ba3d0a1 | 45 | @Test |
ea21cd65 | 46 | public void testTraceControlComponent_1() { |
cfdb727a | 47 | |
eb1bab5b BH |
48 | String name = "node"; |
49 | ||
50 | TraceControlComponent result = new TraceControlComponent(name); | |
51 | ||
52 | assertNotNull(result); | |
53 | assertEquals(name, result.getName()); | |
54 | assertEquals(null, result.getParent()); | |
55 | assertEquals(false, result.hasChildren()); | |
56 | assertEquals(null, result.getImage()); | |
57 | assertEquals(null, result.getControlService()); | |
58 | assertEquals(null, result.getToolTip()); | |
59 | } | |
60 | ||
61 | /** | |
62 | * Run the TraceControlComponent(String,ITraceControlComponent) constructor test. | |
eb1bab5b | 63 | */ |
2ba3d0a1 | 64 | @Test |
ea21cd65 | 65 | public void testTraceControlComponent_2() { |
eb1bab5b BH |
66 | String name = "node"; |
67 | ||
68 | ITraceControlComponent parent = new TraceControlRoot(); | |
69 | TraceControlComponent result = new TraceControlComponent(name, parent); | |
70 | ||
71 | assertNotNull(result); | |
72 | assertEquals(name, result.getName()); | |
73 | assertEquals(false, result.hasChildren()); | |
74 | assertEquals(null, result.getImage()); | |
75 | assertEquals(null, result.getControlService()); | |
76 | assertEquals(null, result.getToolTip()); | |
77 | } | |
78 | ||
79 | /** | |
80 | * Run the void addChild(ITraceControlComponent) method test. | |
eb1bab5b | 81 | */ |
2ba3d0a1 | 82 | @Test |
ea21cd65 | 83 | public void testAddAndGetChild1() { |
eb1bab5b BH |
84 | TraceControlComponent fixture = new TraceControlComponent("node", new TraceControlRoot()); |
85 | fixture.setToolTip("This is the test node"); | |
86 | fixture.addChild(new TraceControlRoot()); | |
87 | ITraceControlComponent component = new TraceControlRoot(); | |
88 | fixture.addChild(component); | |
cfdb727a | 89 | |
eb1bab5b BH |
90 | ITraceControlComponent child = fixture.getChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME); |
91 | assertNotNull(child); | |
92 | assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, child.getName()); | |
93 | } | |
94 | ||
95 | /** | |
96 | * Run the void addChild(ITraceControlComponent) method test. | |
eb1bab5b | 97 | */ |
2ba3d0a1 | 98 | @Test |
ea21cd65 | 99 | public void testAddAndGetChild2() { |
eb1bab5b BH |
100 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
101 | fixture.setToolTip(""); | |
102 | ITraceControlComponent component = null; | |
103 | ||
104 | fixture.addChild(component); | |
105 | assertFalse(fixture.hasChildren()); | |
106 | } | |
107 | ||
108 | /** | |
109 | * Run the void addComponentListener(ITraceControlComponentChangedListener) method test. | |
eb1bab5b | 110 | */ |
2ba3d0a1 | 111 | @Test |
ea21cd65 | 112 | public void testAddComponentListener_1() { |
eb1bab5b BH |
113 | TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null); |
114 | fixture.setToolTip(""); | |
115 | ||
116 | ListenerValidator validator = new ListenerValidator(); | |
117 | fixture.addComponentListener(validator); | |
118 | ||
119 | TraceControlRoot root = new TraceControlRoot(); | |
120 | fixture.addChild(root); | |
121 | assertTrue(validator.isAddedCalled()); | |
cfdb727a | 122 | |
eb1bab5b BH |
123 | fixture.removeChild(root); |
124 | assertTrue(validator.isRemovedCalled()); | |
125 | ||
4775bcbf | 126 | fixture.fireComponentChanged(fixture); |
eb1bab5b BH |
127 | assertTrue(validator.isChangedCalled()); |
128 | } | |
129 | ||
130 | /** | |
131 | * Run the boolean containsChild(String) method test. | |
eb1bab5b | 132 | */ |
2ba3d0a1 | 133 | @Test |
ea21cd65 | 134 | public void testContainsChild_1() { |
eb1bab5b BH |
135 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
136 | fixture.setToolTip(""); | |
137 | fixture.addChild(new TraceControlRoot()); | |
138 | String name = "node"; | |
139 | ||
140 | boolean result = fixture.containsChild(name); | |
141 | ||
142 | assertEquals(false, result); | |
143 | } | |
144 | ||
145 | /** | |
146 | * Run the boolean containsChild(String) method test. | |
eb1bab5b | 147 | */ |
2ba3d0a1 | 148 | @Test |
ea21cd65 | 149 | public void testContainsChild_2() { |
eb1bab5b BH |
150 | TraceControlComponent fixture = new TraceControlComponent("name", new TraceControlRoot()); |
151 | fixture.setToolTip(""); | |
152 | ||
153 | boolean result = fixture.containsChild(TraceControlRoot.TRACE_CONTROL_ROOT_NAME); | |
154 | ||
155 | assertEquals(false, result); | |
156 | } | |
157 | ||
158 | /** | |
159 | * Run the void fireCompenentAdded(ITraceControlComponent,ITraceControlComponent) method test. | |
160 | * Run the void fireCompenentRemoved(ITraceControlComponent,ITraceControlComponent) method test. | |
161 | * Run the void fireCompenentChanged(ITraceControlComponent) method test | |
eb1bab5b | 162 | */ |
2ba3d0a1 | 163 | @Test |
ea21cd65 | 164 | public void testFireCompenentUpdated() { |
eb1bab5b | 165 | ITraceControlComponent parent = new TraceControlRoot(); |
cfdb727a | 166 | |
eb1bab5b BH |
167 | TraceControlComponent fixture = new TraceControlComponent("node", parent); |
168 | fixture.setToolTip(""); | |
cfdb727a | 169 | |
eb1bab5b BH |
170 | ITraceControlComponent component = new TraceControlComponent("child"); |
171 | fixture.addChild(component); | |
172 | ||
173 | ListenerValidator validator = new ListenerValidator(); | |
174 | fixture.addComponentListener(validator); | |
175 | ||
4775bcbf | 176 | fixture.fireComponentAdded(parent, component); |
eb1bab5b BH |
177 | assertTrue(validator.isAddedCalled()); |
178 | assertEquals(parent.getName(), validator.getSavedParent().getName()); | |
179 | assertEquals(component.getName(), validator.getSavedChild().getName()); | |
cfdb727a | 180 | |
eb1bab5b | 181 | validator.initialize(); |
cfdb727a | 182 | |
4775bcbf | 183 | fixture.fireComponentRemoved(parent, component); |
eb1bab5b BH |
184 | assertTrue(validator.isRemovedCalled()); |
185 | assertEquals(parent.getName(), validator.getSavedParent().getName()); | |
186 | assertEquals(component.getName(), validator.getSavedChild().getName()); | |
187 | ||
188 | validator.initialize(); | |
4775bcbf | 189 | fixture.fireComponentChanged(fixture); |
eb1bab5b BH |
190 | assertTrue(validator.isChangedCalled()); |
191 | assertEquals(fixture.getName(), validator.getSavedComponent().getName()); | |
192 | } | |
193 | ||
194 | /** | |
195 | * Run the Object getAdapter(Class) method test. | |
eb1bab5b | 196 | */ |
2ba3d0a1 | 197 | @Test |
ea21cd65 | 198 | public void testGetAdapter() { |
eb1bab5b BH |
199 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
200 | fixture.setToolTip(""); | |
201 | fixture.addChild(new TraceControlRoot()); | |
202 | Class<Object> adapter = Object.class; | |
203 | ||
204 | Object result = fixture.getAdapter(adapter); | |
205 | ||
206 | assertEquals(null, result); | |
207 | } | |
208 | ||
209 | /** | |
210 | * Run the ITraceControlComponent[] getChildren() method test. | |
eb1bab5b | 211 | */ |
2ba3d0a1 | 212 | @Test |
ea21cd65 | 213 | public void testGetChildren_1() { |
eb1bab5b BH |
214 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
215 | fixture.setToolTip(""); | |
216 | fixture.addChild(new TraceControlRoot()); | |
217 | ||
218 | ITraceControlComponent[] result = fixture.getChildren(); | |
219 | ||
220 | assertNotNull(result); | |
221 | assertEquals(1, result.length); | |
222 | assertNotNull(result[0]); | |
223 | assertEquals("trace_control_root", result[0].getName()); | |
224 | assertEquals(null, result[0].getParent()); | |
225 | assertEquals(false, result[0].hasChildren()); | |
226 | assertEquals(null, result[0].getImage()); | |
227 | assertEquals(null, result[0].getControlService()); | |
228 | assertEquals(null, result[0].getToolTip()); | |
229 | } | |
230 | ||
231 | /** | |
ea21cd65 AM |
232 | * Run the ILttngControlService getControlService()/setControlService() |
233 | * method test. | |
eb1bab5b | 234 | * |
ea21cd65 AM |
235 | * @throws ExecutionException |
236 | * Would fail the test | |
eb1bab5b | 237 | */ |
2ba3d0a1 | 238 | @Test |
ea21cd65 | 239 | public void testGetAndSetControlService_1() throws ExecutionException { |
cfdb727a | 240 | |
eb1bab5b BH |
241 | TraceControlComponent parent = new TraceControlComponent("parent") { |
242 | ILttngControlService fService = null; | |
cfdb727a | 243 | |
eb1bab5b BH |
244 | @Override |
245 | public void setControlService(ILttngControlService service ) { | |
246 | fService = service; | |
247 | } | |
cfdb727a | 248 | |
eb1bab5b BH |
249 | @Override |
250 | public ILttngControlService getControlService() { | |
251 | return fService; | |
252 | } | |
253 | }; | |
cfdb727a | 254 | |
eb1bab5b BH |
255 | TraceControlComponent fixture = new TraceControlComponent("", parent); |
256 | parent.addChild(fixture); | |
257 | fixture.setToolTip(""); | |
258 | TraceControlComponent child = new TraceControlComponent("child", fixture); | |
259 | fixture.addChild(child); | |
cfdb727a | 260 | |
eb1bab5b BH |
261 | ILttngControlService result = fixture.getControlService(); |
262 | assertEquals(null, result); | |
cfdb727a | 263 | |
eb1bab5b BH |
264 | TestRemoteSystemProxy proxy = new TestRemoteSystemProxy(); |
265 | ILttngControlService service = new LTTngControlService(proxy.createCommandShell()); | |
266 | fixture.setControlService(service); | |
267 | result = fixture.getControlService(); | |
268 | assertNotNull(service); | |
269 | assertEquals(service, result); | |
cfdb727a | 270 | |
eb1bab5b BH |
271 | result = fixture.getChildren()[0].getControlService(); |
272 | assertNotNull(service); | |
273 | assertEquals(service, result); | |
274 | } | |
275 | ||
276 | /** | |
277 | * Run the Image getImage() method test. | |
eb1bab5b | 278 | */ |
2ba3d0a1 | 279 | @Test |
ea21cd65 | 280 | public void testGetImage_1() { |
eb1bab5b BH |
281 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
282 | fixture.setToolTip(""); | |
283 | fixture.addChild(new TraceControlRoot()); | |
284 | ||
285 | Image result = fixture.getImage(); | |
286 | assertEquals(null, result); | |
cfdb727a | 287 | |
eb1bab5b BH |
288 | fixture.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)); |
289 | assertNotNull(fixture.getImage()); | |
290 | } | |
291 | ||
292 | /** | |
293 | * Run the boolean hasChildren() method test. | |
eb1bab5b | 294 | */ |
2ba3d0a1 | 295 | @Test |
ea21cd65 | 296 | public void testHasChildren_1() { |
eb1bab5b BH |
297 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
298 | fixture.setToolTip(""); | |
299 | fixture.addChild(new TraceControlRoot()); | |
300 | ||
301 | boolean result = fixture.hasChildren(); | |
302 | ||
303 | assertTrue(result); | |
304 | } | |
305 | ||
306 | /** | |
307 | * Run the boolean hasChildren() method test. | |
eb1bab5b | 308 | */ |
2ba3d0a1 | 309 | @Test |
ea21cd65 | 310 | public void testHasChildren_2() { |
eb1bab5b BH |
311 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
312 | fixture.setToolTip(""); | |
313 | ||
314 | boolean result = fixture.hasChildren(); | |
315 | ||
316 | assertFalse(result); | |
317 | } | |
318 | ||
319 | /** | |
320 | * Run the void removeAllChildren() method test. | |
eb1bab5b | 321 | */ |
2ba3d0a1 | 322 | @Test |
ea21cd65 | 323 | public void testRemoveAllChildren_2() { |
eb1bab5b BH |
324 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
325 | fixture.setToolTip(""); | |
326 | ||
327 | fixture.addChild(new TraceControlRoot()); | |
328 | fixture.addChild(new TraceControlComponent("child")); | |
cfdb727a | 329 | |
eb1bab5b BH |
330 | fixture.removeAllChildren(); |
331 | assertFalse(fixture.hasChildren()); | |
332 | } | |
333 | ||
334 | /** | |
335 | * Run the void removeChild(ITraceControlComponent) method test. | |
eb1bab5b | 336 | */ |
2ba3d0a1 | 337 | @Test |
ea21cd65 | 338 | public void testRemoveChild_1() { |
eb1bab5b BH |
339 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
340 | fixture.setToolTip(""); | |
341 | TraceControlComponent child = new TraceControlComponent("child", fixture); | |
cfdb727a | 342 | |
eb1bab5b BH |
343 | fixture.addChild(child); |
344 | fixture.removeChild(child); | |
345 | assertFalse(fixture.hasChildren()); | |
346 | } | |
347 | ||
348 | /** | |
349 | * Run the void removeChild(ITraceControlComponent) method test. | |
eb1bab5b | 350 | */ |
2ba3d0a1 | 351 | @Test |
ea21cd65 | 352 | public void testRemoveChild_2() { |
eb1bab5b BH |
353 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
354 | fixture.setToolTip(""); | |
355 | fixture.addChild(new TraceControlRoot()); | |
356 | ITraceControlComponent component = null; | |
357 | ||
358 | fixture.removeChild(component); | |
359 | assertTrue(fixture.hasChildren()); | |
360 | } | |
361 | ||
362 | /** | |
363 | * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test. | |
eb1bab5b | 364 | */ |
2ba3d0a1 | 365 | @Test |
ea21cd65 | 366 | public void testRemoveComponentListener_1() { |
eb1bab5b BH |
367 | TraceControlComponent fixture = new TraceControlComponent("", (ITraceControlComponent) null); |
368 | fixture.setToolTip(""); | |
cfdb727a | 369 | |
eb1bab5b BH |
370 | ListenerValidator validator = new ListenerValidator(); |
371 | fixture.addComponentListener(validator); | |
372 | ||
373 | // Remove listener and check that validator is not called anymore | |
374 | validator.initialize(); | |
375 | fixture.removeComponentListener(validator); | |
376 | TraceControlRoot root = new TraceControlRoot(); | |
377 | fixture.addChild(root); | |
378 | assertFalse(validator.isAddedCalled()); | |
cfdb727a | 379 | |
eb1bab5b BH |
380 | fixture.removeChild(root); |
381 | assertFalse(validator.isRemovedCalled()); | |
382 | ||
4775bcbf | 383 | fixture.fireComponentChanged(fixture); |
eb1bab5b BH |
384 | assertFalse(validator.isChangedCalled()); |
385 | } | |
386 | ||
387 | /** | |
388 | * Run the void removeComponentListener(ITraceControlComponentChangedListener) method test. | |
eb1bab5b | 389 | */ |
2ba3d0a1 | 390 | @Test |
ea21cd65 | 391 | public void testRemoveComponentListener_2() { |
eb1bab5b BH |
392 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
393 | fixture.setToolTip(""); | |
394 | fixture.addChild(new TraceControlRoot()); | |
395 | ITraceControlComponentChangedListener listener = new ControlView(); | |
396 | ||
397 | fixture.removeComponentListener(listener); | |
398 | ||
399 | } | |
400 | ||
401 | /** | |
402 | * Run the void setChildren(List<ITraceControlComponent>)/ITraceControlComponent[] getChildren() method test. | |
eb1bab5b | 403 | */ |
2ba3d0a1 | 404 | @Test |
ea21cd65 | 405 | public void testGetAndSetChildren() { |
eb1bab5b BH |
406 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
407 | fixture.setToolTip(""); | |
e0838ca1 | 408 | List<ITraceControlComponent> children = new LinkedList<>(); |
eb1bab5b BH |
409 | children.add(new TraceControlComponent("child1")); |
410 | children.add(new TraceControlComponent("child2")); | |
411 | ||
412 | fixture.setChildren(children); | |
cfdb727a | 413 | |
eb1bab5b BH |
414 | ITraceControlComponent[] result = fixture.getChildren(); |
415 | assertEquals(2, result.length); | |
416 | assertEquals("child1", result[0].getName()); | |
417 | assertEquals("child2", result[1].getName()); | |
418 | } | |
419 | ||
420 | /** | |
421 | * Run the void String getName()/setName(String) method tests. | |
eb1bab5b | 422 | */ |
2ba3d0a1 | 423 | @Test |
ea21cd65 | 424 | public void testGetAndSetName() { |
eb1bab5b BH |
425 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
426 | fixture.setToolTip(""); | |
427 | fixture.addChild(new TraceControlRoot()); | |
428 | String name = "node"; | |
429 | ||
430 | fixture.setName(name); | |
431 | assertEquals(name,fixture.getName()); | |
432 | ||
433 | } | |
434 | ||
435 | /** | |
436 | * Run the void ITraceControlComponent getParent()/setParent(ITraceControlComponent) method tests. | |
eb1bab5b | 437 | */ |
2ba3d0a1 | 438 | @Test |
ea21cd65 | 439 | public void testGetAndSetParent() { |
eb1bab5b BH |
440 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
441 | fixture.setToolTip(""); | |
442 | fixture.addChild(new TraceControlRoot()); | |
443 | ITraceControlComponent parent = new TraceControlRoot(); | |
444 | parent.addChild(fixture); | |
445 | ||
446 | fixture.setParent(parent); | |
447 | ITraceControlComponent retrievedParent = fixture.getParent(); | |
448 | assertNotNull(retrievedParent); | |
449 | assertEquals(parent.getName(), retrievedParent.getName()); | |
450 | assertEquals(TraceControlRoot.TRACE_CONTROL_ROOT_NAME, retrievedParent.getName()); | |
451 | assertEquals(null, retrievedParent.getParent()); | |
452 | assertEquals(true, retrievedParent.hasChildren()); | |
453 | } | |
454 | ||
455 | /** | |
456 | * Run the void TargetNodeState getTargetNodeState()/etTargetNodeState(TargetNodeState) method tests. | |
eb1bab5b | 457 | */ |
2ba3d0a1 | 458 | @Test |
ea21cd65 | 459 | public void testGetAndSetTargetNodeState_1() { |
eb1bab5b BH |
460 | TraceControlComponent parent = new TraceControlComponent("parent") { |
461 | private TargetNodeState fState; | |
cfdb727a | 462 | |
eb1bab5b BH |
463 | @Override |
464 | public void setTargetNodeState(TargetNodeState state ) { | |
465 | fState = state; | |
466 | } | |
cfdb727a | 467 | |
eb1bab5b BH |
468 | @Override |
469 | public TargetNodeState getTargetNodeState() { | |
470 | return fState; | |
471 | } | |
472 | }; | |
cfdb727a | 473 | |
eb1bab5b BH |
474 | TraceControlComponent fixture = new TraceControlComponent("", parent); |
475 | parent.addChild(fixture); | |
cfdb727a | 476 | |
eb1bab5b BH |
477 | fixture.setToolTip(""); |
478 | TargetNodeState state = TargetNodeState.CONNECTED; | |
479 | ||
480 | fixture.setTargetNodeState(state); | |
481 | TargetNodeState result = fixture.getTargetNodeState(); | |
cfdb727a | 482 | |
eb1bab5b BH |
483 | assertNotNull(result); |
484 | assertEquals(state, result); | |
485 | // Check also parent | |
486 | assertEquals(state, fixture.getParent().getTargetNodeState()); | |
487 | assertEquals("CONNECTED", result.name()); | |
488 | assertEquals("CONNECTED", result.toString()); | |
489 | assertEquals(2, result.ordinal()); | |
490 | ||
491 | fixture.setTargetNodeState(TargetNodeState.DISCONNECTED); | |
492 | result = fixture.getTargetNodeState(); | |
493 | assertNotNull(result); | |
494 | assertEquals("DISCONNECTED", result.name()); | |
495 | assertEquals("DISCONNECTED", result.toString()); | |
496 | assertEquals(0, result.ordinal()); | |
cfdb727a | 497 | |
eb1bab5b BH |
498 | state = TargetNodeState.CONNECTING; |
499 | ||
500 | fixture.setTargetNodeState(state); | |
501 | result = fixture.getTargetNodeState(); | |
502 | assertNotNull(result); | |
503 | assertEquals("CONNECTING", result.name()); | |
504 | assertEquals("CONNECTING", result.toString()); | |
505 | assertEquals(3, result.ordinal()); | |
cfdb727a | 506 | |
eb1bab5b BH |
507 | fixture.setTargetNodeState(TargetNodeState.DISCONNECTING); |
508 | result = fixture.getTargetNodeState(); | |
509 | assertNotNull(result); | |
510 | assertEquals("DISCONNECTING", result.name()); | |
511 | assertEquals("DISCONNECTING", result.toString()); | |
512 | assertEquals(1, result.ordinal()); | |
513 | ||
514 | } | |
515 | ||
516 | /** | |
517 | * Run the void setToolTip(String) method test. | |
eb1bab5b | 518 | */ |
2ba3d0a1 | 519 | @Test |
ea21cd65 | 520 | public void testGetSndSetToolTip() { |
eb1bab5b BH |
521 | TraceControlComponent fixture = new TraceControlComponent("", new TraceControlRoot()); |
522 | fixture.setToolTip("This is a tooltip"); | |
523 | fixture.addChild(new TraceControlRoot()); | |
524 | ||
525 | String result = fixture.getToolTip(); | |
526 | ||
527 | assertEquals("This is a tooltip", result); | |
528 | } | |
529 | } |