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
|
/*******************************************************************************
* Copyright (c) 2016, 2019 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
*******************************************************************************/
package org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests.latency;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.SystemCallLatencyScatterView;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.XYDataProviderBaseTest;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.linecharts.TmfCommonXAxisChartViewer;
import org.eclipse.ui.IViewPart;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.swtchart.Chart;
import org.swtchart.ISeries;
import org.swtchart.LineStyle;
/**
* Tests of the scatter chart view
*
* @author Matthew Khouzam
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public class SystemCallLatencyScatterChartViewTest extends XYDataProviderBaseTest {
private static final @NonNull String TITLE = "Duration vs Time";
private static final @NonNull String SERIES1_NAME = "bug446190/clock_gettime";
private static final @NonNull String SERIES2_NAME = "bug446190/ioctl";
private static final String VIEW_ID = SystemCallLatencyScatterView.ID;
/**
* Test to check the System Call Scatter view. When trace opens, there are a few
* syscalls present, then we move to the zone without system calls, the tree
* should be empty.
*
* TODO: Test the data
*/
@Test
public void testWithTrace() {
// Wait for analysis to finish.
WaitUtils.waitForJobs();
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof SystemCallLatencyScatterView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotUtils.waitUntil(bot -> bot.tree().visibleRowCount() >= 25, getSWTBotView().bot(), "Missing rows, expected 25, was " + getSWTBotView().bot().tree().visibleRowCount());
SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 24, chart, "No data available");
/* Test type, style and color of series */
verifyChartStyle();
// Update the time range to a range where there is no data
long noDataStart = 1412670961274443542L;
long noDataEnd = 1412670961298823940L;
TmfTimeRange windowRange = new TmfTimeRange(TmfTimestamp.fromNanos(noDataStart), TmfTimestamp.fromNanos(noDataEnd));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, windowRange));
fBot.waitUntil(ConditionHelpers.windowRange(windowRange));
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
// Only the root item should be present
items = getSWTBotView().bot().tree().getAllItems();
assertEquals(1, items.length);
}
private void verifyChartStyle() {
verifySeriesStyle(SERIES1_NAME, ISeries.SeriesType.LINE, null, LineStyle.NONE, false);
verifySeriesStyle(SERIES2_NAME, ISeries.SeriesType.LINE, null, LineStyle.NONE, false);
}
@Override
protected @NonNull String getMainSeriesName() {
return SERIES2_NAME;
}
@Override
protected @NonNull String getTitle() {
return TITLE;
}
@Override
protected String getViewID() {
return VIEW_ID;
}
@Override
protected ITmfTrace getTestTrace() {
return CtfTmfTestTraceUtils.getTrace(CtfTestTrace.ARM_64_BIT_HEADER);
}
@Override
protected void disposeTestTrace() {
CtfTmfTestTraceUtils.dispose(CtfTestTrace.ARM_64_BIT_HEADER);
}
}
|