Search in sources :

Example 11 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class LamiChartViewerTest method testSimilarRows.

/**
 * Test a few charts with the multiple similar row dataset.
 *
 * @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 IllegalArgumentException
 *             the object is not the correct class type
 */
@Test
public void testSimilarRows() throws SecurityException, IllegalArgumentException {
    SWTBotView viewBot = executeAnalysis(LamiAnalyses.MULTIPLE_SIMILAR_ROW);
    // Create a new chart
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu("New custom chart");
    menu.click();
    // Create a bar chart of Wakee process (name) vs scheduling latency,
    // Priority and Target CPU
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.BAR_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakee process (name)", ImmutableSet.of("Scheduling latency (ns)", "Priority", "Target CPU"));
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    @Nullable Chart customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    assertNotNull(customChart);
    Event mouseMove = new Event();
    mouseMove.type = SWT.MouseEnter;
    customChart.getDisplay().post(mouseMove);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 3));
    SWTBotChart chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Wakee process (name)", "Value");
    // Make sure the axis formatter have the right categories and range
    String[] xValues = new String[6];
    Arrays.fill(xValues, "swapper/5");
    SWTBotCustomChartUtils.assertCategoriesAxis(customChart, AxisType.X, xValues);
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, 0, 2);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, false);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency (ns)", "Priority", "Target CPU"));
    closeCharts();
    // Create a bar chart of Waker process (name) vs scheduling latency,
    // Priority and Target CPU
    menu.click();
    fBot.shell("Custom chart creation").activate();
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.BAR_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Waker process (name)", ImmutableSet.of("Scheduling latency (ns)", "Priority", "Target CPU"));
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    assertNotNull(customChart);
    customChart.getDisplay().post(mouseMove);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 3));
    chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Waker process (name)", "Value");
    // Make sure the axis formatter have the right categories and range
    Arrays.fill(xValues, "?");
    SWTBotCustomChartUtils.assertCategoriesAxis(customChart, AxisType.X, xValues);
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, 0, 2);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, false);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency (ns)", "Priority", "Target CPU"));
    closeCharts();
}
Also used : SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Event(org.eclipse.swt.widgets.Event) Nullable(org.eclipse.jdt.annotation.Nullable) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Example 12 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class LamiChartViewerTest method testScatterMultipleRow.

/**
 * Test a few scatter charts with the multiple row dataset.
 *
 * @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 IllegalArgumentException
 *             the object is not the correct class type
 */
@Test
public void testScatterMultipleRow() throws SecurityException, IllegalArgumentException {
    SWTBotView viewBot = executeAnalysis(LamiAnalyses.MULTIPLE_ROW);
    // Get the expected maximum and minimum values of each axis
    LamiResultTable resultTable = LamiAnalyses.MULTIPLE_ROW.getAnalysis().getResultTable(0);
    Long minX = Long.MAX_VALUE;
    Long maxX = Long.MIN_VALUE;
    Long minY = Long.MAX_VALUE;
    Long maxY = Long.MIN_VALUE;
    for (LamiTableEntry entry : resultTable.getEntries()) {
        Long wakeupTs = ((LamiLongNumber) entry.getValue(0)).getValue();
        Long switchTs = ((LamiLongNumber) entry.getValue(1)).getValue();
        Long latency = ((LamiLongNumber) entry.getValue(2)).getValue();
        if (wakeupTs != null) {
            minX = Math.min(minX, wakeupTs);
            maxX = Math.max(maxX, wakeupTs);
        }
        if (switchTs != null) {
            minX = Math.min(minX, switchTs);
            maxX = Math.max(maxX, switchTs);
        }
        if (latency != null) {
            minY = Math.min(minY, latency);
            maxY = Math.max(maxY, latency);
        }
    }
    // Create a new chart
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu("New custom chart");
    menu.click();
    // Create a scatter chart of Wakeup timestamp vs scheduling latency
    // and Switch timestamp vs scheduling latency
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    @Nullable Chart customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    Event mouseMove = new Event();
    mouseMove.type = SWT.MouseEnter;
    customChart.getDisplay().post(mouseMove);
    assertNotNull(customChart);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    SWTBotChart chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatters have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, minY, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, false);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
    // Create the same chart, but with log scale enabled in Y. Make sure
    // the results are the same
    menu.click();
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.setLogScale(fBot, AxisType.Y);
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    assertNotNull(customChart);
    customChart.getDisplay().post(mouseMove);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatter have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    // Logscale charts are clamped to 0
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, 0, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, true);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
}
Also used : LamiResultTable(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Event(org.eclipse.swt.widgets.Event) LamiLongNumber(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiLongNumber) Nullable(org.eclipse.jdt.annotation.Nullable) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Aggregations

SWTBotRootMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu)12 Test (org.junit.Test)6 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)5 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)5 Event (org.eclipse.swt.widgets.Event)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 Chart (org.eclipse.swtchart.Chart)2 Main (aero.minova.rcp.form.menu.mdi.Main)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 ECommandService (org.eclipse.e4.core.commands.ECommandService)1 EHandlerService (org.eclipse.e4.core.commands.EHandlerService)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Menu (org.eclipse.swt.widgets.Menu)1 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)1