Search in sources :

Example 1 with SWTBotCanvas

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

the class FindDialogTestBase method openDialog.

private static void openDialog(SWTBotView view) {
    SWTBotCanvas canvas = view.bot().canvas(1);
    view.setFocus();
    canvas.pressShortcut(Keystrokes.HOME);
    if (SWTUtils.isMac()) {
        canvas.pressShortcut(Keystrokes.COMMAND, KeyStroke.getInstance('F'));
    } else {
        canvas.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance('F'));
    }
    fBot.shell(DIALOG_TITLE).activate();
}
Also used : SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas)

Example 2 with SWTBotCanvas

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas 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)

Example 3 with SWTBotCanvas

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

the class FilterColorEditorTest method testHeaderBar.

/**
 * Test the header bar
 */
@Test
public void testHeaderBar() {
    // Add search filter on Timestamp column
    fTableBot.click(0, TIMESTAMP_COLUMN);
    fBot.text().typeText("2");
    fBot.text().pressShortcut(Keystrokes.CR);
    // Add search filter on Message column and Add as Filter
    fTableBot.click(0, MESSAGE_COLUMN);
    fBot.text().typeText("F");
    fBot.text().pressShortcut(Keystrokes.CTRL, Keystrokes.CR);
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "2/22", 1, 1));
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "Message F", 3, MESSAGE_COLUMN));
    fBot.clabel("Timestamp matches \"2\"");
    fBot.clabel("Message matches \"F\"");
    waitForHighlightState(3, TIMESTAMP_COLUMN, true);
    waitForHighlightState(3, MESSAGE_COLUMN, true);
    // Clear all filter highlighting
    fTableBot.pressShortcut(Keystrokes.DELETE);
    waitForHighlightState(3, TIMESTAMP_COLUMN, false);
    waitForHighlightState(3, MESSAGE_COLUMN, false);
    // Click filter label to set the filter highlighting on Message filter
    SWTBotCLabel filterCLabel = fBot.clabel("Message matches \"F\"");
    SWTBotCanvas filterCanvas = new SWTBotCanvas(filterCLabel.widget);
    filterCanvas.click();
    waitForHighlightState(3, TIMESTAMP_COLUMN, false);
    waitForHighlightState(3, MESSAGE_COLUMN, true);
    // Click filter icon to remove the Message filter
    Rectangle imageBounds = filterCLabel.image().getBounds();
    filterCanvas.click(filterCLabel.widget.getLeftMargin() + imageBounds.width / 2, filterCLabel.widget.getTopMargin() + imageBounds.height / 2);
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "5/22", 1, 1));
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) SWTBotCLabel(org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel) Test(org.junit.Test)

Example 4 with SWTBotCanvas

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

the class SDViewTest method testSDView.

/**
 * Test Sequence diagram view, counting the columns
 */
@Test
public void testSDView() {
    SWTBotView viewBot = fBot.viewById(UML2DVIEW_ID);
    SWTBotCanvas timeCompressionBar = viewBot.bot().canvas(0);
    SWTBotCanvas sdWidget = viewBot.bot().canvas(1);
    assertNotNull(viewBot);
    viewBot.setFocus();
    WaitUtils.waitForJobs();
    List<SWTBotToolbarButton> viewButtons = viewBot.getToolbarButtons();
    List<String> titles = new ArrayList<>();
    for (SWTBotToolbarButton buttonBot : viewButtons) {
        titles.add(buttonBot.getToolTipText());
    }
    final char commandKeyChar = (char) 0x2318;
    final String findShortcut = (Platform.getOS().equals(Platform.OS_MACOSX) ? commandKeyChar : "Ctrl+") + "F";
    String[] expected = { "Reset zoom factor", "Select", "Zoom in the diagram", "Zoom out the diagram", "Go to next page", "Go to previous page", "Go to first page", "Go to last page", "Find... (" + findShortcut + ")" };
    assertArrayEquals("Buttons", expected, titles.toArray(new String[0]));
    SDView view = (SDView) viewBot.getViewReference().getPart(false);
    ISDAdvancedPagingProvider pagingProvider = (ISDAdvancedPagingProvider) view.getSDPagingProvider();
    Frame frame = view.getFrame();
    assertEquals(2, frame.lifeLinesCount());
    timeCompressionBar.click();
    // Zoom in page using toolbar buttons
    viewBot.toolbarButton("Select").click();
    sdWidget.click(0, 0);
    viewBot.toolbarButton("Zoom in the diagram").click();
    sdWidget.click();
    sdWidget.click();
    viewBot.toolbarButton("Zoom out the diagram").click();
    sdWidget.click();
    viewBot.toolbarButton("Reset zoom factor").click();
    sdWidget.click();
    // Zoom in page using view menu
    viewBot.viewMenu("Select").click();
    sdWidget.click(0, 0);
    viewBot.viewMenu("Zoom in").click();
    sdWidget.click();
    sdWidget.click();
    viewBot.viewMenu("Zoom out").click();
    sdWidget.click();
    viewBot.viewMenu("Reset zoom factor").click();
    sdWidget.click();
    assertEquals(0, pagingProvider.currentPage());
    viewBot.toolbarButton("Find... (" + findShortcut + ")").click();
    SWTBot findDialogBot = fBot.shell("Sequence Diagram Find").bot();
    findDialogBot.comboBox().setText("peer2");
    findDialogBot.checkBox("Lifeline").select();
    findDialogBot.checkBox("Interaction").deselect();
    findDialogBot.button("Find").click();
    findDialogBot.button("Close").click();
    SWTBotUtils.waitUntil(f -> f.getLifeline(1).isSelected(), frame, "Did not find lifeline");
    assertEquals(0, pagingProvider.currentPage());
    // Shell focus required to enable tool item shortcut
    viewBot.setFocus();
    viewBot.toolbarButton("Find... (" + findShortcut + ")").click();
    findDialogBot = fBot.shell("Sequence Diagram Find").bot();
    findDialogBot.comboBox().setText("1001");
    findDialogBot.checkBox("Lifeline").deselect();
    findDialogBot.checkBox("Interaction").select();
    findDialogBot.button("Find").click();
    findDialogBot.button("Close").click();
    SWTBotUtils.waitUntil(f -> f.getSyncMessage(1).isSelected(), frame, "Did not find interaction");
    viewBot.viewMenu("Hide Patterns...").click();
    SWTBot hideDialogBot = fBot.shell("Sequence Diagram Hide Patterns").bot();
    hideDialogBot.button("Add...").click();
    SWTBot definitionBot = fBot.shell("Definition of Hide Pattern").bot();
    definitionBot.comboBox().setText("peer2");
    definitionBot.checkBox("Lifeline").select();
    definitionBot.checkBox("Interaction").deselect();
    definitionBot.button("Create").click();
    hideDialogBot.button("OK").click();
    SWTBotUtils.waitUntil(v -> v.getFrame().lifeLinesCount() == 1, view, "Did not hide lifeline");
    viewBot.viewMenu("Hide Patterns...").click();
    hideDialogBot = fBot.shell("Sequence Diagram Hide Patterns").bot();
    hideDialogBot.table().select("hide peer2 [Lifeline]");
    hideDialogBot.button("Remove").click();
    hideDialogBot.button("OK").click();
    SWTBotUtils.waitUntil(v -> v.getFrame().lifeLinesCount() == 2, view, "Did not show lifeline");
    viewBot.viewMenu("Configure Min Max...").click();
    SWTBot configurationBot = fBot.shell("TimeCompression bar configuration").bot();
    configurationBot.textWithLabel("Max time").setText("200");
    configurationBot.button("OK").click();
    viewBot.viewMenu("Configure Min Max...").click();
    configurationBot = fBot.shell("TimeCompression bar configuration").bot();
    configurationBot.button("Default").click();
    configurationBot.button("OK").click();
    // Navigate pages using toolbar buttons
    assertEquals(0, pagingProvider.currentPage());
    viewBot.toolbarButton("Go to next page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to previous page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to last page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.toolbarButton("Go to first page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    // Navigate pages using view menu
    assertEquals(0, pagingProvider.currentPage());
    viewBot.viewMenu("Next page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.viewMenu("Previous page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.viewMenu("Last page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
    viewBot.viewMenu("First page").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 0, pagingProvider, "Did not change page");
    viewBot.viewMenu("Pages...").click();
    SWTBot pagesBot = fBot.shell("Sequence Diagram Pages").bot();
    pagesBot.text().setText("2");
    pagesBot.button("OK").click();
    SWTBotUtils.waitUntil(pp -> pp.currentPage() == 1, pagingProvider, "Did not change page");
}
Also used : Frame(org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) ArrayList(java.util.ArrayList) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) ISDAdvancedPagingProvider(org.eclipse.tracecompass.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) SDView(org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView) Test(org.junit.Test)

Example 5 with SWTBotCanvas

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

the class SDViewTest method testSDPrintUi.

/**
 * Test Sequence diagram print dialog
 */
@Test
public void testSDPrintUi() {
    SWTBotView viewBot = fBot.viewById(UML2DVIEW_ID);
    assertNotNull(viewBot);
    viewBot.setFocus();
    WaitUtils.waitForJobs();
    // Test print dialog
    SWTBotCanvas canvas = viewBot.bot().canvas(1);
    canvas.setFocus();
    canvas.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance('P'));
    SWTBotShell printShell = fBot.shell("Print");
    assertNotNull(printShell);
    SWTBot printBot = printShell.bot();
    printBot.radio("Use current zoom").click();
    SWTBotRadio allPages = printBot.radio("All pages");
    SWTBotRadio currentView = printBot.radio("Current view");
    // 'All pages' and 'Current view' buttons will be enabled
    allPages.click();
    currentView.click();
    // Test 'Number of horizontal pages' button
    printBot.radio("Number of horizontal pages:").click();
    SWTBotText horizontalPagesText = printBot.text(0);
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), horizontalPagesText, "Number of horizontal pages should be 1");
    horizontalPagesText.setText("2");
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), horizontalPagesText, "Number of horizontal pages should be 2");
    assertFalse(currentView.isEnabled());
    // Test 'Number of vertical pages' button
    SWTBotText totalPagesText = printBot.textWithLabel("Total number of pages:");
    printBot.radio("Number of vertical pages:").click();
    SWTBotText verticalPagesText = printBot.text(1);
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), verticalPagesText, "Number of vertical pages should be 1");
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(1)), totalPagesText, "Total number of pages should be 1");
    verticalPagesText.setText("2");
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), verticalPagesText, "Number of vertical pages should be 2");
    assertFalse(currentView.isEnabled());
    // Test 'selected pages' button
    printBot.radio("Selected pages").click();
    assertFalse(currentView.isEnabled());
    // Test 'From pages' buttons
    printBot.radio("From page").click();
    SWTBotText fromText = printBot.text(3);
    SWTBotText toText = printBot.text(4);
    SWTBotUtils.waitUntil(t -> t.getText().isEmpty(), fromText, "From text is not empty");
    SWTBotUtils.waitUntil(t -> t.getText().isEmpty(), toText, "To text is not empty");
    fromText.setText("2");
    toText.setText("3");
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(2)), fromText, "From text is not 2");
    SWTBotUtils.waitUntil(t -> t.getText().equals(String.valueOf(3)), toText, "To text is not 3");
    assertFalse(currentView.isEnabled());
    // Don't actually print
    printBot.button("Cancel").click();
    printBot.waitUntil(Conditions.shellCloses(printShell));
}
Also used : SWTBotRadio(org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Aggregations

SWTBotCanvas (org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas)8 Test (org.junit.Test)6 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)5 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 ArrayList (java.util.ArrayList)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 SWTBotCLabel (org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel)1 SWTBotRadio (org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio)1 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)1 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)1 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)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 SDView (org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView)1 Frame (org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.Frame)1 ISDAdvancedPagingProvider (org.eclipse.tracecompass.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider)1 TimeGraphControl (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl)1