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
.junit
.Test
;
29 import org
.junit
.runner
.RunWith
;
32 * Test for the Control view in Trace Compass. This will test the save and load feature.
34 * @author Bernd Hufmann
36 @RunWith(SWTBotJunit4ClassRunner
.class)
37 public class ControlViewKernelFilterTest
extends ControlViewTest
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
42 private static final String TEST_STREAM
= "CreateSessionTestLTTng2_8.cfg";
43 private static final String CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME
= "KernelFilter";
44 private static final String CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME
= "KernelFilterProvider";
46 private static final String SESSION_NAME
= "mysession";
47 private static final String FILTER_EXPRESSION
= "next_tid==1234";
48 private static final String FILTER_EXPRESSION_DISPLAY
= "foo > 10";
51 protected String
getTestStream() {
56 protected String
getSessionName() {
62 public void testTraceSessionTree() {
64 fProxy
.setTestFile(fTestFile
);
65 fProxy
.setScenario(INIT_SCENARIO_NAME
);
68 // Prepare for saving of profile
69 fProxy
.setScenario(CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME
);
71 testEnableKernelEvent();
72 testStartStopTracing(TraceSessionState
.ACTIVE
);
73 testStartStopTracing(TraceSessionState
.INACTIVE
);
75 testDisconnectFromNode();
79 * Test enable events from Kernel provider
82 public void testTraceSessionTreeKernelProvider() {
84 fProxy
.setTestFile(fTestFile
);
85 fProxy
.setScenario(INIT_SCENARIO_NAME
);
88 // Prepare for saving of profile
89 fProxy
.setScenario(CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME
);
91 testEnableKernelFromProviderEvent();
92 testStartStopTracing(TraceSessionState
.ACTIVE
);
93 testStartStopTracing(TraceSessionState
.INACTIVE
);
95 testDisconnectFromNode();
99 protected void testEnableKernelEvent() {
100 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
102 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
105 sessionItem
.select();
106 SWTBotMenu menuBot
= sessionItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM
);
109 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
111 SWTBotTree tracepointsTree
= shell
.bot().tree();
112 tracepointsTree
.select(ControlViewSwtBotUtil
.ALL_TREE_NODE
);
113 SWTBotText filterText
= shell
.bot().textInGroup(ControlViewSwtBotUtil
.FILTER_EXPRESSION_LABEL
);
114 filterText
.setText(FILTER_EXPRESSION
);
115 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
116 SWTBotUtils
.waitForJobs();
118 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, sessionItem
));
120 SWTBotTreeItem kernelDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
122 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
124 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
);
125 assertEquals(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, kernelDomainItem
.getText());
127 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
129 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
131 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
132 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
133 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
135 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
137 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
139 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
140 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
141 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
142 assertEquals(ControlViewSwtBotUtil
.ALL_EVENTS_NAME
, eventItem
.getText());
144 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
145 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
147 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
148 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
149 ControlViewSwtBotUtil
.ALL_EVENTS_NAME
);
151 assertTrue(comp
instanceof TraceEventComponent
);
152 TraceEventComponent event
= (TraceEventComponent
) comp
;
153 assertEquals(FILTER_EXPRESSION_DISPLAY
, event
.getFilterExpression());
156 private void testEnableKernelFromProviderEvent() {
157 SWTBotTreeItem kernelProviderEventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
159 ControlViewSwtBotUtil
.PROVIDER_GROUP_NAME
,
160 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
161 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
163 kernelProviderEventItem
.select();
164 SWTBotMenu menuBot
= kernelProviderEventItem
.contextMenu(ControlViewSwtBotUtil
.ENABLE_EVENT_MENU_ITEM
);
167 SWTBotShell shell
= fBot
.shell(ControlViewSwtBotUtil
.ENABLE_EVENT_DIALOG_TITLE
).activate();
168 SWTBotCCombo sessionCombo
= shell
.bot().ccomboBoxInGroup(ControlViewSwtBotUtil
.SESSION_LIST_GROUP_NAME
);
169 sessionCombo
.setSelection(getSessionName());
170 SWTBotText filterText
= shell
.bot().textInGroup(ControlViewSwtBotUtil
.FILTER_EXPRESSION_LABEL
);
171 filterText
.setText(FILTER_EXPRESSION
);
172 shell
.bot().button(ControlViewSwtBotUtil
.DIALOG_OK_BUTTON
).click();
173 SWTBotUtils
.waitForJobs();
175 SWTBotTreeItem sessionItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
177 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
180 fBot
.waitUntil(ConditionHelpers
.IsTreeChildNodeAvailable(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, sessionItem
));
182 SWTBotTreeItem kernelDomainItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
184 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
186 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
);
187 assertEquals(ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
, kernelDomainItem
.getText());
189 SWTBotTreeItem channelItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
191 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
193 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
194 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
);
195 assertEquals(ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
, channelItem
.getText());
197 SWTBotTreeItem eventItem
= SWTBotUtils
.getTreeItem(fBot
, fTree
,
199 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
201 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
202 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
203 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
204 assertEquals(ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
, eventItem
.getText());
206 ITraceControlComponent comp
= ControlViewSwtBotUtil
.getComponent(fNode
,
207 ControlViewSwtBotUtil
.SESSION_GROUP_NAME
,
209 ControlViewSwtBotUtil
.KERNEL_DOMAIN_NAME
,
210 ControlViewSwtBotUtil
.DEFAULT_CHANNEL_NAME
,
211 ControlViewSwtBotUtil
.SCHED_SWITCH_EVENT_NAME
);
213 assertTrue(comp
instanceof TraceEventComponent
);
214 TraceEventComponent event
= (TraceEventComponent
) comp
;
215 assertEquals(FILTER_EXPRESSION_DISPLAY
, event
.getFilterExpression());