Added properties implementation
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui.tests / src / org / eclipse / linuxtools / lttng / ui / tests / control / model / component / TraceControlPropertiesTest.java
CommitLineData
06b9339e
BH
1/**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.tests.control.model.component;
13
14import junit.framework.Test;
15import junit.framework.TestCase;
16import junit.framework.TestSuite;
17
18import org.eclipse.linuxtools.lttng.stubs.service.TestRemoteSystemProxy;
19import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
20import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
21import org.eclipse.linuxtools.lttng.ui.views.control.model.TargetNodeState;
22import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
23import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEventType;
24import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
25import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
26import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.BaseEventComponent;
27import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.KernelProviderComponent;
28import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TargetNodeComponent;
29import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceChannelComponent;
30import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
31import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceEventComponent;
32import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
33import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.UstProviderComponent;
34import org.eclipse.linuxtools.lttng.ui.views.control.property.BaseEventPropertySource;
35import org.eclipse.linuxtools.lttng.ui.views.control.property.KernelProviderPropertySource;
36import org.eclipse.linuxtools.lttng.ui.views.control.property.TargetNodePropertySource;
37import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceChannelPropertySource;
38import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceDomainPropertySource;
39import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceEventPropertySource;
40import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceSessionPropertySource;
41import org.eclipse.linuxtools.lttng.ui.views.control.property.UstProviderPropertySource;
42import org.eclipse.rse.core.model.Host;
43import org.eclipse.rse.core.model.IHost;
44import org.eclipse.rse.internal.core.model.SystemProfile;
45import org.eclipse.ui.views.properties.IPropertySource;
46import org.junit.After;
47import org.junit.Before;
48
49/**
50 * The class <code>TraceControlPropertiesTest</code> contains tests for the all property class</code>.
51 *
52 */
53@SuppressWarnings("nls")
54public class TraceControlPropertiesTest extends TestCase {
55
56 // ------------------------------------------------------------------------
57 // Test data
58 // ------------------------------------------------------------------------
59
60 // ------------------------------------------------------------------------
61 // Static methods
62 // ------------------------------------------------------------------------
63
64 /**
65 * Returns test setup used when executing test case stand-alone.
66 * @return Test setup class
67 */
68 public static Test suite() {
69 return new ModelImplTestSetup(new TestSuite(TraceControlPropertiesTest.class));
70 }
71
72 // ------------------------------------------------------------------------
73 // Housekeeping
74 // ------------------------------------------------------------------------
75
76 /**
77 * Perform pre-test initialization.
78 *
79 * @throws Exception
80 * if the initialization fails for some reason
81 *
82 */
83 @Override
84 @Before
85 public void setUp() throws Exception {
86 }
87
88 /**
89 * Perform post-test clean-up.
90 *
91 * @throws Exception
92 * if the clean-up fails for some reason
93 *
94 */
95 @Override
96 @After
97 public void tearDown() throws Exception {
98 }
99
100 /**
101 * Run the TraceControlComponent.
102 */
103 public void testTraceControlComponents()
104 throws Exception {
105
106 TestRemoteSystemProxy proxy = new TestRemoteSystemProxy();
107
108 ITraceControlComponent root = TraceControlTestFacility.getInstance().getControlView().getTraceControlRoot();
109
110 @SuppressWarnings("restriction")
111 IHost host = new Host(new SystemProfile("myProfile", true));
112 host.setHostName("127.0.0.1");
113
114 TargetNodeComponent node = new TargetNodeComponent("myNode", root, host, proxy);
115
116 root.addChild(node);
117 node.connect();
118
119 TraceControlTestFacility.getInstance().waitForJobs();
120
121 // ------------------------------------------------------------------------
122 // Verify Node Properties (adapter)
123 // ------------------------------------------------------------------------
124 Object adapter = node.getAdapter(IPropertySource.class);
125 assertNotNull(adapter);
126 assertTrue(adapter instanceof TargetNodePropertySource);
127
128 TargetNodePropertySource source = (TargetNodePropertySource)adapter;
129
130 assertNull(source.getEditableValue());
131 assertFalse(source.isPropertySet(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
132 assertNotNull(source.getPropertyDescriptors());
133
134 assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
135 assertEquals("127.0.0.1", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID));
136 assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID));
137 assertNull(source.getPropertyValue("test"));
138
139 adapter = node.getAdapter(IChannelInfo.class);
140 assertNull(adapter);
141
142 ITraceControlComponent[] groups = node.getChildren();
143 assertNotNull(groups);
144 assertEquals(2, groups.length);
145
146 ITraceControlComponent[] providers = groups[0].getChildren();
147
148 assertNotNull(providers);
149 assertEquals(3, providers.length);
150
151 // ------------------------------------------------------------------------
152 // Verify Kernel Provider Properties (adapter)
153 // ------------------------------------------------------------------------
154 KernelProviderComponent kernelProvider = (KernelProviderComponent) providers[0];
155
156 adapter = kernelProvider.getAdapter(IPropertySource.class);
157 assertNotNull(adapter);
158 assertTrue(adapter instanceof KernelProviderPropertySource);
159
160 KernelProviderPropertySource kernelSource = (KernelProviderPropertySource)adapter;
161 assertNotNull(kernelSource.getPropertyDescriptors());
162
163 assertEquals("Kernel", kernelSource.getPropertyValue(KernelProviderPropertySource.KERNEL_PROVIDER_NAME_PROPERTY_ID));
164
165 // ------------------------------------------------------------------------
166 // Verify UST Provider Properties (adapter)
167 // ------------------------------------------------------------------------
168 UstProviderComponent ustProvider = (UstProviderComponent) providers[1];
169
170 adapter = ustProvider.getAdapter(IPropertySource.class);
171 assertNotNull(adapter);
172 assertTrue(adapter instanceof UstProviderPropertySource);
173
174 UstProviderPropertySource ustSource = (UstProviderPropertySource)adapter;
175 assertNotNull(ustSource.getPropertyDescriptors());
176
177 assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_NAME_PROPERTY_ID));
178 assertEquals(String.valueOf(9379), ustSource.getPropertyValue(UstProviderPropertySource.UST_PROVIDER_PID_PROPERTY_ID));
179
180 // ------------------------------------------------------------------------
181 // Verify Base Event Properties (adapter)
182 // ------------------------------------------------------------------------
183 ITraceControlComponent[] events = ustProvider.getChildren();
184 assertNotNull(events);
185 assertEquals(2, events.length);
186
187 BaseEventComponent baseEventInfo = (BaseEventComponent) events[0];
188 assertNotNull(baseEventInfo);
189
190 adapter = baseEventInfo.getAdapter(IPropertySource.class);
191 assertNotNull(adapter);
192 assertTrue(adapter instanceof BaseEventPropertySource);
193
194 BaseEventPropertySource baseSource = (BaseEventPropertySource)adapter;
195 assertNotNull(baseSource.getPropertyDescriptors());
196
197 assertEquals("ust_tests_hello:tptest_sighandler", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_NAME_PROPERTY_ID));
198 assertEquals(TraceEventType.TRACEPOINT.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_TYPE_PROPERTY_ID));
199 assertEquals(TraceLogLevel.TRACE_MODULE.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_LOGLEVEL_PROPERTY_ID));
200
201 // ------------------------------------------------------------------------
202 // Verify Session Properties (adapter)
203 // ------------------------------------------------------------------------
204 ITraceControlComponent[] sessions = groups[1].getChildren();
205 assertNotNull(sessions);
206 assertEquals(2, sessions.length);
207
208 TraceSessionComponent session = (TraceSessionComponent)sessions[1];
209
210 adapter = session.getAdapter(IPropertySource.class);
211 assertNotNull(adapter);
212 assertTrue(adapter instanceof TraceSessionPropertySource);
213
214 TraceSessionPropertySource sessionSource = (TraceSessionPropertySource)adapter;
215 assertNotNull(sessionSource.getPropertyDescriptors());
216
217 assertEquals("mysession", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_NAME_PROPERTY_ID));
218 assertEquals("/home/user/lttng-traces/mysession-20120129-084256", sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_PATH_PROPERTY_ID));
219 assertEquals(TraceSessionState.ACTIVE.name(), sessionSource.getPropertyValue(TraceSessionPropertySource.TRACE_SESSION_STATE_PROPERTY_ID));
220
221 // ------------------------------------------------------------------------
222 // Verify Domain Provider Properties (adapter)
223 // ------------------------------------------------------------------------
224 ITraceControlComponent[] domains = session.getChildren();
225 assertNotNull(domains);
226 assertEquals(2, domains.length);
227
228 TraceDomainComponent domain = (TraceDomainComponent) domains[0];
229 adapter = domain.getAdapter(IPropertySource.class);
230 assertNotNull(adapter);
231 assertTrue(adapter instanceof TraceDomainPropertySource);
232
233 TraceDomainPropertySource domainSource = (TraceDomainPropertySource)adapter;
234 assertNotNull(domainSource.getPropertyDescriptors());
235
236 assertEquals("Kernel", domainSource.getPropertyValue(TraceDomainPropertySource.TRACE_DOMAIN_NAME_PROPERTY_ID));
237
238 ITraceControlComponent[] channels = domains[0].getChildren();
239 assertNotNull(channels);
240 assertEquals(2, channels.length);
241
242 // ------------------------------------------------------------------------
243 // Verify Channel Properties (adapter)
244 // ------------------------------------------------------------------------
245 assertTrue(channels[0] instanceof TraceChannelComponent);
246 TraceChannelComponent channel = (TraceChannelComponent) channels[0];
247
248 adapter = channel.getAdapter(IPropertySource.class);
249 assertNotNull(adapter);
250 assertTrue(adapter instanceof TraceChannelPropertySource);
251
252 TraceChannelPropertySource channelSource = (TraceChannelPropertySource)adapter;
253 assertNotNull(channelSource.getPropertyDescriptors());
254
255 assertEquals("channel0", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NAME_PROPERTY_ID));
256 assertEquals(String.valueOf(4), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_NO_SUBBUFFERS_PROPERTY_ID));
257 assertEquals(TraceEnablement.ENABLED.name(), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_STATE_PROPERTY_ID));
258 assertEquals(String.valueOf(false), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OVERWRITE_MODE_PROPERTY_ID));
259 assertEquals("splice()", channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_OUTPUT_TYPE_PROPERTY_ID));
260 assertEquals(String.valueOf(200), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_READ_TIMER_PROPERTY_ID));
261 assertEquals(String.valueOf(262144), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SUBBUFFER_SIZE_PROPERTY_ID));
262 assertEquals(String.valueOf(0), channelSource.getPropertyValue(TraceChannelPropertySource.TRACE_CHANNEL_SWITCH_TIMER_PROPERTY_ID));
263
264 // ------------------------------------------------------------------------
265 // Verify Event Properties (adapter)
266 // ------------------------------------------------------------------------
267 ITraceControlComponent[] channel0Events = channel.getChildren();
268 assertNotNull(channel0Events);
269 assertEquals(2, channel0Events.length);
270 assertTrue(channel0Events[0] instanceof TraceEventComponent);
271
272 TraceEventComponent event = (TraceEventComponent) channel0Events[0];
273
274 adapter = event.getAdapter(IPropertySource.class);
275 assertNotNull(adapter);
276 assertTrue(adapter instanceof TraceEventPropertySource);
277
278 TraceEventPropertySource eventSource = (TraceEventPropertySource)adapter;
279 assertNotNull(eventSource.getPropertyDescriptors());
280
281 assertEquals("block_rq_remap", eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_NAME_PROPERTY_ID));
282 assertEquals(TraceLogLevel.TRACE_EMERG.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_LOGLEVEL_PROPERTY_ID));
283 assertEquals(TraceEventType.TRACEPOINT.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_TYPE_PROPERTY_ID));
284 assertEquals(TraceEnablement.ENABLED.name(), eventSource.getPropertyValue(TraceEventPropertySource.TRACE_EVENT_STATE_PROPERTY_ID));
285 }
286}
This page took 0.034248 seconds and 5 git commands to generate.