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