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