tmf: Bug 460842: Introduce tmf remote plug-ins and feature
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / model / component / TraceControlTreeModelNoProvidersTest.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
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
11 * Alexandre Montplaisir - Port to JUnit4
12 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
13 **********************************************************************/
14
15 package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
16
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
23 import java.io.File;
24 import java.net.URL;
25
26 import org.eclipse.core.runtime.FileLocator;
27 import org.eclipse.core.runtime.Path;
28 import org.eclipse.remote.core.IRemoteConnection;
29 import org.eclipse.swt.graphics.Image;
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;
39 import org.eclipse.tracecompass.tmf.remote.core.proxy.RemoteSystemProxy;
40 import org.junit.After;
41 import org.junit.Before;
42 import org.junit.Test;
43 import org.osgi.framework.FrameworkUtil;
44
45 /**
46 * The class <code>TraceControlTreeModelNoProvidersTest</code> verifies that the
47 * Tracer Control can handle the case where no kernel provider and only UST
48 * provider are available.
49 */
50 public class TraceControlTreeModelNoProvidersTest {
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
67 // ------------------------------------------------------------------------
68 // Housekeeping
69 // ------------------------------------------------------------------------
70
71 /**
72 * Perform pre-test initialization.
73 *
74 * @throws Exception
75 * if the initialization fails for some reason
76 */
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.
87 */
88 @After
89 public void tearDown() {
90 TraceControlTestFacility.getInstance().waitForJobs();
91 }
92
93 /**
94 * Run the TraceControlComponent.
95 */
96 @Test
97 public void testTraceControlComponents() {
98
99 fProxy.setTestFile(fTestFile);
100 fProxy.setScenario(SCEN_LIST_INFO_TEST);
101
102 ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
103
104 IRemoteConnection host = RemoteSystemProxy.getLocalConnection();
105
106 TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, host, fProxy);
107
108 root.addChild(node);
109 node.connect();
110
111 TraceControlTestFacility.getInstance().waitForConnect(node);
112 TraceControlTestFacility.getInstance().waitForJobs();
113
114 // ------------------------------------------------------------------------
115 // Verify Parameters of TargetNodeComponent
116 // ------------------------------------------------------------------------
117 assertEquals("Local", node.getToolTip()); // assigned in createLocalHost() above
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
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 }
This page took 0.04084 seconds and 5 git commands to generate.