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