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