1 /*******************************************************************************
2 * Copyright (c) 2016 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
8 *******************************************************************************/
10 package org
.eclipse
.tracecompass
.tmf
.analysis
.xml
.ui
.swtbot
.tests
.latency
;
12 import static org
.eclipse
.swtbot
.swt
.finder
.SWTBotAssert
.assertVisible
;
13 import static org
.junit
.Assert
.assertEquals
;
14 import static org
.junit
.Assert
.assertNotNull
;
15 import static org
.junit
.Assert
.assertTrue
;
16 import static org
.junit
.Assert
.fail
;
18 import org
.eclipse
.swtbot
.eclipse
.finder
.widgets
.SWTBotView
;
19 import org
.eclipse
.swtbot
.swt
.finder
.exceptions
.WidgetNotFoundException
;
20 import org
.eclipse
.swtbot
.swt
.finder
.finders
.UIThreadRunnable
;
21 import org
.eclipse
.swtbot
.swt
.finder
.junit
.SWTBotJunit4ClassRunner
;
22 import org
.eclipse
.swtbot
.swt
.finder
.matchers
.WidgetOfType
;
23 import org
.eclipse
.swtbot
.swt
.finder
.results
.Result
;
24 import org
.eclipse
.swtbot
.swt
.finder
.widgets
.AbstractSWTBotControl
;
25 import org
.eclipse
.tracecompass
.internal
.tmf
.analysis
.xml
.ui
.views
.latency
.PatternScatterGraphView
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
27 import org
.eclipse
.ui
.IViewPart
;
28 import org
.eclipse
.ui
.IViewReference
;
29 import org
.junit
.Test
;
30 import org
.junit
.runner
.RunWith
;
31 import org
.swtchart
.Chart
;
32 import org
.swtchart
.ISeries
;
33 import org
.swtchart
.ISeriesSet
;
34 import org
.swtchart
.Range
;
37 * Tests of the pattern scatter chart view
39 * @author Jean-Christian Kouame
41 @RunWith(SWTBotJunit4ClassRunner
.class)
42 public class PatternScatterChartViewTest
extends PatternLatencyViewTestBase
{
44 private static final String VIEW_ID
= PatternScatterGraphView
.ID
;
45 private static final String VIEW_TITLE
= "Latency vs Time";
46 private Chart fScatterChart
;
48 private void setChart() {
49 SWTBotView viewBot
= fBot
.viewById(VIEW_ID
);
50 final IViewReference viewReference
= viewBot
.getViewReference();
51 IViewPart viewPart
= UIThreadRunnable
.syncExec(new Result
<IViewPart
>() {
53 public IViewPart
run() {
54 return viewReference
.getView(true);
57 assertNotNull(viewPart
);
58 if (!(viewPart
instanceof PatternScatterGraphView
)) {
59 fail("Could not instanciate view");
61 fScatterChart
= viewBot
.bot().widget(WidgetOfType
.widgetOfType(Chart
.class));
62 assertNotNull(fScatterChart
);
66 * Test the pattern latency scatter graph. This method test if the chart has
67 * one series and the series has data
70 public void testWithTrace() {
72 SWTBotUtils
.waitForJobs();
73 final Chart scatterChart
= fScatterChart
;
74 assertNotNull(scatterChart
);
76 SWTBotChart chartBot
= new SWTBotChart(scatterChart
);
77 assertVisible(chartBot
);
78 final Range range
= scatterChart
.getAxisSet().getXAxes()[0].getRange();
79 assertEquals(100000000, range
.upper
- range
.lower
, 0);
80 ISeriesSet seriesSet
= fScatterChart
.getSeriesSet();
81 assertNotNull(seriesSet
);
82 ISeries
[] series
= seriesSet
.getSeries();
83 assertNotNull(series
);
85 // Verify that the chart has 1 series
86 assertEquals(1, series
.length
);
87 // Verify that the series has data
88 assertTrue(series
[0].getXSeries().length
> 0);
91 private static class SWTBotChart
extends AbstractSWTBotControl
<Chart
> {
92 public SWTBotChart(Chart w
) throws WidgetNotFoundException
{
98 protected String
getViewId() {
103 protected String
getViewTitle() {