1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
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 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.lttng2
.control
.ui
.swtbot
.tests
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertTrue
;
16 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
17 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotCCombo
;
18 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotMenu
;
19 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotShell
;
20 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotText
;
21 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTree
;
22 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotTreeItem
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceEventComponent
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.ConditionHelpers
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
28 import org
.eclipse
.tracecompass
.tmf
.ui
.tests
.shared
.WaitUtils
;
29 import org
.junit
.Test
;
30 import org
.junit
.runner
.RunWith
;
33 * Test for the Control view in Trace Compass. This will test the save and load feature.
35 * @author Bernd Hufmann
37 @RunWith(SWTBotJunit4ClassRunner
.class)
38 public class ControlViewKernelFilterTest
extends ControlViewTest
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
43 private static final String TEST_STREAM
= "CreateSessionTestLTTng2_8.cfg";
44 private static final String CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME
= "KernelFilter";
45 private static final String CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME
= "KernelFilterProvider";
47 private static final String SESSION_NAME
= "mysession";
48 private static final String FILTER_EXPRESSION
= "next_tid==1234";
49 private static final String FILTER_EXPRESSION_DISPLAY
= "foo > 10";
52 protected String
getTestStream() {
57 protected String
getSessionName() {
63 public void testTraceSessionTree() {
65 fProxy
.setTestFile(fTestFile
);
66 fProxy
.setScenario(INIT_SCENARIO_NAME
);
69 // Prepare for saving of profile
70 fProxy
.setScenario(CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME
);
72 testEnableKernelEvent();
73 testStartStopTracing(TraceSessionState
.ACTIVE
);
74 testStartStopTracing(TraceSessionState
.INACTIVE
);
76 testDisconnectFromNode();
80 * Test enable events from Kernel provider
83 public void testTraceSessionTreeKernelProvider() {
85 fProxy
.setTestFile(fTestFile
);
86 fProxy
.setScenario(INIT_SCENARIO_NAME
);
89 // Prepare for saving of profile
90 fProxy
.setScenario(CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME
);
92 testEnableKernelFromProviderEvent();
93 testStartStopTracing(TraceSessionState
.ACTIVE
);
94 testStartStopTracing(TraceSessionState
.INACTIVE
);
96 testDisconnectFromNode();
100 protected void testEnableKernelEvent() {
101 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
103 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
106 sessionItem
.select();
107 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM
);
110 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
112 shell
.bot().radioInGroup(ControlViewSwtBotUtil
.GROUP_SELECT_NAME
, ControlViewSwtBotUtil
.TRACEPOINTS_GROUP_NAME
).click();
114 SWTBotTree tracepointsTree
= shell
.bot().tree();
115 SWTBotTreeItem allItem
= SWTBotUtils
.getTreeItem(fBot
, tracepointsTree
, ControlViewSwtBotUtil
.ALL_TREE_NODE
);
118 SWTBotText filterText
= shell
.bot().textInGroup(ControlViewSwtBotUtil
.FILTER_EXPRESSION_LABEL
);
119 filterText
.setText(FILTER_EXPRESSION
);
120 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
121 WaitUtils
.waitForJobs();
123 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, sessionItem
));
125 SWTBotTreeItem kernelDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
127 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
129 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
);
130 assertEquals(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, kernelDomainItem
.getText());
132 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
134 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
136 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
137 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
138 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
140 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
142 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
144 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
145 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
146 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
147 assertEquals(ControlViewSwtBotUtil
.ALL_EVENTS_NAME
, eventItem
.getText());
149 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
150 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
152 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
153 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
154 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
156 assertTrue(comp
instanceof TraceEventComponent
);
157 TraceEventComponent event
= (TraceEventComponent
) comp
;
158 assertEquals(FILTER_EXPRESSION_DISPLAY
, event
.getFilterExpression());
161 private void testEnableKernelFromProviderEvent() {
162 SWTBotTreeItem kernelProviderEventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
164 ControlViewSwtBotUtil
.PROVIDER_GROUP_NAME
,
165 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
166 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
168 kernelProviderEventItem
.select();
169 SWTBotMenu menuBot
= kernelProviderEventItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_MENU_ITEM
);
172 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
173 SWTBotCCombo sessionCombo
= shell
.bot().ccomboBoxInGroup(ControlViewSwtBotUtil
.SESSION_LIST_GROUP_NAME
);
174 sessionCombo
.setSelection(getSessionName());
175 SWTBotText filterText
= shell
.bot().textInGroup(ControlViewSwtBotUtil
.FILTER_EXPRESSION_LABEL
);
176 filterText
.setText(FILTER_EXPRESSION
);
177 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
178 WaitUtils
.waitForJobs();
180 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
182 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
185 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, sessionItem
));
187 SWTBotTreeItem kernelDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
189 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
191 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
);
192 assertEquals(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, kernelDomainItem
.getText());
194 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
196 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
198 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
199 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
200 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
202 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
204 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
206 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
207 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
208 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
209 assertEquals(ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
, eventItem
.getText());
211 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
212 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
214 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
215 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
216 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
218 assertTrue(comp
instanceof TraceEventComponent
);
219 TraceEventComponent event
= (TraceEventComponent
) comp
;
220 assertEquals(FILTER_EXPRESSION_DISPLAY
, event
.getFilterExpression());