lttng: Add a diagram showing the dependencies between plugins
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui.tests / src / org / eclipse / linuxtools / lttng2 / ui / tests / control / model / component / TraceControlTreeModelNoProvidersTest.java
CommitLineData
a07c7629 1/**********************************************************************
2ba3d0a1 2 * Copyright (c) 2012, 2013 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
a07c7629 12 **********************************************************************/
2ba3d0a1 13
a07c7629
BH
14package org.eclipse.linuxtools.lttng2.ui.tests.control.model.component;
15
2ba3d0a1
AM
16import static org.junit.Assert.assertEquals;
17import static org.junit.Assert.assertFalse;
18import static org.junit.Assert.assertNotNull;
19import static org.junit.Assert.assertNotSame;
20import static org.junit.Assert.assertTrue;
21
a07c7629
BH
22import java.io.File;
23import java.net.URL;
24
a07c7629
BH
25import org.eclipse.core.runtime.FileLocator;
26import org.eclipse.core.runtime.Path;
27import org.eclipse.linuxtools.internal.lttng2.core.control.model.TargetNodeState;
28import org.eclipse.linuxtools.internal.lttng2.stubs.service.TestRemoteSystemProxy;
29import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
30import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent;
31import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup;
32import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup;
33import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.UstProviderComponent;
34import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService;
35import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlService;
36import org.eclipse.rse.core.RSECorePlugin;
37import org.eclipse.rse.core.model.IHost;
38import org.eclipse.rse.core.model.ISystemProfile;
39import org.eclipse.rse.core.model.ISystemRegistry;
40import org.eclipse.swt.graphics.Image;
41import org.junit.After;
42import org.junit.Before;
2ba3d0a1 43import org.junit.Test;
a07c7629
BH
44import 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 51public 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
65 private TestRemoteSystemProxy fProxy;
66 private String fTestFile;
67
a07c7629
BH
68 // ------------------------------------------------------------------------
69 // Housekeeping
70 // ------------------------------------------------------------------------
71
72 /**
73 * Perform pre-test initialization.
74 *
75 * @throws Exception
76 * if the initialization fails for some reason
a07c7629 77 */
a07c7629
BH
78 @Before
79 public void setUp() throws Exception {
80 fProxy = new TestRemoteSystemProxy();
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.
96 *
97 * @throws Exception
98 * This will fail the test
99 */
2ba3d0a1 100 @Test
a07c7629
BH
101 public void testTraceControlComponents() throws Exception {
102
103 fProxy.setTestFile(fTestFile);
104 fProxy.setScenario(SCEN_LIST_INFO_TEST);
105
106 ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
107
108 ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
109 ISystemProfile profile = registry.createSystemProfile("myProfile", true);
110 IHost host = registry.createLocalHost(profile, "myProfile", "user");
111
112 TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, host, fProxy);
113
114 root.addChild(node);
115 node.connect();
116
117 TraceControlTestFacility.getInstance().waitForJobs();
118
119 // ------------------------------------------------------------------------
120 // Verify Parameters of TargetNodeComponent
121 // ------------------------------------------------------------------------
122 assertEquals("LOCALHOST", node.getHostName()); // assigned in createLocalHost() above
123 assertEquals("LOCALHOST", node.getToolTip()); // assigned in createLocalHost() above
124 Image connectedImage = node.getImage();
125 assertNotNull(connectedImage);
126 assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
127 assertNotNull(node.getControlService());
128 ILttngControlService service = node.getControlService();
129 assertTrue(service instanceof LTTngControlService);
130 node.setControlService(service);
131 assertTrue(node.getControlService() instanceof LTTngControlService);
132
133 assertTrue(node.isPassiveCommunicationsListener());
134
135 // ------------------------------------------------------------------------
136 // Verify Children of TargetNodeComponent
137 // ------------------------------------------------------------------------
138 ITraceControlComponent[] groups = node.getChildren();
139 assertNotNull(groups);
140 assertEquals(2, groups.length);
141
142 assertTrue(groups[0] instanceof TraceProviderGroup);
143 assertTrue(groups[1] instanceof TraceSessionGroup);
144
145 // Check for kernel provider
146 TraceProviderGroup providerGroup = (TraceProviderGroup) groups[0];
147 assertFalse(providerGroup.hasKernelProvider());
148
149 assertEquals("Provider", providerGroup.getName());
150 assertEquals("Sessions", groups[1].getName());
151
152 // ------------------------------------------------------------------------
153 // Verify TraceProviderGroup
154 // ------------------------------------------------------------------------
155 ITraceControlComponent[] providers = groups[0].getChildren();
156
157 assertNotNull(providers);
158 assertEquals(1, providers.length);
159 assertTrue(providers[0] instanceof UstProviderComponent);
160
161 // disconnect
162 node.disconnect();
163 assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
164 assertNotNull(node.getImage());
165 assertNotSame(connectedImage, node.getImage());
166
167 node.getParent().removeChild(node);
168 }
169}
This page took 0.040016 seconds and 5 git commands to generate.