control: command support for enabling all tracepoints/syscalls
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / swtbot / tests / ControlViewKernelFilterTest.java
CommitLineData
43628e7b
BH
1/*******************************************************************************
2 * Copyright (c) 2015 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
10package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
11
12import static org.junit.Assert.assertEquals;
13import static org.junit.Assert.assertNotNull;
14import static org.junit.Assert.assertTrue;
15
16import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
17import org.eclipse.swtbot.swt.finder.widgets.SWTBotCCombo;
18import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
19import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
20import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
21import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
22import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
23import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
24import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
25import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
26import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
27import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
28import org.junit.Test;
29import org.junit.runner.RunWith;
30
31/**
32 * Test for the Control view in Trace Compass. This will test the save and load feature.
33 *
34 * @author Bernd Hufmann
35 */
36@RunWith(SWTBotJunit4ClassRunner.class)
37public class ControlViewKernelFilterTest extends ControlViewTest {
38
39 // ------------------------------------------------------------------------
40 // Constants
41 // ------------------------------------------------------------------------
155ccbfe 42 private static final String TEST_STREAM = "CreateSessionTestLTTng2_8.cfg";
43628e7b
BH
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";
45
46 private static final String SESSION_NAME = "mysession";
47 private static final String FILTER_EXPRESSION = "next_tid==1234";
155ccbfe 48 private static final String FILTER_EXPRESSION_DISPLAY = "foo > 10";
43628e7b
BH
49
50 @Override
51 protected String getTestStream() {
52 return TEST_STREAM;
53 }
54
55 @Override
56 protected String getSessionName() {
57 return SESSION_NAME;
58 }
59
60 @Override
61 @Test
62 public void testTraceSessionTree() {
63
64 fProxy.setTestFile(fTestFile);
65 fProxy.setScenario(INIT_SCENARIO_NAME);
66
67 testConnectToNode();
68 // Prepare for saving of profile
69 fProxy.setScenario(CREATE_SESSION_KERNEL_FILTER_SCENARIO_NAME);
70 testCreateSession();
71 testEnableKernelEvent();
72 testStartStopTracing(TraceSessionState.ACTIVE);
73 testStartStopTracing(TraceSessionState.INACTIVE);
74 testDestroySession();
75 testDisconnectFromNode();
76 }
77
78 /**
79 * Test enable events from Kernel provider
80 */
81 @Test
82 public void testTraceSessionTreeKernelProvider() {
83
84 fProxy.setTestFile(fTestFile);
85 fProxy.setScenario(INIT_SCENARIO_NAME);
86
87 testConnectToNode();
88 // Prepare for saving of profile
89 fProxy.setScenario(CREATE_SESSION_KERNEL_FILTER_PROVIDER_SCENARIO_NAME);
90 testCreateSession();
91 testEnableKernelFromProviderEvent();
92 testStartStopTracing(TraceSessionState.ACTIVE);
93 testStartStopTracing(TraceSessionState.INACTIVE);
94 testDestroySession();
95 testDisconnectFromNode();
96 }
97
98 @Override
99 protected void testEnableKernelEvent() {
100 SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
101 getNodeName(),
102 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
103 getSessionName());
104
105 sessionItem.select();
106 SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
107 menuBot.click();
108
109 SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
110
9ee91a86
BH
111 shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME).click();
112
43628e7b
BH
113 SWTBotTree tracepointsTree = shell.bot().tree();
114 tracepointsTree.select(ControlViewSwtBotUtil.ALL_TREE_NODE);
115 SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
116 filterText.setText(FILTER_EXPRESSION);
117 shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
118 SWTBotUtils.waitForJobs();
119
120 fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));
121
122 SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
123 getNodeName(),
124 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
125 getSessionName(),
126 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
127 assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());
128
129 SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
130 getNodeName(),
131 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
132 getSessionName(),
133 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
134 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
135 assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
136
137 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
138 getNodeName(),
139 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
140 getSessionName(),
141 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
142 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
143 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
144 assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
145
146 ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
147 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
148 getSessionName(),
149 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
150 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
151 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
152 assertNotNull(comp);
153 assertTrue(comp instanceof TraceEventComponent);
154 TraceEventComponent event = (TraceEventComponent) comp;
155 assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
156 }
157
158 private void testEnableKernelFromProviderEvent() {
159 SWTBotTreeItem kernelProviderEventItem = SWTBotUtils.getTreeItem(fBot, fTree,
160 getNodeName(),
161 ControlViewSwtBotUtil.PROVIDER_GROUP_NAME,
162 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
163 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
164
165 kernelProviderEventItem.select();
166 SWTBotMenu menuBot = kernelProviderEventItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM);
167 menuBot.click();
168
169 SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
170 SWTBotCCombo sessionCombo = shell.bot().ccomboBoxInGroup(ControlViewSwtBotUtil.SESSION_LIST_GROUP_NAME);
171 sessionCombo.setSelection(getSessionName());
172 SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
173 filterText.setText(FILTER_EXPRESSION);
174 shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
175 SWTBotUtils.waitForJobs();
176
177 SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
178 getNodeName(),
179 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
180 getSessionName());
181
182 fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));
183
184 SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
185 getNodeName(),
186 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
187 getSessionName(),
188 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
189 assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());
190
191 SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
192 getNodeName(),
193 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
194 getSessionName(),
195 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
196 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
197 assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
198
199 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
200 getNodeName(),
201 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
202 getSessionName(),
203 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
204 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
205 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
206 assertEquals(ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME, eventItem.getText());
207
208 ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
209 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
210 getSessionName(),
211 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
212 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
213 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
214 assertNotNull(comp);
215 assertTrue(comp instanceof TraceEventComponent);
216 TraceEventComponent event = (TraceEventComponent) comp;
217 assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
218 }
219
220}
This page took 0.042869 seconds and 5 git commands to generate.