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