use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class ResourcesAndCpuViewTest method testCpuView.
/**
* Simple test to check the CPU Usage view after getting signals.
*/
@Test
public void testCpuView() {
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof CpuUsageView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
chartViewer.setNbPoints(10);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json), "resources/cpuusage/cpu-usage-res10.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(TOTAL_SERIES_NAME, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);
/* Select a thread */
SWTBotTreeItem rootEntry = getSWTBotView().bot().tree().getTreeItem(TRACE_NAME);
SWTBotUtils.waitUntil(tree -> getTableCount() >= 8, rootEntry, "Did not finish loading");
SWTBotTreeItem selectedTheadNode = rootEntry.getNode(SELECTED_THREAD);
selectedTheadNode.check();
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, SELECTED_THREAD_SERIES), "resources/cpuusage/cpu-usage-res10Selected.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(SELECTED_THREAD_SERIES, ISeries.SeriesType.LINE, RED, LineStyle.SOLID, true);
selectedTheadNode.uncheck();
/* Selected an another thread and test in HD */
String otherSelectedThread = "lttng-consumerd";
SWTBotTreeItem otherSelectedThreadNode = rootEntry.getNode(otherSelectedThread);
otherSelectedThreadNode.check();
chartViewer.setNbPoints(100);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, OTHERTHREAD_SERIES), "resources/cpuusage/cpu-usage-res100Selected.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(OTHERTHREAD_SERIES, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, true);
/*
* Test new TimeRange
*/
chartViewer.setNbPoints(10);
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
assertNotNull(activeTrace);
fResourcesViewBot.getToolbarButtons().stream().filter(button -> button.getToolTipText().contains(RESET)).findAny().get().click();
fBot.waitUntil(ConditionHelpers.windowRange(new TmfTimeRange(TRACE_START, TRACE_END)));
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, OTHERTHREAD_SERIES), "resources/cpuusage/cpu-usage-all-res10.json", "Chart data is not valid");
/* Test chart style */
verifySeriesStyle(OTHERTHREAD_SERIES, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, true);
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class PatternDensityViewTest method testWithTrace.
/**
* Test the pattern density view and its viewers data
*
* @throws SecurityException
* If a security manager is present and any the wrong class is
* loaded or the class loader is not the same as its ancestor's
* loader.
*
* @throws NoSuchFieldException
* Field not available
* @throws IllegalAccessException
* Field is inaccessible
* @throws IllegalArgumentException
* the object is not the correct class type
*/
@Test
public void testWithTrace() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
setDensityViewer();
WaitUtils.waitForJobs();
// Test the table content
SWTBotTable tableBot = new SWTBotTable(fDensityViewer.getTableViewer().getTable());
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
tableBot.header(COLUMN_HEADER).click();
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
tableBot.header(COLUMN_HEADER).click();
fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, SYSTEM_CALL_PREFIX, 0, 3));
// Test the chart content
final Chart densityChart = fDensityChart;
assertNotNull(densityChart);
fBot.waitUntil(ConditionHelpers.numberOfSeries(densityChart, 1));
SWTBotChart chartBot = new SWTBotChart(densityChart);
assertVisible(chartBot);
ISeriesSet seriesSet = fDensityChart.getSeriesSet();
assertNotNull(seriesSet);
ISeries<?>[] series = seriesSet.getSeries();
assertNotNull(series);
// Verify that the chart has 1 series
assertEquals(1, series.length);
// Verify that the series has data
assertTrue(((IndexedSeriesModel<?>) series[0].getDataModel()).size() > 0);
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class PatternScatterChartViewTest method testWithTrace.
/**
* Test the pattern latency scatter graph. This method test if the chart has one
* series and the series has data
*/
@Test
public void testWithTrace() {
// Get the chart viewer and wait for the view to be ready
WaitUtils.waitForJobs();
TmfXYChartViewer chartViewer = getChartViewer();
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
// Check all the items in the tree
final Chart chart = fScatterChart;
assertNotNull(chart);
SWTBotView viewBot = fBot.viewById(VIEW_ID);
SWTBotTreeItem[] items = viewBot.bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
// Look at the presence of data in the chart
SWTBotChart chartBot = new SWTBotChart(chart);
assertVisible(chartBot);
final Range range = chart.getAxisSet().getXAxes()[0].getRange();
assertEquals(100000000, range.upper - range.lower, 0);
ISeriesSet seriesSet = fScatterChart.getSeriesSet();
assertNotNull(seriesSet);
ISeries<?>[] series = seriesSet.getSeries();
assertNotNull(series);
// Verify that the chart has more than 1 series
assertTrue(series.length > 1);
// Verify that each series has data
for (int i = 0; i < series.length; i++) {
assertTrue("Verifying series " + i, ((IndexedSeriesModel<?>) series[i].getDataModel()).size() > 0);
}
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class TmfFilteredXYChartViewer method handleCheckStateChangedEvent.
/**
* Update the chart depending on the selected entries.
*
* @param entries
* Counters to display on the chart
*/
@Override
public void handleCheckStateChangedEvent(Collection<ITmfTreeViewerEntry> entries) {
cancelUpdate();
Iterable<TmfGenericTreeEntry> counterEntries = Iterables.filter(entries, TmfGenericTreeEntry.class);
Collection<@NonNull Long> selectedIds = Sets.newHashSet(Iterables.transform(counterEntries, e -> e.getModel().getId()));
if (!selectedIds.containsAll(fSelectedIds)) {
clearContent();
}
fSelectedIds = selectedIds;
// Update the styles as well
BaseXYPresentationProvider presProvider = getPresentationProvider();
for (ITmfTreeViewerEntry entry : entries) {
if (entry instanceof TmfGenericTreeEntry) {
TmfGenericTreeEntry<TmfTreeDataModel> genericEntry = (TmfGenericTreeEntry<TmfTreeDataModel>) entry;
TmfTreeDataModel model = genericEntry.getModel();
OutputElementStyle style = model.getStyle();
if (style != null) {
presProvider.setStyle(model.getId(), style);
}
}
}
updateContent();
}
use of org.eclipse.swtchart.Chart in project tracecompass by tracecompass.
the class SystemCallLatencyDensityViewTest method testWithTrace.
/**
* Test with an actual trace, this is more of an integration test than a
* unit test. This test is a slow one too. If some analyses are not well
* configured, this test will also generates null pointer exceptions. These
* will be logged.
*
* @throws IOException
* trace not found?
* @throws SecurityException
* If a security manager is present and any the wrong class is
* loaded or the class loader is not the same as its ancestor's
* loader.
*
* @throws NoSuchFieldException
* Field not available
* @throws IllegalAccessException
* Field is inaccessible
* @throws IllegalArgumentException
* the object is not the correct class type
*/
@Test
public void testWithTrace() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
String tracePath = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.ARM_64_BIT_HEADER.getTraceURL())).getAbsolutePath();
SWTWorkbenchBot bot = new SWTWorkbenchBot();
SWTBotUtils.closeViewById(VIEW_ID, fBot);
SWTBotUtils.createProject(PROJECT_NAME);
SWTBotUtils.openTrace(PROJECT_NAME, tracePath, TRACE_TYPE);
WaitUtils.waitForJobs();
createDensityViewer();
WaitUtils.waitForJobs();
SWTBotTable tableBot = new SWTBotTable(fDensityViewer.getTableViewer().getTable());
bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1,600", 0, 2));
tableBot.header("Duration").click();
bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1,600", 0, 2));
tableBot.header("Duration").click();
bot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1,001,046,400", 0, 2));
final Chart densityChart = fDensityChart;
assertNotNull(densityChart);
bot.waitUntil(ConditionHelpers.numberOfSeries(densityChart, 1));
SWTBotChart chartBot = new SWTBotChart(densityChart);
assertVisible(chartBot);
assertEquals("", chartBot.getToolTipText());
final Range range = densityChart.getAxisSet().getXAxes()[0].getRange();
assertTrue(0 > range.lower);
assertTrue(1001046400 < range.upper);
bot.closeAllEditors();
SWTBotUtils.deleteProject(PROJECT_NAME, bot);
}
Aggregations