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; | |
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_7.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 = "with filter"; | |
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 | 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(); | |
117 | ||
118 | fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem)); | |
119 | ||
120 | SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
121 | getNodeName(), | |
122 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
123 | getSessionName(), | |
124 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME); | |
125 | assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText()); | |
126 | ||
127 | SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
128 | getNodeName(), | |
129 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
130 | getSessionName(), | |
131 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
132 | ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME); | |
133 | assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText()); | |
134 | ||
135 | SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
136 | getNodeName(), | |
137 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
138 | getSessionName(), | |
139 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
140 | ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, | |
141 | ControlViewSwtBotUtil.ALL_EVENTS_NAME); | |
142 | assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText()); | |
143 | ||
144 | ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode, | |
145 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
146 | getSessionName(), | |
147 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
148 | ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, | |
149 | ControlViewSwtBotUtil.ALL_EVENTS_NAME); | |
150 | assertNotNull(comp); | |
151 | assertTrue(comp instanceof TraceEventComponent); | |
152 | TraceEventComponent event = (TraceEventComponent) comp; | |
153 | assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression()); | |
154 | } | |
155 | ||
156 | private void testEnableKernelFromProviderEvent() { | |
157 | SWTBotTreeItem kernelProviderEventItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
158 | getNodeName(), | |
159 | ControlViewSwtBotUtil.PROVIDER_GROUP_NAME, | |
160 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
161 | ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME); | |
162 | ||
163 | kernelProviderEventItem.select(); | |
164 | SWTBotMenu menuBot = kernelProviderEventItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM); | |
165 | menuBot.click(); | |
166 | ||
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(); | |
174 | ||
175 | SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
176 | getNodeName(), | |
177 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
178 | getSessionName()); | |
179 | ||
180 | fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem)); | |
181 | ||
182 | SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
183 | getNodeName(), | |
184 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
185 | getSessionName(), | |
186 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME); | |
187 | assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText()); | |
188 | ||
189 | SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
190 | getNodeName(), | |
191 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
192 | getSessionName(), | |
193 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
194 | ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME); | |
195 | assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText()); | |
196 | ||
197 | SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree, | |
198 | getNodeName(), | |
199 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
200 | getSessionName(), | |
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()); | |
205 | ||
206 | ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode, | |
207 | ControlViewSwtBotUtil.SESSION_GROUP_NAME, | |
208 | getSessionName(), | |
209 | ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, | |
210 | ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, | |
211 | ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME); | |
212 | assertNotNull(comp); | |
213 | assertTrue(comp instanceof TraceEventComponent); | |
214 | TraceEventComponent event = (TraceEventComponent) comp; | |
215 | assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression()); | |
216 | } | |
217 | ||
218 | } |