Search in sources :

Example 1 with CpuUsageView

use of org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView 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);
}
Also used : CtfTestTrace(org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) TmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp) Chart(org.eclipse.swtchart.Chart) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) CtfTmfTestTraceUtils(org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils) ConditionHelpers(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers) SWTBotUtils(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) RGB(org.eclipse.swt.graphics.RGB) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) Widget(org.eclipse.swt.widgets.Widget) IViewPart(org.eclipse.ui.IViewPart) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) WidgetOfType(org.eclipse.swtbot.swt.finder.matchers.WidgetOfType) TmfCpuSelectedSignal(org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfCpuSelectedSignal) WaitUtils(org.eclipse.tracecompass.tmf.ui.tests.shared.WaitUtils) Before(org.junit.Before) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Assert.assertNotNull(org.junit.Assert.assertNotNull) ISeries(org.eclipse.swtchart.ISeries) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TmfSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSignal) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest) ResourcesView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesView) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) Tree(org.eclipse.swt.widgets.Tree) Matcher(org.hamcrest.Matcher) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) NonNull(org.eclipse.jdt.annotation.NonNull) LineStyle(org.eclipse.swtchart.LineStyle) Assert.assertEquals(org.junit.Assert.assertEquals) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IViewPart(org.eclipse.ui.IViewPart) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 2 with CpuUsageView

use of org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView in project tracecompass by tracecompass.

the class ResourcesAndCpuViewTest method testResetTimeRange.

/**
 * Test that the reset time range button resets the time range for both the CPU
 * view and the Resources view.
 */
@Test
public void testResetTimeRange() {
    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(activeTrace);
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof CpuUsageView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    IWorkbenchPart part = fResourcesViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    // click the reset time range button in the CPU view
    getSWTBotView().toolbarButton(RESET).click();
    assertChartRange(chartViewer, FULL_RANGE);
    fResourcesViewBot.setFocus();
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
    // go back to the original range
    broadcast(new TmfWindowRangeUpdatedSignal(this, activeTrace.getInitialTimeRange(), activeTrace));
    // click the reset time range button in the Resources View
    fResourcesViewBot.toolbarButton(RESET).click();
    assertChartRange(chartViewer, FULL_RANGE);
    fResourcesViewBot.setFocus();
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) IViewPart(org.eclipse.ui.IViewPart) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) CpuUsageView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Aggregations

CpuUsageView (org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.cpuusage.CpuUsageView)2 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 XYDataProviderBaseTest (org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)2 TmfCommonXAxisChartViewer (org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer)2 AbstractTimeGraphView (org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView)2 IViewPart (org.eclipse.ui.IViewPart)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2 Test (org.junit.Test)2 NonNull (org.eclipse.jdt.annotation.NonNull)1 RGB (org.eclipse.swt.graphics.RGB)1 Tree (org.eclipse.swt.widgets.Tree)1 Widget (org.eclipse.swt.widgets.Widget)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 UIThreadRunnable (org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable)1 WidgetOfType (org.eclipse.swtbot.swt.finder.matchers.WidgetOfType)1 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 Chart (org.eclipse.swtchart.Chart)1 ISeries (org.eclipse.swtchart.ISeries)1