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
.ConditionHelpers
;
27 import org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
.SWTBotUtils
;
28 import org
.eclipse
.ui
.IViewPart
;
29 import org
.eclipse
.ui
.IViewReference
;
30 import org
.junit
.Test
;
31 import org
.junit
.runner
.RunWith
;
32 import org
.swtchart
.Chart
;
33 import org
.swtchart
.ISeries
;
34 import org
.swtchart
.ISeriesSet
;
35 import org
.swtchart
.Range
;
38 * Tests of the pattern scatter chart view
40 * @author Jean-Christian Kouame
42 @RunWith(SWTBotJunit4ClassRunner
.class)
43 public class PatternScatterChartViewTest
extends PatternLatencyViewTestBase
{
45 private static final String VIEW_ID
= PatternScatterGraphView
.ID
;
46 private static final String VIEW_TITLE
= "Latency vs Time";
47 private Chart fScatterChart
;
49 private void setChart() {
50 SWTBotView viewBot
= fBot
.viewById(VIEW_ID
);
51 final IViewReference viewReference
= viewBot
.getViewReference();
52 IViewPart viewPart
= UIThreadRunnable
.syncExec(new Result
<IViewPart
>() {
54 public IViewPart
run() {
55 return viewReference
.getView(true);
58 assertNotNull(viewPart
);
59 if (!(viewPart
instanceof PatternScatterGraphView
)) {
60 fail("Could not instanciate view");
62 fScatterChart
= viewBot
.bot().widget(WidgetOfType
.widgetOfType(Chart
.class));
63 assertNotNull(fScatterChart
);
67 * Test the pattern latency scatter graph. This method test if the chart has
68 * one series and the series has data
71 public void testWithTrace() {
73 SWTBotUtils
.waitForJobs();
74 final Chart scatterChart
= fScatterChart
;
75 assertNotNull(scatterChart
);
76 fBot
.waitUntil(ConditionHelpers
.numberOfSeries(scatterChart
, 1));
78 SWTBotChart chartBot
= new SWTBotChart(scatterChart
);
79 assertVisible(chartBot
);
80 final Range range
= scatterChart
.getAxisSet().getXAxes()[0].getRange();
81 assertEquals(100000000, range
.upper
- range
.lower
, 0);
82 ISeriesSet seriesSet
= fScatterChart
.getSeriesSet();
83 assertNotNull(seriesSet
);
84 ISeries
[] series
= seriesSet
.getSeries();
85 assertNotNull(series
);
87 // Verify that the chart has 1 series
88 assertEquals(1, series
.length
);
89 // Verify that the series has data
90 assertTrue(series
[0].getXSeries().length
> 0);
93 private static class SWTBotChart
extends AbstractSWTBotControl
<Chart
> {
94 public SWTBotChart(Chart w
) throws WidgetNotFoundException
{
100 protected String
getViewId() {
105 protected String
getViewTitle() {