Search in sources :

Example 1 with SWTBotEclipseSwtChart

use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart in project tracecompass by tracecompass.

the class XYChartViewTest method testZoomToSelection.

/**
 * Test zoom to selection
 */
@Test
public void testZoomToSelection() {
    SWTBotEclipseSwtChart xyChart = new SWTBotEclipseSwtChart(fViewBot.bot());
    xyChart.setFocus();
    assertEquals(80, fXyViewer.getWindowDuration());
    /* set selection to trace start time */
    ITmfTimestamp selStartTime = TmfTimestamp.fromNanos(30L);
    ITmfTimestamp selEndTime = TmfTimestamp.fromNanos(80L);
    TmfTimeRange range = new TmfTimeRange(selStartTime, selEndTime);
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, selStartTime, selEndTime));
    // Wait till selection is finished
    fViewBot.bot().waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return (fXyViewer.getSelectionEndTime() - fXyViewer.getSelectionBeginTime()) == getDuration(range);
        }

        @Override
        public String getFailureMessage() {
            return "SWT Chart is null";
        }
    });
    fireKeyInGraph(xyChart, 'z');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, getDuration(range)));
}
Also used : SWTBotEclipseSwtChart(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) Test(org.junit.Test)

Example 2 with SWTBotEclipseSwtChart

use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart in project tracecompass by tracecompass.

the class XYChartViewTest method testHorizontalZoom.

/**
 * Test horizontal zoom, we can see a rounding error
 */
@Test
public void testHorizontalZoom() {
    fViewBot.setFocus();
    assertEquals(80, fXyViewer.getWindowDuration());
    SWTBotEclipseSwtChart xyChart = new SWTBotEclipseSwtChart(fViewBot.bot());
    fireKeyInGraph(xyChart, '=');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 52));
    fireKeyInGraph(xyChart, '+');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 34));
    fireKeyInGraph(xyChart, '-');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 51));
    fireKeyInGraph(xyChart, '-');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 77));
    resetTimeRange();
    /* Zoom using zoom-in and zoom-out buttons */
    SWTBotToolbarButton button = fViewBot.toolbarButton("Zoom In");
    button.click();
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 52));
    button = fViewBot.toolbarButton("Zoom Out");
    button.click();
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, 78));
    /*
         *  Note that 'w' and 's' zooming is based on mouse position. Just check if
         *  window range was increased or decreased to avoid inaccuracy due to
         *  the mouse position in test environment.
         */
    long previousRange = fXyViewer.getWindowDuration();
    fireKeyInGraph(xyChart, 'w');
    fViewBot.bot().waitUntil(new SeriesUpdatedCondition(fXyViewer, previousRange, false));
    previousRange = fXyViewer.getWindowDuration();
    fireKeyInGraph(xyChart, 's');
    fViewBot.bot().waitUntil(new SeriesUpdatedCondition(fXyViewer, previousRange, true));
}
Also used : SWTBotEclipseSwtChart(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test)

Example 3 with SWTBotEclipseSwtChart

use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart in project tracecompass by tracecompass.

the class XYChartViewTest method testKeyboardNavigation.

/**
 * Test 'a' and 'd' navigation
 */
@Test
public void testKeyboardNavigation() {
    SWTBotEclipseSwtChart xyChart = new SWTBotEclipseSwtChart(fViewBot.bot());
    xyChart.setFocus();
    assertEquals(80, fXyViewer.getWindowDuration());
    TmfTimeRange updatedWindowRange = new TmfTimeRange(TmfTimestamp.fromNanos(40), TmfTimestamp.fromNanos(120));
    // move to the right
    fireKeyInGraph(xyChart, 'd');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, getDuration(updatedWindowRange)));
    // move to the left
    fireKeyInGraph(xyChart, 'a');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, getDuration(INITIAL_WINDOW_RANGE)));
}
Also used : SWTBotEclipseSwtChart(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Aggregations

SWTBotEclipseSwtChart (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart)3 Test (org.junit.Test)3 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)2 DefaultCondition (org.eclipse.swtbot.swt.finder.waits.DefaultCondition)1 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)1 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)1 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)1 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)1