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