/
ControlFlowViewTest.java
740 lines (637 loc) · 36.4 KB
/
ControlFlowViewTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
/*******************************************************************************
* Copyright (c) 2015, 2018 Ericsson and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Tasse - Initial API and implementation
*******************************************************************************/
package org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.tracecompass.ctf.core.tests.shared.LttngTraceGenerator;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow.ControlFlowView;
import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.junit.Before;
import org.junit.Test;
/**
* SWTBot tests for Control Flow view
*
* @author Patrick Tasse
*/
public class ControlFlowViewTest extends KernelTimeGraphViewTestBase {
private static final String DIALOG_OK = "OK";
private static final String DIALOG_CANCEL = "Cancel";
private static final String THREAD_PRESENTATION_HIERARCHICAL = "Hierarchical";
private static final String THREAD_PRESENTATION_FLAT = "Flat";
private static final String DYNAMIC_FILTER_ACTIVE_THREADS_ONLY_TOGGLE = "Active Threads only";
private static final String DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE = "e.g. 0-3,5,7-8";
private static final String DYNAMIC_FILTERS_ALL_ACTIVE_RADIO = "All Active Threads";
private static final String DYNAMIC_FILTERS_ON_CPU_RADIO = "Active Threads on CPUs:";
private static final String DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX = "Show Active Threads Only";
private static final String DYNAMIC_FILTERS_SHELL_TEXT = "Dynamic Filters Configuration";
private static final String DYNAMIC_FILTER_CONFIGURE_LABEL = "Configure...";
private static final String CHECK_SELECTED = "Check selected";
private static final String CHECK_ALL = "Check all";
private static final String CHECK_SUBTREE = "Check subtree";
private static final String CHECK_ACTIVE = "Check Active";
private static final String UNCHECK_SELECTED = "Uncheck selected";
private static final String UNCHECK_ALL = "Uncheck all";
private static final String UNCHECK_SUBTREE = "Uncheck subtree";
private static final String UNCHECK_INACTIVE = "Uncheck Inactive";
private static final String FOLLOW_CPU_BACKWARD = "Follow CPU Backward";
private static final String FOLLOW_CPU_FORWARD = "Follow CPU Forward";
private static final String SELECT_PREVIOUS_STATE_CHANGE = "Select Previous State Change";
private static final String SELECT_NEXT_STATE_CHANGE = "Select Next State Change";
private static final @NonNull ITmfTimestamp TID1_TIME1 = TmfTimestamp.fromNanos(1368000272651208498L);
private static final @NonNull ITmfTimestamp TID1_TIME2 = TmfTimestamp.fromNanos(1368000272656149680L);
private static final @NonNull ITmfTimestamp TID1_TIME3 = TmfTimestamp.fromNanos(1368000272656364514L);
private static final @NonNull ITmfTimestamp TID1_TIME4 = TmfTimestamp.fromNanos(1368000272663239202L);
private static final @NonNull ITmfTimestamp TID1_TIME5 = TmfTimestamp.fromNanos(1368000272663454036L);
private static final @NonNull ITmfTimestamp TID1_TIME6 = TmfTimestamp.fromNanos(1368000272665602376L);
private static final @NonNull ITmfTimestamp TID2_TIME1 = TmfTimestamp.fromNanos(1368000272651853000L);
private static final @NonNull ITmfTimestamp TID2_TIME2 = TmfTimestamp.fromNanos(1368000272652067834L);
private static final @NonNull ITmfTimestamp TID2_TIME3 = TmfTimestamp.fromNanos(1368000272652282668L);
private static final @NonNull ITmfTimestamp TID2_TIME4 = TmfTimestamp.fromNanos(1368000272652497502L);
private static final @NonNull ITmfTimestamp TID5_TIME1 = TmfTimestamp.fromNanos(1368000272652497502L);
@Override
protected SWTBotView getViewBot() {
return fBot.viewByTitle("Control Flow");
}
@Override
protected SWTBotView openView() {
SWTBotUtils.openView(ControlFlowView.ID);
return getViewBot();
}
@Override
protected List<String> getLegendValues() {
return Arrays.asList("Unknown", "Usermode", "System call", "Interrupt", "Wait blocked", "Wait for CPU", "Wait");
}
@Override
protected List<String> getToolbarTooltips() {
return Arrays.asList("Optimize", SEPARATOR,
"Hide Empty Rows", "Show View Filters", "Show Legend", SEPARATOR,
"Reset the Time Scale to Default", "Select Previous State Change", "Select Next State Change", SEPARATOR,
"Add Bookmark...", "Previous Marker", "Next Marker", SEPARATOR,
"Select Previous Process", "Select Next Process", "Zoom In", "Zoom Out", SEPARATOR,
"Hide Arrows", "Follow CPU Backward", "Follow CPU Forward",
"Go to previous event of the selected thread", "Go to next event of the selected thread", SEPARATOR,
"Pin View");
}
/**
* Before Test
*/
@Override
@Before
public void before() {
SWTBotView viewBot = getViewBot();
viewBot.show();
super.before();
viewBot.setFocus();
}
/**
* Test keyboard navigation using ARROW_RIGHT and ARROW_LEFT
*/
@Test
public void testKeyboardLeftRight() {
SWTBotView viewBot = getViewBot();
SWTBotCanvas canvas = viewBot.bot().canvas(1);
testNextPreviousEvent(
() -> {
canvas.setFocus();
canvas.pressShortcut(Keystrokes.RIGHT);
},
() -> {
canvas.setFocus();
canvas.pressShortcut(Keystrokes.SHIFT, Keystrokes.RIGHT);
},
() -> {
canvas.setFocus();
canvas.pressShortcut(Keystrokes.LEFT);
},
() -> {
canvas.setFocus();
canvas.pressShortcut(Keystrokes.SHIFT, Keystrokes.LEFT);
});
}
/**
* Test tool bar buttons "Select Next State Change" and "Select Previous
* State Change"
*/
@Test
public void testToolBarSelectNextPreviousStateChange() {
SWTBotView viewBot = getViewBot();
testNextPreviousEvent(() -> viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(),
() -> viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(SWT.SHIFT),
() -> viewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(),
() -> viewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click(SWT.SHIFT));
}
private void testNextPreviousEvent(Runnable selectNext, Runnable shiftSelectNext, Runnable selectPrevious, Runnable shiftSelectPrevious) {
/* change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
fBot.waitUntil(ConditionHelpers.windowRange(range));
/* set selection to trace start time */
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME));
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
/* set focus on time graph */
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
timeGraph.setFocus();
/* select first thread */
timeGraph.getEntry(LttngTraceGenerator.getName(), "gnuplot").select();
/* click "Select Next State Change" 3 times */
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME2, TID1_TIME2));
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME3)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME3));
/* shift-click "Select Next State Change" 3 times */
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME4));
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME5));
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME6));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME6)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME6));
/* shift-click "Select Previous State Change" 4 times */
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME5));
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME4));
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3));
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME2));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME3, TID1_TIME2)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME2));
/* click "Select Next State Change" 2 times */
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3));
selectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME4)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME4));
/* shift-click "Select Previous State Change" 3 times */
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME3));
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME2));
shiftSelectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME1));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME1)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
/* shift-click "Select Next State Change" 4 times */
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME2));
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME3));
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4));
shiftSelectNext.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME5));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID1_TIME4, TID1_TIME5)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME5));
/* click "Select Previous State Change" 5 times */
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME4, TID1_TIME4));
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME3, TID1_TIME3));
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME2, TID1_TIME2));
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
selectPrevious.run();
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
}
/**
* Test the filter
*/
@Test
public void testFilter() {
/* change window range to 1 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
SWTBotView viewBot = getViewBot();
SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
filterButton.click();
SWTBot bot = fBot.shell("Filter").activate().bot();
SWTBotTree treeBot = bot.tree();
// get how many items there are
int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals("default", 226, checked);
// test "uncheck all button"
bot.button(UNCHECK_ALL).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(0, checked);
// test check active
bot.button(CHECK_ACTIVE).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(CHECK_ACTIVE, 69, checked);
// test check all
bot.button(CHECK_ALL).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(CHECK_ALL, 226, checked);
// test uncheck inactive
bot.button(UNCHECK_INACTIVE).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(UNCHECK_INACTIVE, 69, checked);
// test check selected
treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot");
bot.button(UNCHECK_ALL).click();
bot.button(CHECK_SELECTED).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(CHECK_SELECTED, 2, checked);
// test check subtree
bot.button(UNCHECK_ALL).click();
bot.button(CHECK_SUBTREE).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(CHECK_SUBTREE, 2, checked);
// test uncheck selected
bot.button(CHECK_ALL).click();
bot.button(UNCHECK_SELECTED).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(UNCHECK_SELECTED, 225, checked);
// test uncheck subtree
bot.button(CHECK_ALL).click();
bot.button(UNCHECK_SUBTREE).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(UNCHECK_SELECTED, 225, checked);
// test filter
bot.button(UNCHECK_ALL).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals(0, checked);
bot.text().setText("half-life 3");
SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
treeItem.rowCount();
fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25));
bot.button(CHECK_ALL).click();
checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
assertEquals("Filtered", 26, checked);
bot.button(DIALOG_OK).click();
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
for (SWTBotTimeGraphEntry entry : traceEntry.getEntries()) {
assertEquals("Filtered Control flow view", "Half-life 3", entry.getText());
}
}
/**
* Test dynamic filters dialog
*/
@Test
public void testDynamicFiltersDialog() {
String valid_cpu_ranges = "0,1,2-100";
String invalid_cpu_ranges = "-1,1";
/* Change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
timeGraphIsReadyCondition(range);
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
SWTBotShell shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
/* Make sure nothing is checked and radio buttons are disabled */
SWTBotCheckBox activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
SWTBotRadio onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
SWTBotRadio allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
SWTBotText onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
assertFalse(activeThreadsCheckbox.isChecked());
assertFalse(onCpuRadio.isEnabled());
assertFalse(allActiveRadio.isEnabled());
assertFalse(onCpuField.isEnabled());
/*
* Test Active Filter buttons toggle
*/
activeThreadsCheckbox.click();
/* All objects should be enabled except for the CPU ranges field */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertFalse(onCpuField.isEnabled());
/*
* The All Active Threads option should be the default for a new filter
*/
assertTrue(allActiveRadio.isSelected());
/*
* Select All Threads on CPUs option
*/
onCpuRadio.click();
/* All objects should be enabled */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertTrue(onCpuField.isEnabled());
assertFalse(allActiveRadio.isSelected());
assertTrue(onCpuRadio.isSelected());
/*
* Select All Active Threads then Active Threads on CPUs to validate
* toggle of options
*/
allActiveRadio.click();
/* All objects should be enabled except for the CPU ranges field */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertFalse(onCpuField.isEnabled());
assertTrue(allActiveRadio.isSelected());
assertFalse(onCpuRadio.isSelected());
/* Select Active Threads on CPUs */
onCpuRadio.click();
/* All objects should be enabled */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertTrue(onCpuField.isEnabled());
assertFalse(allActiveRadio.isSelected());
assertTrue(onCpuRadio.isSelected());
/* Put an invalid value in the CPU ranges field */
onCpuField.setText(invalid_cpu_ranges);
/* Make sure the OK button is not enabled when in an invalid state */
assertFalse(shell.bot().button(DIALOG_OK).isEnabled());
/* Put a valid value in the CPU ranges field */
onCpuField.setText(valid_cpu_ranges);
/* Make sure the OK button is enabled when in a valid state */
assertTrue(shell.bot().button(DIALOG_OK).isEnabled());
shell.bot().button(DIALOG_OK).click();
timeGraphIsReadyCondition(range);
/* Make sure that the quick Active Thread Filter toggle is checked */
assertTrue(getViewBot().viewMenu(DYNAMIC_FILTER_ACTIVE_THREADS_ONLY_TOGGLE).isChecked());
/* Make sure that the Flat presentation is checked */
assertTrue(getViewBot().viewMenu(THREAD_PRESENTATION_FLAT).isChecked());
assertFalse(getViewBot().viewMenu(THREAD_PRESENTATION_HIERARCHICAL).isChecked());
/* Reopen the dialog */
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
/* Make sure nothing is checked and radio buttons are disabled */
activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
/* Make sure the previous settings are set correctly */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertTrue(onCpuField.isEnabled());
assertFalse(allActiveRadio.isSelected());
assertTrue(onCpuRadio.isSelected());
assertTrue(onCpuField.isEnabled());
assertEquals("CPU ranges not equal", onCpuField.getText(), valid_cpu_ranges);
/*
* Change to All Active Threads option click OK then reopen. The
* previous CPU range should still be there.
*/
allActiveRadio.click();
/* Make sure that the ranges are still visible but disabled */
assertFalse(onCpuField.isEnabled());
assertEquals("Cpu ranges not equal", onCpuField.getText(), valid_cpu_ranges);
/* Close the dialog */
shell.bot().button(DIALOG_OK).click();
timeGraphIsReadyCondition(range);
/* Open the dialog */
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
allActiveRadio = shell.bot().radio(DYNAMIC_FILTERS_ALL_ACTIVE_RADIO);
onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
/* Range field should have a value in it */
assertTrue(activeThreadsCheckbox.isChecked());
assertTrue(allActiveRadio.isEnabled());
assertTrue(onCpuRadio.isEnabled());
assertFalse(onCpuField.isEnabled());
assertTrue(allActiveRadio.isSelected());
assertFalse(onCpuRadio.isSelected());
assertFalse(onCpuField.isEnabled());
assertEquals("CPU ranges not equal", onCpuField.getText(), valid_cpu_ranges);
shell.bot().button(DIALOG_CANCEL).click();
}
/**
* Test dynamic filters dialog
*/
@Test
public void testDynamicFiltering() {
/* Change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
timeGraphIsReadyCondition(range);
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
SWTBotUtils.waitUntil(entry -> entry.getEntries().length == 225, traceEntry, () -> "Entries size expected:225 actual:" + traceEntry.getEntries().length);
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
SWTBotShell shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
/* Make sure nothing is checked and radio buttons are disabled */
SWTBotCheckBox activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
assertFalse(activeThreadsCheckbox.isChecked());
/*
* Test Active Filter buttons toggle
*/
activeThreadsCheckbox.click();
/* All objects should be enabled except for the CPU ranges field */
assertTrue(activeThreadsCheckbox.isChecked());
shell.bot().button(DIALOG_OK).click();
/*
* A zoom thread is started after applying the filter. Make sure that the time graph
* is ready before continuing with the test
*/
timeGraphIsReadyCondition(range);
/* Change window range to 50 us */
range = new TmfTimeRange(START_TIME, START_TIME.normalize(50000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
timeGraphIsReadyCondition(range);
/* Verify that number active entries changed */
SWTBotUtils.waitUntil(entry -> entry.getEntries().length == 7, traceEntry, () -> "Entries size expected:7 actual:" + traceEntry.getEntries().length);
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
assertTrue(activeThreadsCheckbox.isChecked());
/*
* Test Active Filter buttons toggle
*/
activeThreadsCheckbox.click();
/* All objects should be enabled except for the CPU ranges field */
assertFalse(activeThreadsCheckbox.isChecked());
}
/**
* Test dynamic filters dialog on CPU
*/
@Test
public void testDynamicFilteringCpu() {
/* Change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
timeGraphIsReadyCondition(range);
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
SWTBotUtils.waitUntil(entry -> entry.getEntries().length == 225, traceEntry, () -> "Entries size expected:225 actual:" + traceEntry.getEntries().length);
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
SWTBotShell shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
/* Make sure nothing is checked and radio buttons are disabled */
SWTBotCheckBox activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
assertFalse(activeThreadsCheckbox.isChecked());
SWTBotRadio onCpuRadio = shell.bot().radio(DYNAMIC_FILTERS_ON_CPU_RADIO);
SWTBotText onCpuField = shell.bot().textWithMessage(DYNAMIC_FILTER_ON_CPU_FIELD_MESSAGE);
/* Toggle active thread filter button */
activeThreadsCheckbox.click();
assertTrue(activeThreadsCheckbox.isChecked());
/* Filter on selected CPUs */
onCpuRadio.click();
onCpuField.setText("0");
shell.bot().button(DIALOG_OK).click();
/*
* A zoom thread is started after applying the filter. Make sure that the time graph
* is ready before continuing with the test
*/
timeGraphIsReadyCondition(range);
/* Change window range to 50 us */
range = new TmfTimeRange(START_TIME, START_TIME.normalize(50000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, range.getStartTime(), range.getEndTime()));
timeGraphIsReadyCondition(range);
/* Verify that number active entries changed */
SWTBotUtils.waitUntil(entry -> entry.getEntries().length == 1, traceEntry, () -> "Entries size expected:1 actual:" + traceEntry.getEntries().length);
getViewBot().viewMenu(DYNAMIC_FILTER_CONFIGURE_LABEL).click();
shell = fBot.shell(DYNAMIC_FILTERS_SHELL_TEXT).activate();
activeThreadsCheckbox = shell.bot().checkBox(DYNAMIC_FILTERS_SHOW_ACTIVE_THREADS_ONLY_CHECKBOX);
assertTrue(activeThreadsCheckbox.isChecked());
/*
* Test Active Filter buttons toggle
*/
activeThreadsCheckbox.click();
/* All objects should be enabled except for the CPU ranges field */
assertFalse(activeThreadsCheckbox.isChecked());
}
/**
* Test tool bar buttons "Follow CPU Forward" and "Follow CPU Backward"
*/
@Test
public void testToolBarFollowCPUForwardBackward() {
/* change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
fBot.waitUntil(ConditionHelpers.windowRange(range));
/* set selection to trace start time */
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME));
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
SWTBotView viewBot = getViewBot();
/* set focus on time graph */
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
timeGraph.setFocus();
/* select first thread */
timeGraph.getEntry(LttngTraceGenerator.getName(), "gnuplot").select();
/* click "Follow CPU Forward" 3 times */
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME2)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME2));
/* shift-click "Follow CPU Forward" 3 times */
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID5_TIME1)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "5"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID5_TIME1));
/* shift-click "Follow CPU Backward" 4 times */
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME1));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME1)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME1));
/* click "Follow CPU Forward" 2 times */
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME3)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME3));
/* shift-click "Follow CPU Backward" 3 times */
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID1_TIME1));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID1_TIME1)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "1"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID1_TIME1));
/* shift-click "Follow CPU Forward" 4 times */
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
viewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME4));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME4)));
fBot.waitUntil(ConditionHelpers.timeGraphSelectionContains(timeGraph, 1, "2"));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(TID2_TIME4));
/* click "Follow CPU Backward" 5 times */
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
viewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
assertTrue(TmfTraceManager.getInstance().getCurrentTraceContext().getWindowRange().contains(START_TIME));
}
}