b78b17b92072f15913e1ca8771bfdacbac2e3ae5
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests / src / org / eclipse / tracecompass / lttng2 / control / ui / swtbot / tests / ControlViewKernelFilterTest.java
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
10 package org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertTrue;
15
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;
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)
37 public class ControlViewKernelFilterTest extends ControlViewTest {
38
39 // ------------------------------------------------------------------------
40 // Constants
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";
45
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";
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
111 shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME).click();
112
113 SWTBotTree tracepointsTree = shell.bot().tree();
114 SWTBotTreeItem allItem = SWTBotUtils.getTreeItem(fBot, tracepointsTree, ControlViewSwtBotUtil.ALL_TREE_NODE);
115 allItem.check();
116
117 SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
118 filterText.setText(FILTER_EXPRESSION);
119 shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
120 SWTBotUtils.waitForJobs();
121
122 fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));
123
124 SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
125 getNodeName(),
126 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
127 getSessionName(),
128 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
129 assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());
130
131 SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
132 getNodeName(),
133 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
134 getSessionName(),
135 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
136 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
137 assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
138
139 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
140 getNodeName(),
141 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
142 getSessionName(),
143 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
144 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
145 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
146 assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
147
148 ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
149 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
150 getSessionName(),
151 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
152 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
153 ControlViewSwtBotUtil.ALL_EVENTS_NAME);
154 assertNotNull(comp);
155 assertTrue(comp instanceof TraceEventComponent);
156 TraceEventComponent event = (TraceEventComponent) comp;
157 assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
158 }
159
160 private void testEnableKernelFromProviderEvent() {
161 SWTBotTreeItem kernelProviderEventItem = SWTBotUtils.getTreeItem(fBot, fTree,
162 getNodeName(),
163 ControlViewSwtBotUtil.PROVIDER_GROUP_NAME,
164 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
165 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
166
167 kernelProviderEventItem.select();
168 SWTBotMenu menuBot = kernelProviderEventItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM);
169 menuBot.click();
170
171 SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
172 SWTBotCCombo sessionCombo = shell.bot().ccomboBoxInGroup(ControlViewSwtBotUtil.SESSION_LIST_GROUP_NAME);
173 sessionCombo.setSelection(getSessionName());
174 SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
175 filterText.setText(FILTER_EXPRESSION);
176 shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
177 SWTBotUtils.waitForJobs();
178
179 SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
180 getNodeName(),
181 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
182 getSessionName());
183
184 fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));
185
186 SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
187 getNodeName(),
188 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
189 getSessionName(),
190 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
191 assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());
192
193 SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
194 getNodeName(),
195 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
196 getSessionName(),
197 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
198 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
199 assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());
200
201 SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
202 getNodeName(),
203 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
204 getSessionName(),
205 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
206 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
207 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
208 assertEquals(ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME, eventItem.getText());
209
210 ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
211 ControlViewSwtBotUtil.SESSION_GROUP_NAME,
212 getSessionName(),
213 ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
214 ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
215 ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
216 assertNotNull(comp);
217 assertTrue(comp instanceof TraceEventComponent);
218 TraceEventComponent event = (TraceEventComponent) comp;
219 assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
220 }
221
222 }
This page took 0.036029 seconds and 4 git commands to generate.