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