From 44af9da927a1e6c2c5737ee39f0b6b929549d0be Mon Sep 17 00:00:00 2001 From: Genevieve Bastien Date: Sat, 15 Oct 2016 10:45:05 -0400 Subject: [PATCH] tmf.ui/timing: Update XY viewers even if there is no data The range of the window still changed and the view should follow that range, even though there is no data to display Change-Id: Iaa6d180de39f6ee5b109ce5826999c096f170469 Signed-off-by: Genevieve Bastien Reviewed-on: https://git.eclipse.org/r/83355 Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam Reviewed-by: Hudson CI --- ...SystemCallLatencyScatterChartViewTest.java | 19 ++++++++++++++++++- .../META-INF/MANIFEST.MF | 3 ++- .../latency/SystemCallLatencyScatterView.java | 8 ++++++++ ...bstractSegmentStoreScatterGraphViewer.java | 4 ++-- .../linecharts/TmfCommonXLineChartViewer.java | 3 --- 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java index b09a719b57..d2940d3549 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests/src/org/eclipse/tracecompass/analysis/os/linux/ui/swtbot/tests/latency/SystemCallLatencyScatterChartViewTest.java @@ -35,6 +35,10 @@ import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl; 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.ui.swtbot.tests.shared.ConditionHelpers; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils; import org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils; @@ -66,6 +70,7 @@ public class SystemCallLatencyScatterChartViewTest { /** The Log4j logger instance. */ private static final Logger fLogger = Logger.getRootLogger(); private Chart fScatterChart; + private SystemCallLatencyScatterView fSystemCallLatencyScatterView = null; /** * Things to setup @@ -121,6 +126,7 @@ public class SystemCallLatencyScatterChartViewTest { if (!(viewPart instanceof SystemCallLatencyScatterView)) { fail("Could not instanciate view"); } + fSystemCallLatencyScatterView = (SystemCallLatencyScatterView) viewPart; fScatterChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class)); assertNotNull(fScatterChart); } @@ -173,13 +179,24 @@ public class SystemCallLatencyScatterChartViewTest { SWTBotChart chartBot = new SWTBotChart(scatterChart); assertVisible(chartBot); assertEquals("", chartBot.getToolTipText()); - final Range range = scatterChart.getAxisSet().getXAxes()[0].getRange(); + Range range = scatterChart.getAxisSet().getXAxes()[0].getRange(); assertEquals(100000000, range.upper - range.lower, 0); ISeriesSet seriesSet = fScatterChart.getSeriesSet(); assertNotNull(seriesSet); ISeries[] series = seriesSet.getSeries(); assertNotNull(series); + // 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)); + + bot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(fSystemCallLatencyScatterView.getChartViewer())); + + range = scatterChart.getAxisSet().getXAxes()[0].getRange(); + assertEquals(noDataEnd - noDataStart, range.upper - range.lower, 0); + // Verify that the chart has 1 series assertEquals(1, series.length); // Verify that each series is a ILineSeries diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/META-INF/MANIFEST.MF b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/META-INF/MANIFEST.MF index 9b6b94a8a8..e3ab086fc8 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/META-INF/MANIFEST.MF +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.tracecompass.segmentstore.core, org.eclipse.tracecompass.analysis.timing.core, org.eclipse.tracecompass.analysis.timing.ui -Import-Package: com.google.common.base, +Import-Package: com.google.common.annotations, + com.google.common.base, com.google.common.collect, org.swtchart Export-Package: org.eclipse.tracecompass.internal.analysis.os.linux.ui;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests", diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterView.java index 6267ce4973..5f879305cf 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyScatterView.java @@ -18,6 +18,8 @@ import org.eclipse.tracecompass.common.core.NonNullUtils; import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer; import org.eclipse.tracecompass.tmf.ui.views.TmfChartView; +import com.google.common.annotations.VisibleForTesting; + /** * Some stuff * @@ -54,4 +56,10 @@ public class SystemCallLatencyScatterView extends TmfChartView { return fScatterViewer; } + @VisibleForTesting + @Override + public TmfXYChartViewer getChartViewer() { + return super.getChartViewer(); + } + } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java index 006b589505..8322bed9ce 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/scatter/AbstractSegmentStoreScatterGraphViewer.java @@ -310,7 +310,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL Collection data = fDisplayData; final int dataSize = (nb == 0) ? data.size() : nb; - if (dataSize == 0 || end == start) { + if (end == start) { return; } @@ -325,7 +325,7 @@ public abstract class AbstractSegmentStoreScatterGraphViewer extends TmfCommonXL ySeries.add((double) segment.getLength()); } setXAxis(Doubles.toArray(xSeries)); - setSeries(Messages.SegmentStoreScatterGraphViewer_legend, Doubles.toArray(ySeries)); // $NON-NLS-1$ + setSeries(Messages.SegmentStoreScatterGraphViewer_legend, Doubles.toArray(ySeries)); updateDisplay(); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java index 3030b00e4d..a53bdf98a8 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java @@ -382,9 +382,6 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer { public void run() { if (!getSwtChart().isDisposed()) { double[] xValues = fXValues; - if (xValues.length < 1) { - return; - } double maxy = DEFAULT_MAXY; double miny = DEFAULT_MINY; for (Entry entry : fSeriesValues.entrySet()) { -- 2.34.1