Commit | Line | Data |
---|---|---|
a07c7629 | 1 | /********************************************************************** |
533d0bc3 | 2 | * Copyright (c) 2012, 2015 Ericsson |
a07c7629 BH |
3 | * |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
2ba3d0a1 | 11 | * Alexandre Montplaisir - Port to JUnit4 |
b732adaa | 12 | * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE |
a07c7629 | 13 | **********************************************************************/ |
2ba3d0a1 | 14 | |
9bc60be7 | 15 | package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component; |
a07c7629 | 16 | |
2ba3d0a1 AM |
17 | import static org.junit.Assert.assertEquals; |
18 | import static org.junit.Assert.assertFalse; | |
19 | import static org.junit.Assert.assertNotNull; | |
20 | import static org.junit.Assert.assertNotSame; | |
21 | import static org.junit.Assert.assertTrue; | |
22 | ||
a07c7629 BH |
23 | import java.io.File; |
24 | import java.net.URL; | |
25 | ||
a07c7629 BH |
26 | import org.eclipse.core.runtime.FileLocator; |
27 | import org.eclipse.core.runtime.Path; | |
b732adaa | 28 | import org.eclipse.remote.core.IRemoteConnection; |
a07c7629 | 29 | import org.eclipse.swt.graphics.Image; |
9bc60be7 AM |
30 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState; |
31 | import org.eclipse.tracecompass.internal.lttng2.control.stubs.service.TestRemoteSystemProxy; | |
32 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
33 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; | |
34 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup; | |
35 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup; | |
36 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.UstProviderComponent; | |
37 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService; | |
38 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService; | |
ec619615 | 39 | import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy; |
a07c7629 BH |
40 | import org.junit.After; |
41 | import org.junit.Before; | |
2ba3d0a1 | 42 | import org.junit.Test; |
a07c7629 BH |
43 | import org.osgi.framework.FrameworkUtil; |
44 | ||
45 | /** | |
46 | * The class <code>TraceControlTreeModelNoProvidersTest</code> verifies that the | |
2ba3d0a1 AM |
47 | * Tracer Control can handle the case where no kernel provider and only UST |
48 | * provider are available. | |
a07c7629 | 49 | */ |
2ba3d0a1 | 50 | public class TraceControlTreeModelNoProvidersTest { |
a07c7629 BH |
51 | |
52 | // ------------------------------------------------------------------------ | |
53 | // Constants | |
54 | // ------------------------------------------------------------------------ | |
55 | ||
56 | private static final String TEST_STREAM = "ListInfoTest.cfg"; | |
57 | private static final String SCEN_LIST_INFO_TEST = "ListInfoTestNoKernel"; | |
58 | private static final String TARGET_NODE_NAME = "myNode"; | |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Test data | |
62 | // ------------------------------------------------------------------------ | |
63 | ||
64 | private TestRemoteSystemProxy fProxy; | |
65 | private String fTestFile; | |
66 | ||
a07c7629 BH |
67 | // ------------------------------------------------------------------------ |
68 | // Housekeeping | |
69 | // ------------------------------------------------------------------------ | |
70 | ||
71 | /** | |
72 | * Perform pre-test initialization. | |
73 | * | |
74 | * @throws Exception | |
75 | * if the initialization fails for some reason | |
a07c7629 | 76 | */ |
a07c7629 BH |
77 | @Before |
78 | public void setUp() throws Exception { | |
79 | fProxy = new TestRemoteSystemProxy(); | |
80 | URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null); | |
81 | File testfile = new File(FileLocator.toFileURL(location).toURI()); | |
82 | fTestFile = testfile.getAbsolutePath(); | |
83 | } | |
84 | ||
85 | /** | |
86 | * Perform post-test clean-up. | |
a07c7629 | 87 | */ |
a07c7629 | 88 | @After |
2ba3d0a1 | 89 | public void tearDown() { |
a07c7629 BH |
90 | TraceControlTestFacility.getInstance().waitForJobs(); |
91 | } | |
92 | ||
93 | /** | |
94 | * Run the TraceControlComponent. | |
a07c7629 | 95 | */ |
2ba3d0a1 | 96 | @Test |
b732adaa | 97 | public void testTraceControlComponents() { |
a07c7629 BH |
98 | |
99 | fProxy.setTestFile(fTestFile); | |
100 | fProxy.setScenario(SCEN_LIST_INFO_TEST); | |
101 | ||
102 | ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot(); | |
103 | ||
533d0bc3 | 104 | IRemoteConnection host = RemoteSystemProxy.getLocalConnection(); |
a07c7629 BH |
105 | |
106 | TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, host, fProxy); | |
107 | ||
108 | root.addChild(node); | |
109 | node.connect(); | |
110 | ||
b732adaa | 111 | TraceControlTestFacility.getInstance().waitForConnect(node); |
a07c7629 BH |
112 | TraceControlTestFacility.getInstance().waitForJobs(); |
113 | ||
114 | // ------------------------------------------------------------------------ | |
115 | // Verify Parameters of TargetNodeComponent | |
116 | // ------------------------------------------------------------------------ | |
b732adaa | 117 | assertEquals("Local", node.getToolTip()); // assigned in createLocalHost() above |
a07c7629 BH |
118 | Image connectedImage = node.getImage(); |
119 | assertNotNull(connectedImage); | |
120 | assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState()); | |
121 | assertNotNull(node.getControlService()); | |
122 | ILttngControlService service = node.getControlService(); | |
123 | assertTrue(service instanceof LTTngControlService); | |
124 | node.setControlService(service); | |
125 | assertTrue(node.getControlService() instanceof LTTngControlService); | |
126 | ||
a07c7629 BH |
127 | // ------------------------------------------------------------------------ |
128 | // Verify Children of TargetNodeComponent | |
129 | // ------------------------------------------------------------------------ | |
130 | ITraceControlComponent[] groups = node.getChildren(); | |
131 | assertNotNull(groups); | |
132 | assertEquals(2, groups.length); | |
133 | ||
134 | assertTrue(groups[0] instanceof TraceProviderGroup); | |
135 | assertTrue(groups[1] instanceof TraceSessionGroup); | |
136 | ||
137 | // Check for kernel provider | |
138 | TraceProviderGroup providerGroup = (TraceProviderGroup) groups[0]; | |
139 | assertFalse(providerGroup.hasKernelProvider()); | |
140 | ||
141 | assertEquals("Provider", providerGroup.getName()); | |
142 | assertEquals("Sessions", groups[1].getName()); | |
143 | ||
144 | // ------------------------------------------------------------------------ | |
145 | // Verify TraceProviderGroup | |
146 | // ------------------------------------------------------------------------ | |
147 | ITraceControlComponent[] providers = groups[0].getChildren(); | |
148 | ||
149 | assertNotNull(providers); | |
150 | assertEquals(1, providers.length); | |
151 | assertTrue(providers[0] instanceof UstProviderComponent); | |
152 | ||
153 | // disconnect | |
154 | node.disconnect(); | |
155 | assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState()); | |
156 | assertNotNull(node.getImage()); | |
157 | assertNotSame(connectedImage, node.getImage()); | |
158 | ||
159 | node.getParent().removeChild(node); | |
160 | } | |
161 | } |