lttng: Fix ControlViewTest
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / tests / model / component / TraceControlTreeModelNoProvidersTest.java
CommitLineData
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 15package org.eclipse.tracecompass.lttng2.control.ui.tests.model.component;
a07c7629 16
2ba3d0a1
AM
17import static org.junit.Assert.assertEquals;
18import static org.junit.Assert.assertFalse;
19import static org.junit.Assert.assertNotNull;
20import static org.junit.Assert.assertNotSame;
21import static org.junit.Assert.assertTrue;
22
a07c7629
BH
23import java.io.File;
24import java.net.URL;
25
a07c7629
BH
26import org.eclipse.core.runtime.FileLocator;
27import org.eclipse.core.runtime.Path;
d8a4fd60 28import org.eclipse.jdt.annotation.NonNull;
b732adaa 29import org.eclipse.remote.core.IRemoteConnection;
a07c7629 30import org.eclipse.swt.graphics.Image;
9bc60be7
AM
31import org.eclipse.tracecompass.internal.lttng2.control.core.model.TargetNodeState;
32import org.eclipse.tracecompass.internal.lttng2.control.stubs.service.TestRemoteSystemProxy;
33import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
34import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent;
35import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
36import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup;
37import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.UstProviderComponent;
38import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.ILttngControlService;
39import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlService;
b6b4e8b4 40import org.eclipse.tracecompass.tmf.remote.core.proxy.TmfRemoteConnectionFactory;
a07c7629
BH
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 // ------------------------------------------------------------------------
13f36900 64 private TraceControlTestFacility fFacility;
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 {
13f36900
BH
81 fFacility = TraceControlTestFacility.getInstance();
82 fFacility.init();
a07c7629
BH
83 URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path(TraceControlTestFacility.DIRECTORY + File.separator + TEST_STREAM), null);
84 File testfile = new File(FileLocator.toFileURL(location).toURI());
85 fTestFile = testfile.getAbsolutePath();
86 }
87
88 /**
89 * Perform post-test clean-up.
a07c7629 90 */
a07c7629 91 @After
2ba3d0a1 92 public void tearDown() {
13f36900 93 fFacility.dispose();
a07c7629
BH
94 }
95
96 /**
97 * Run the TraceControlComponent.
a07c7629 98 */
2ba3d0a1 99 @Test
b732adaa 100 public void testTraceControlComponents() {
a07c7629
BH
101
102 fProxy.setTestFile(fTestFile);
103 fProxy.setScenario(SCEN_LIST_INFO_TEST);
104
13f36900 105 ITraceControlComponent root = fFacility.getControlView().getTraceControlRoot();
a07c7629 106
d8a4fd60 107 TargetNodeComponent node = new TargetNodeComponent(TARGET_NODE_NAME, root, fProxy);
a07c7629
BH
108
109 root.addChild(node);
110 node.connect();
111
13f36900
BH
112 fFacility.waitForConnect(node);
113 fFacility.waitForJobs();
a07c7629
BH
114
115 // ------------------------------------------------------------------------
116 // Verify Parameters of TargetNodeComponent
117 // ------------------------------------------------------------------------
b732adaa 118 assertEquals("Local", node.getToolTip()); // assigned in createLocalHost() above
a07c7629
BH
119 Image connectedImage = node.getImage();
120 assertNotNull(connectedImage);
121 assertEquals(TargetNodeState.CONNECTED, node.getTargetNodeState());
122 assertNotNull(node.getControlService());
123 ILttngControlService service = node.getControlService();
124 assertTrue(service instanceof LTTngControlService);
125 node.setControlService(service);
126 assertTrue(node.getControlService() instanceof LTTngControlService);
127
a07c7629
BH
128 // ------------------------------------------------------------------------
129 // Verify Children of TargetNodeComponent
130 // ------------------------------------------------------------------------
131 ITraceControlComponent[] groups = node.getChildren();
132 assertNotNull(groups);
133 assertEquals(2, groups.length);
134
135 assertTrue(groups[0] instanceof TraceProviderGroup);
136 assertTrue(groups[1] instanceof TraceSessionGroup);
137
138 // Check for kernel provider
139 TraceProviderGroup providerGroup = (TraceProviderGroup) groups[0];
140 assertFalse(providerGroup.hasKernelProvider());
141
142 assertEquals("Provider", providerGroup.getName());
143 assertEquals("Sessions", groups[1].getName());
144
145 // ------------------------------------------------------------------------
146 // Verify TraceProviderGroup
147 // ------------------------------------------------------------------------
148 ITraceControlComponent[] providers = groups[0].getChildren();
149
150 assertNotNull(providers);
151 assertEquals(1, providers.length);
152 assertTrue(providers[0] instanceof UstProviderComponent);
153
154 // disconnect
155 node.disconnect();
156 assertEquals(TargetNodeState.DISCONNECTED, node.getTargetNodeState());
157 assertNotNull(node.getImage());
158 assertNotSame(connectedImage, node.getImage());
159
160 node.getParent().removeChild(node);
161 }
162}
This page took 0.082806 seconds and 5 git commands to generate.