Commit | Line | Data |
---|---|---|
2fe6a9ea PT |
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 | * Contributors: | |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests; | |
14 | ||
6675124f MK |
15 | import static org.junit.Assert.assertEquals; |
16 | import static org.junit.Assert.assertNotNull; | |
2fe6a9ea PT |
17 | import static org.junit.Assert.assertTrue; |
18 | ||
2fe6a9ea | 19 | import org.eclipse.jdt.annotation.NonNull; |
6e4a07af | 20 | import org.eclipse.swt.SWT; |
2fe6a9ea | 21 | import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; |
6675124f | 22 | import org.eclipse.swtbot.swt.finder.SWTBot; |
2fe6a9ea | 23 | import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; |
b0d2c558 | 24 | import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; |
2fe6a9ea PT |
25 | import org.eclipse.swtbot.swt.finder.keyboard.Keyboard; |
26 | import org.eclipse.swtbot.swt.finder.keyboard.KeyboardFactory; | |
27 | import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; | |
28 | import org.eclipse.swtbot.swt.finder.matchers.WidgetOfType; | |
29 | import org.eclipse.swtbot.swt.finder.results.VoidResult; | |
6675124f MK |
30 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel; |
31 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton; | |
2fe6a9ea | 32 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; |
3553c912 PT |
33 | import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; |
34 | import org.eclipse.tracecompass.ctf.core.tests.shared.LttngKernelTraceGenerator; | |
2fe6a9ea PT |
35 | import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; |
36 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; | |
37 | import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal; | |
38 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; | |
2fe6a9ea | 39 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
b2c971ec | 40 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; |
2fe6a9ea PT |
41 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; |
42 | import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; | |
156e9ead | 43 | import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView; |
2fe6a9ea | 44 | import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl; |
156e9ead | 45 | import org.eclipse.ui.IWorkbenchPart; |
2fe6a9ea PT |
46 | import org.junit.Before; |
47 | import org.junit.Test; | |
b0d2c558 | 48 | import org.junit.runner.RunWith; |
2fe6a9ea PT |
49 | |
50 | /** | |
51 | * SWTBot tests for Control Flow view | |
52 | * | |
53 | * @author Patrick Tasse | |
54 | */ | |
b0d2c558 AM |
55 | @RunWith(SWTBotJunit4ClassRunner.class) |
56 | public class ControlFlowViewTest extends KernelTestBase { | |
2fe6a9ea | 57 | |
6675124f MK |
58 | private static final String CHECK_SELECTED = "Check selected"; |
59 | private static final String CHECK_ALL = "Check all"; | |
60 | private static final String CHECK_SUBTREE = "Check subtree"; | |
61 | private static final String CHECK_ACTIVE = "Check Active"; | |
62 | private static final String UNCHECK_SELECTED = "Uncheck selected"; | |
63 | private static final String UNCHECK_ALL = "Uncheck all"; | |
64 | private static final String UNCHECK_SUBTREE = "Uncheck subtree"; | |
65 | private static final String UNCHECK_INACTIVE = "Uncheck Inactive"; | |
66 | ||
6675124f | 67 | |
2fe6a9ea PT |
68 | private static final String FOLLOW_CPU_BACKWARD = "Follow CPU Backward"; |
69 | private static final String FOLLOW_CPU_FORWARD = "Follow CPU Forward"; | |
d33eb610 AM |
70 | private static final String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change"; |
71 | private static final String SELECT_NEXT_STATE_CHANGE = "Select Next State Change"; | |
3553c912 | 72 | private static final String SELECT_NEXT_PROCESS = "Select Next Process"; |
2fe6a9ea | 73 | private static final Keyboard KEYBOARD = KeyboardFactory.getSWTKeyboard(); |
b2c971ec MK |
74 | private static final @NonNull ITmfTimestamp START_TIME = TmfTimestamp.fromNanos(1368000272650993664L); |
75 | private static final @NonNull ITmfTimestamp TID1_TIME1 = TmfTimestamp.fromNanos(1368000272651208412L); | |
76 | private static final @NonNull ITmfTimestamp TID1_TIME2 = TmfTimestamp.fromNanos(1368000272656147616L); | |
77 | private static final @NonNull ITmfTimestamp TID1_TIME3 = TmfTimestamp.fromNanos(1368000272656362364L); | |
78 | private static final @NonNull ITmfTimestamp TID1_TIME4 = TmfTimestamp.fromNanos(1368000272663234300L); | |
79 | private static final @NonNull ITmfTimestamp TID1_TIME5 = TmfTimestamp.fromNanos(1368000272663449048L); | |
80 | private static final @NonNull ITmfTimestamp TID1_TIME6 = TmfTimestamp.fromNanos(1368000272665596528L); | |
81 | private static final @NonNull ITmfTimestamp TID2_TIME1 = TmfTimestamp.fromNanos(1368000272651852656L); | |
82 | private static final @NonNull ITmfTimestamp TID2_TIME2 = TmfTimestamp.fromNanos(1368000272652067404L); | |
83 | private static final @NonNull ITmfTimestamp TID2_TIME3 = TmfTimestamp.fromNanos(1368000272652282152L); | |
84 | private static final @NonNull ITmfTimestamp TID2_TIME4 = TmfTimestamp.fromNanos(1368000272652496900L); | |
85 | private static final @NonNull ITmfTimestamp TID5_TIME1 = TmfTimestamp.fromNanos(1368000272652496900L); | |
2fe6a9ea PT |
86 | |
87 | private SWTBotView fViewBot; | |
88 | ||
89 | /** | |
90 | * Before Test | |
91 | */ | |
92 | @Override | |
93 | @Before | |
94 | public void before() { | |
95 | super.before(); | |
96 | fViewBot = fBot.viewByTitle("Control Flow"); | |
b0d2c558 AM |
97 | fViewBot.show(); |
98 | fViewBot.setFocus(); | |
2fe6a9ea PT |
99 | } |
100 | ||
101 | /** | |
102 | * Test keyboard navigation using ARROW_RIGHT and ARROW_LEFT | |
103 | */ | |
104 | @Test | |
105 | public void testKeyboardLeftRight() { | |
156e9ead MAL |
106 | testNextPreviousEvent(() -> KEYBOARD.pressShortcut(Keystrokes.RIGHT), |
107 | () -> KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT), | |
108 | () -> KEYBOARD.pressShortcut(Keystrokes.LEFT), | |
109 | () -> KEYBOARD.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT)); | |
2fe6a9ea PT |
110 | } |
111 | ||
112 | /** | |
d33eb610 | 113 | * Test tool bar buttons "Select Next State Change" and "Select Previous State Change" |
2fe6a9ea PT |
114 | */ |
115 | @Test | |
d33eb610 AM |
116 | public void testToolBarSelectNextPreviousStateChange() { |
117 | testNextPreviousEvent(() -> fViewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(), | |
118 | () -> fViewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(SWT.SHIFT), | |
119 | () -> fViewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(), | |
120 | () -> fViewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(SWT.SHIFT)); | |
156e9ead MAL |
121 | } |
122 | ||
123 | private void testNextPreviousEvent(Runnable selectNext, Runnable shiftSelectNext, Runnable selectPrevious, Runnable shiftSelectPrevious) { | |
2fe6a9ea PT |
124 | /* change window range to 10 ms */ |
125 | TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE)); | |
126 | TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)); | |
127 | fBot.waitUntil(ConditionHelpers.windowRange(range)); | |
128 | ||
129 | /* set selection to trace start time */ | |
130 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
156e9ead | 131 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); |
2fe6a9ea PT |
132 | |
133 | /* select first item */ | |
134 | final SWTBotTree tree = fViewBot.bot().tree(); | |
135 | tree.pressShortcut(Keystrokes.HOME); | |
3553c912 | 136 | fViewBot.toolbarButton(SELECT_NEXT_PROCESS).click(); |
2fe6a9ea PT |
137 | |
138 | /* set focus on time graph */ | |
139 | final TimeGraphControl timegraph = fViewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)); | |
140 | UIThreadRunnable.syncExec(new VoidResult() { | |
141 | @Override | |
142 | public void run() { | |
143 | timegraph.setFocus(); | |
144 | } | |
145 | }); | |
146 | ||
d33eb610 | 147 | /* click "Select Next State Change" 3 times */ |
156e9ead MAL |
148 | selectNext.run(); |
149 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1)); | |
150 | selectNext.run(); | |
151 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME2, TID1_TIME2)); | |
152 | selectNext.run(); | |
153 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3)); | |
2fe6a9ea PT |
154 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME3))); |
155 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME3)); | |
156 | ||
d33eb610 | 157 | /* shift-click "Select Next State Change" 3 times */ |
156e9ead MAL |
158 | shiftSelectNext.run(); |
159 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME4)); | |
160 | shiftSelectNext.run(); | |
161 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME5)); | |
162 | shiftSelectNext.run(); | |
163 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME6)); | |
6e4a07af | 164 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME6))); |
2fe6a9ea PT |
165 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME6)); |
166 | ||
d33eb610 | 167 | /* shift-click "Select Previous State Change" 4 times */ |
156e9ead MAL |
168 | shiftSelectPrevious.run(); |
169 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME5)); | |
170 | shiftSelectPrevious.run(); | |
171 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME4)); | |
172 | shiftSelectPrevious.run(); | |
173 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3)); | |
174 | shiftSelectPrevious.run(); | |
175 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME2)); | |
6e4a07af | 176 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME2))); |
2fe6a9ea PT |
177 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME2)); |
178 | ||
d33eb610 | 179 | /* click "Select Next State Change" 2 times */ |
156e9ead MAL |
180 | selectNext.run(); |
181 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3)); | |
182 | selectNext.run(); | |
183 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4)); | |
2fe6a9ea PT |
184 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME4))); |
185 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME4)); | |
186 | ||
d33eb610 | 187 | /* shift-click "Select Previous State Change" 3 times */ |
156e9ead MAL |
188 | shiftSelectPrevious.run(); |
189 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME3)); | |
190 | shiftSelectPrevious.run(); | |
191 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME2)); | |
192 | shiftSelectPrevious.run(); | |
193 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME1)); | |
6e4a07af | 194 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME1))); |
2fe6a9ea PT |
195 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1)); |
196 | ||
d33eb610 | 197 | /* shift-click "Select Next State Change" 4 times */ |
156e9ead MAL |
198 | shiftSelectNext.run(); |
199 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME2)); | |
200 | shiftSelectNext.run(); | |
201 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME3)); | |
202 | shiftSelectNext.run(); | |
203 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4)); | |
204 | shiftSelectNext.run(); | |
205 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME5)); | |
6e4a07af | 206 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME5))); |
2fe6a9ea PT |
207 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME5)); |
208 | ||
d33eb610 | 209 | /* click "Select Previous State Change" 5 times */ |
156e9ead MAL |
210 | selectPrevious.run(); |
211 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4)); | |
212 | selectPrevious.run(); | |
213 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3)); | |
214 | selectPrevious.run(); | |
215 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME2, TID1_TIME2)); | |
216 | selectPrevious.run(); | |
217 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1)); | |
218 | selectPrevious.run(); | |
219 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); | |
2fe6a9ea PT |
220 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME))); |
221 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME)); | |
222 | } | |
223 | ||
6675124f MK |
224 | /** |
225 | * Test the legend content | |
226 | */ | |
227 | @Test | |
228 | public void testLegend() { | |
229 | String[] labelValues = { "UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED" }; | |
230 | SWTBotToolbarButton legendButton = fViewBot.toolbarButton("Show Legend"); | |
231 | legendButton.click(); | |
232 | fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("States Transition Visualizer")); | |
233 | SWTBot bot = fBot.activeShell().bot(); | |
234 | for (int i = 1; i < 8; i++) { | |
235 | SWTBotLabel label = bot.label(i); | |
236 | assertNotNull(label); | |
237 | assertEquals(labelValues[i - 1], label.getText()); | |
238 | } | |
239 | bot.button("OK").click(); | |
240 | } | |
241 | ||
242 | /** | |
243 | * Test the filter | |
244 | */ | |
245 | @Test | |
246 | public void testFilter() { | |
247 | /* change window range to 1 ms */ | |
248 | TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE)); | |
249 | TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)); | |
f149d124 | 250 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); |
6675124f MK |
251 | |
252 | SWTBotToolbarButton filterButton = fViewBot.toolbarButton("Show View Filters"); | |
253 | filterButton.click(); | |
254 | fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("Filter")); | |
255 | SWTBot bot = fBot.activeShell().bot(); | |
256 | SWTBotTree treeBot = bot.tree(); | |
257 | TreeCheckedCounter treeCheckCounter = new TreeCheckedCounter(treeBot); | |
258 | // get how many items there are | |
259 | Integer checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 260 | assertEquals("default", 226, checked.intValue()); |
6675124f MK |
261 | // test "uncheck all button" |
262 | bot.button(UNCHECK_ALL).click(); | |
263 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
264 | assertEquals(0, checked.intValue()); | |
265 | // test check active | |
266 | bot.button(CHECK_ACTIVE).click(); | |
267 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 268 | assertEquals(CHECK_ACTIVE, 69, checked.intValue()); |
6675124f MK |
269 | // test check all |
270 | bot.button(CHECK_ALL).click(); | |
271 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 272 | assertEquals(CHECK_ALL, 226, checked.intValue()); |
6675124f MK |
273 | // test uncheck inactive |
274 | bot.button(UNCHECK_INACTIVE).click(); | |
275 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 276 | assertEquals(UNCHECK_INACTIVE, 69, checked.intValue()); |
6675124f | 277 | // test check selected |
3553c912 | 278 | treeBot.getTreeItem(LttngKernelTraceGenerator.getName()).select("gnuplot"); |
6675124f MK |
279 | bot.button(UNCHECK_ALL).click(); |
280 | bot.button(CHECK_SELECTED).click(); | |
281 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 282 | assertEquals(CHECK_SELECTED, 2, checked.intValue()); |
6675124f MK |
283 | // test check subtree |
284 | bot.button(UNCHECK_ALL).click(); | |
285 | bot.button(CHECK_SUBTREE).click(); | |
286 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 287 | assertEquals(CHECK_SUBTREE, 2, checked.intValue()); |
6675124f MK |
288 | // test uncheck selected |
289 | bot.button(CHECK_ALL).click(); | |
290 | bot.button(UNCHECK_SELECTED).click(); | |
291 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 292 | assertEquals(UNCHECK_SELECTED, 225, checked.intValue()); |
6675124f MK |
293 | // test uncheck subtree |
294 | bot.button(CHECK_ALL).click(); | |
295 | bot.button(UNCHECK_SUBTREE).click(); | |
296 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 297 | assertEquals(UNCHECK_SELECTED, 225, checked.intValue()); |
6675124f MK |
298 | // test filter |
299 | bot.button(UNCHECK_ALL).click(); | |
300 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
301 | assertEquals(0, checked.intValue()); | |
302 | bot.text().setText("half-life 3"); | |
3553c912 PT |
303 | SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngKernelTraceGenerator.getName()); |
304 | treeItem.rowCount(); | |
305 | fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25)); | |
6675124f MK |
306 | bot.button(CHECK_ALL).click(); |
307 | checked = UIThreadRunnable.syncExec(treeCheckCounter); | |
3553c912 | 308 | assertEquals("Filtered", 26, checked.intValue()); |
6675124f MK |
309 | bot.button("OK").click(); |
310 | treeBot = fViewBot.bot().tree(); | |
3553c912 | 311 | treeItem = treeBot.getTreeItem(LttngKernelTraceGenerator.getName()); |
6675124f | 312 | for (int i = 0; i < 25; i++) { |
3553c912 | 313 | assertEquals("Filtered Control flow view", "Half-life 3", treeItem.cell(i, 0)); |
6675124f MK |
314 | } |
315 | } | |
316 | ||
2fe6a9ea PT |
317 | /** |
318 | * Test tool bar buttons "Follow CPU Forward" and "Follow CPU Backward" | |
319 | */ | |
320 | @Test | |
321 | public void testToolBarFollowCPUForwardBackward() { | |
322 | /* change window range to 10 ms */ | |
323 | TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE)); | |
324 | TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)); | |
325 | fBot.waitUntil(ConditionHelpers.windowRange(range)); | |
326 | ||
327 | /* set selection to trace start time */ | |
328 | TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME)); | |
329 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME))); | |
330 | ||
331 | /* select first item */ | |
332 | final SWTBotTree tree = fViewBot.bot().tree(); | |
333 | tree.pressShortcut(Keystrokes.HOME); | |
3553c912 | 334 | fViewBot.toolbarButton(SELECT_NEXT_PROCESS).click(); |
2fe6a9ea PT |
335 | |
336 | /* set focus on time graph */ | |
337 | final TimeGraphControl timegraph = fViewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)); | |
338 | UIThreadRunnable.syncExec(new VoidResult() { | |
339 | @Override | |
340 | public void run() { | |
341 | timegraph.setFocus(); | |
342 | } | |
343 | }); | |
344 | ||
2fe6a9ea | 345 | /* click "Follow CPU Forward" 3 times */ |
156e9ead | 346 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); |
2fe6a9ea | 347 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(); |
156e9ead | 348 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1)); |
2fe6a9ea | 349 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(); |
156e9ead | 350 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1)); |
2fe6a9ea | 351 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(); |
156e9ead | 352 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2)); |
2fe6a9ea | 353 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME2))); |
6e4a07af | 354 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2")); |
2fe6a9ea PT |
355 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME2)); |
356 | ||
6e4a07af PT |
357 | /* shift-click "Follow CPU Forward" 3 times */ |
358 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); | |
156e9ead | 359 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3)); |
6e4a07af | 360 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); |
156e9ead | 361 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4)); |
6e4a07af | 362 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); |
156e9ead | 363 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4)); |
6e4a07af PT |
364 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID5_TIME1))); |
365 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "5")); | |
2fe6a9ea PT |
366 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID5_TIME1)); |
367 | ||
6e4a07af PT |
368 | /* shift-click "Follow CPU Backward" 4 times */ |
369 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); | |
156e9ead | 370 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4)); |
6e4a07af | 371 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); |
156e9ead | 372 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3)); |
6e4a07af | 373 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); |
156e9ead | 374 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2)); |
6e4a07af | 375 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); |
156e9ead | 376 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME1)); |
6e4a07af PT |
377 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME1))); |
378 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2")); | |
2fe6a9ea PT |
379 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME1)); |
380 | ||
381 | /* click "Follow CPU Forward" 2 times */ | |
382 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(); | |
156e9ead | 383 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2)); |
2fe6a9ea | 384 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(); |
156e9ead | 385 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3)); |
2fe6a9ea | 386 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME3))); |
6e4a07af | 387 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2")); |
2fe6a9ea PT |
388 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME3)); |
389 | ||
6e4a07af PT |
390 | /* shift-click "Follow CPU Backward" 3 times */ |
391 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); | |
156e9ead | 392 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2)); |
6e4a07af | 393 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); |
156e9ead | 394 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1)); |
6e4a07af | 395 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT); |
156e9ead | 396 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID1_TIME1)); |
6e4a07af PT |
397 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID1_TIME1))); |
398 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "1")); | |
2fe6a9ea PT |
399 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1)); |
400 | ||
6e4a07af PT |
401 | /* shift-click "Follow CPU Forward" 4 times */ |
402 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); | |
156e9ead | 403 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1)); |
6e4a07af | 404 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); |
156e9ead | 405 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2)); |
6e4a07af | 406 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); |
156e9ead | 407 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3)); |
6e4a07af | 408 | fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT); |
156e9ead | 409 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME4)); |
6e4a07af PT |
410 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME4))); |
411 | fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2")); | |
2fe6a9ea PT |
412 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME4)); |
413 | ||
414 | /* click "Follow CPU Backward" 5 times */ | |
415 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(); | |
156e9ead | 416 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3)); |
2fe6a9ea | 417 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(); |
156e9ead | 418 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2)); |
2fe6a9ea | 419 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(); |
156e9ead | 420 | timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1)); |
2fe6a9ea | 421 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(); |
156e9ead | 422 | timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1)); |
2fe6a9ea | 423 | fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(); |
156e9ead | 424 | timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME)); |
2fe6a9ea PT |
425 | fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME))); |
426 | assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME)); | |
427 | } | |
156e9ead MAL |
428 | |
429 | private void timeGraphIsReadyCondition(@NonNull TmfTimeRange selectionRange) { | |
430 | IWorkbenchPart part = fViewBot.getViewReference().getPart(false); | |
431 | fBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, selectionRange, selectionRange.getEndTime())); | |
432 | } | |
2fe6a9ea | 433 | } |