1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
12 * Patrick Tasse - Extract base class from ImportAndReadKernelSmokeTest
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.lttng2
.kernel
.ui
.swtbot
.tests
;
17 import static org
.junit
.Assert
.assertNotNull
;
19 import java
.util
.List
;
21 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
22 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
23 import org
.eclipse
.swtbot
.eclipse
.finder
.SWTWorkbenchBot
;
24 import org
.eclipse
.swtbot
.eclipse
.finder
.matchers
.WidgetMatcherFactory
;
25 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
26 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
27 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
28 import org
.eclipse
.swtbot
.swt
.finder
.results
.VoidResult
;
29 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.SWTBotToolbarButton
;
30 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.ui
.views
.controlflow
.ControlFlowView
;
31 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.ui
.views
.resources
.ResourcesView
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
33 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSelectionRangeUpdatedSignal
;
34 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfContext
;
35 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.event
.CtfTmfEvent
;
36 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTrace
;
37 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.trace
.CtfTmfTrace
;
38 import org
.eclipse
.tracecompass
.tmf
.ui
.editors
.TmfEventsEditor
;
39 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
40 import org
.eclipse
.tracecompass
.tmf
.ui
.views
.histogram
.HistogramView
;
41 import org
.eclipse
.ui
.IEditorPart
;
42 import org
.eclipse
.ui
.IEditorReference
;
43 import org
.eclipse
.ui
.IViewPart
;
44 import org
.eclipse
.ui
.IViewReference
;
45 import org
.eclipse
.ui
.PlatformUI
;
46 import org
.hamcrest
.Matcher
;
47 import org
.junit
.Test
;
48 import org
.junit
.runner
.RunWith
;
51 * SWTBot Smoke test for LTTng Kernel UI.
53 * @author Matthew Khouzam
55 @RunWith(SWTBotJunit4ClassRunner
.class)
56 public class ImportAndReadKernelSmokeTest
extends KernelTest
{
58 private static final CtfTmfTestTrace CTT
= CtfTmfTestTrace
.SYNTHETIC_TRACE
;
60 private ITmfEvent fDesired1
;
61 private ITmfEvent fDesired2
;
68 Matcher
<IEditorReference
> matcher
= WidgetMatcherFactory
.withPartName(CTT
.getTrace().getName());
69 IEditorPart iep
= fBot
.editor(matcher
).getReference().getEditor(true);
70 final TmfEventsEditor tmfEd
= (TmfEventsEditor
) iep
;
71 fDesired1
= getEvent(100);
72 fDesired2
= getEvent(10000);
73 UIThreadRunnable
.syncExec(new VoidResult() {
77 tmfEd
.selectionChanged(new SelectionChangedEvent(tmfEd
, new StructuredSelection(fDesired1
)));
80 testHV(getViewPart("Histogram"));
81 testCFV((ControlFlowView
) getViewPart("Control Flow"));
82 testRV((ResourcesView
) getViewPart("Resources"));
85 private static void testCFV(ControlFlowView vp
) {
89 private void testHV(IViewPart vp
) {
90 SWTBotView hvBot
= (new SWTWorkbenchBot()).viewById(HistogramView
.ID
);
91 List
<SWTBotToolbarButton
> hvTools
= hvBot
.getToolbarButtons();
92 for (SWTBotToolbarButton hvTool
: hvTools
) {
93 if (hvTool
.getToolTipText().toLowerCase().contains("lost")) {
97 HistogramView hv
= (HistogramView
) vp
;
98 final TmfSelectionRangeUpdatedSignal signal
= new TmfSelectionRangeUpdatedSignal(hv
, fDesired1
.getTimestamp());
99 final TmfSelectionRangeUpdatedSignal signal2
= new TmfSelectionRangeUpdatedSignal(hv
, fDesired2
.getTimestamp());
100 hv
.updateTimeRange(100000);
101 SWTBotUtils
.waitForJobs();
102 hv
.selectionRangeUpdated(signal
);
103 hv
.broadcast(signal
);
104 SWTBotUtils
.waitForJobs();
105 SWTBotUtils
.delay(1000);
107 hv
.updateTimeRange(1000000000);
108 SWTBotUtils
.waitForJobs();
109 hv
.selectionRangeUpdated(signal2
);
110 hv
.broadcast(signal2
);
111 SWTBotUtils
.waitForJobs();
112 SWTBotUtils
.delay(1000);
116 private static void testRV(ResourcesView vp
) {
120 private static CtfTmfEvent
getEvent(int rank
) {
121 try (CtfTmfTrace trace
= CtfTmfTestTrace
.SYNTHETIC_TRACE
.getTrace()) {
122 ITmfContext ctx
= trace
.seekEvent(0);
123 for (int i
= 0; i
< rank
; i
++) {
126 return trace
.getNext(ctx
);
131 private static IViewPart
getViewPart(final String viewTile
) {
132 final IViewPart
[] vps
= new IViewPart
[1];
133 UIThreadRunnable
.syncExec(new VoidResult() {
136 IViewReference
[] viewRefs
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
137 for (IViewReference viewRef
: viewRefs
) {
138 IViewPart vp
= viewRef
.getView(true);
139 if (vp
.getTitle().equals(viewTile
)) {