Search in sources :

Example 1 with TimeGraphMarkerAxis

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis in project tracecompass by tracecompass.

the class ResourcesViewTest method testMarkerAxis.

/**
 * Test the marker axis
 */
@Test
public void testMarkerAxis() {
    SWTBotView viewBot = getViewBot();
    /* center window range of first lost event range */
    ITmfTimestamp startTime = LOST_EVENT_TIME1.normalize(-10000000L, ITmfTimestamp.NANOSECOND_SCALE);
    ITmfTimestamp endTime = LOST_EVENT_END1.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE);
    TmfTimeRange range = new TmfTimeRange(startTime, endTime);
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    fBot.waitUntil(ConditionHelpers.windowRange(range));
    /* set selection to window start time */
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, startTime));
    timeGraphIsReadyCondition(new TmfTimeRange(startTime, startTime), startTime);
    /* get marker axis size with one category */
    final TimeGraphMarkerAxis markerAxis = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphMarkerAxis.class));
    final Point size1 = getSize(markerAxis);
    /* add bookmark at window start time */
    viewBot.toolbarButton(ADD_BOOKMARK).click();
    SWTBot dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot();
    dialogBot.text().setText("B");
    dialogBot.button(OK).click();
    /* get marker axis size with two categories */
    final Point size2 = getSize(markerAxis);
    final int rowHeight = size2.y - size1.y;
    /*
         * get the state area bounds, since we don't know the name space width
         */
    final TimeGraphControl timeGraph = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class));
    int x0 = getXForTime(timeGraph, startTime.toNanos());
    int x1 = getXForTime(timeGraph, endTime.toNanos());
    /*
         * click at the center of the marker axis width and first row height, it
         * should be within the lost event range
         */
    final SWTBotCanvas markerAxisCanvas = new SWTBotCanvas(markerAxis);
    markerAxisCanvas.click((x0 + x1) / 2, TOP_MARGIN + rowHeight / 2);
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1)));
    /*
         * click near the left of the marker axis width and center of second row
         * height, it should be on the bookmark label
         */
    markerAxisCanvas.click(x0 + 2, TOP_MARGIN + rowHeight + rowHeight / 2);
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(startTime, startTime)));
    /* click "Remove Bookmark" */
    viewBot.toolbarButton(REMOVE_BOOKMARK).click();
    assertEquals(size1, getSize(markerAxis));
    /* click the 'expanded' icon to collapse */
    markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2);
    assertEquals(TOGGLE_SIZE.y, getSize(markerAxis).y);
    /* click the 'collapsed' icon to expand */
    markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2);
    assertEquals(size1, getSize(markerAxis));
    /* click on the 'X' icon to hide the 'Lost Events' marker category */
    markerAxisCanvas.click(TOGGLE_SIZE.x + HIDE_SIZE.x / 2, TOP_MARGIN + HIDE_SIZE.y / 2);
    assertEquals(0, getSize(markerAxis).y);
    /* show Lost Events markers */
    viewBot.viewMenu(LOST_EVENTS).click();
    SWTBotUtils.waitUntil(ma -> size1.equals(getSize(ma)), markerAxis, "Lost Events did not reappear");
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TimeGraphMarkerAxis(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis) Point(org.eclipse.swt.graphics.Point) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Aggregations

Point (org.eclipse.swt.graphics.Point)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)1 SWTBotCanvas (org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas)1 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)1 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)1 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)1 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)1 TimeGraphControl (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl)1 TimeGraphMarkerAxis (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis)1 Test (org.junit.Test)1