Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#bot()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#bot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlameChartViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test loading conflicting mapping files.
 *
 * @throws IOException
 *             Missing file
 */
@Test
public void testLoadingMappingFiles() throws IOException {

    // 1- Open conflicting mapping files
    URL mapUrlA = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt");
    URL mapUrlB = CtfTmfTestTraceUtils.class.getResource("dummy-mapping.txt");
    String absoluteFileA = FileLocator.toFileURL(mapUrlA).getFile();
    String absoluteFileB = FileLocator.toFileURL(mapUrlB).getFile();
    String[] overrideFiles = { absoluteFileA, absoluteFileB };
    TmfFileDialogFactory.setOverrideFiles(overrideFiles);

    SWTBotShell shell = openSymbolProviderDialog();
    final SWTBot symbolDialog = shell.bot();
    symbolDialog.button("Add...").click();
    symbolDialog.button("OK").click();

    // 2- Ensure symbols are loaded and prioritized
    sfBot.viewById(FlameChartView.ID).setFocus();
    WaitUtils.waitForJobs();
    goToTime(TIMESTAMP);
    waitForSymbolNames("main", "event_loop", "draw_frame", "draw_gears", "drawB");
}
 
Example 2
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test opening up the preference page from context menu of Traces folder
 */
@Test
public void testPreferencePageContextMenu() {
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    /* Finish waiting for eclipse to load */
    WaitUtils.waitForJobs();

    /* Open preferences page from context menu */
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    tracesFolder.contextMenu().menu(MANAGE_XML_ANALYSES_COMMAND_NAME).click();

    SWTBotShell shell = SWTBotUtils.anyShellOf(fBot, PREFERENCES_SHELL, MANAGE_XML_ANALYSES_PREF_TITLE_FILTERED).activate();
    SWTBot bot = shell.bot();

    /* Close preference page*/
    SWTBotUtils.pressOKishButtonInPreferences(bot);

    SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
}
 
Example 3
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Clean up after a test, reset the views and reset the states of the
 * timegraph by pressing reset on all the resets of the legend
 */
@After
public void after() {

    // reset all
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    SWTBot legendBot = legendShell.bot();

    for (int i = 0; i < StubPresentationProvider.STATES.length; i++) {
        SWTBotButton resetButton = legendBot.button(i);
        if (resetButton.isEnabled()) {
            resetButton.click();
        }
    }
    legendBot.button(OK_BUTTON).click();
    TmfTraceStub trace = fTrace;
    assertNotNull(trace);
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace)));
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    fViewBot.close();
    fBot.waitUntil(ConditionHelpers.viewIsClosed(fViewBot));
    fTrace.dispose();
}
 
Example 4
Source File: FlameChartViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test check callstack at a time with function map
 *
 * @throws IOException
 *             Missing file
 */
@Test
public void testGoToTimeAndCheckStackWithNames() throws IOException {
    goToTime(TIMESTAMPS[0]);
    final SWTBotView viewBot = sfBot.viewById(FlameChartView.ID);
    viewBot.setFocus();

    URL mapUrl = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt");
    String absoluteFile = FileLocator.toFileURL(mapUrl).getFile();
    TmfFileDialogFactory.setOverrideFiles(absoluteFile);

    SWTBotShell shell = openSymbolProviderDialog();
    SWTBot shellBot = shell.bot();
    shellBot.button("Add...").click();
    shellBot.button("OK").click();
    shellBot.waitUntil(Conditions.shellCloses(shell));
    SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
    SWTBotTimeGraphEntry[] threads = timeGraph.getEntry(TRACE, PROCESS).getEntries();
    assertEquals(1, threads.length);
    assertEquals(THREAD, threads[0].getText(0));
    waitForSymbolNames("main", "event_loop", "handle_event");
}
 
Example 5
Source File: ImportBdmWizardBot.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public ImportBdmWizardBot setImportAction(String packageName, String action) {
    SWTBotTree tree = bot.tree();
    SWTBotShell activeShell = bot.activeShell();
    bot.waitUntil(treeItemAvailable(tree, packageName));
    SWTBotTreeItem treeItem = tree.getTreeItem(packageName);
    treeItem.select();
    treeItem.click(1);

    SWTBot activeBot = activeShell.bot();
    SWTBotCCombo ccomboBoxInGroup = activeBot.ccomboBoxWithId(SmartImportBdmPage.IMPORT_ACTION_COMBO_EDITOR_ID);
    activeBot.waitUntil(new ConditionBuilder()
            .withTest(() -> Stream.of(ccomboBoxInGroup.items()).anyMatch(action::equals))
            .withFailureMessage(() -> String.format("Action '%s' not found in combo", action))
            .create());
    ccomboBoxInGroup.setSelection(action);
    return this;
}
 
Example 6
Source File: ControlFlowViewSortingTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void applyFilter() {
    // Select only certain root nodes and their children but filter out rest
    SWTBotToolbarButton filterButton = fViewBot.toolbarButton(FILTER_ACTION);
    filterButton.click();
    SWTBotShell shell = fBot.shell(FILTER_DIALOG_TITLE).activate();

    SWTBot bot = shell.bot();
    SWTBotTree treeBot = bot.tree();
    bot.button(UNCHECK_ALL).click();

    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 0, checked);

    // select root nodes and their children
    checkFilterTreeItems(bot, treeBot, SYSTEMD_PROCESS_NAME);
    checkFilterTreeItems(bot, treeBot, KTHREAD_PROCESS_NAME);
    checkFilterTreeItems(bot, treeBot, LTTNG_CONSUMER_PROCESS_NAME);

    bot.button(OK_BUTTON).click();
}
 
Example 7
Source File: CtfTmfExperimentTrimmingTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test setup
 */
@Before
public void setup() {
    WaitUtils.waitForJobs();
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    tracesFolder.contextMenu().menu("Open As Experiment...", "Generic Experiment").click();
    SWTBotUtils.activateEditor(fBot, "Experiment");
    SWTBotTreeItem project = SWTBotUtils.selectProject(fBot, PROJECT_NAME);
    SWTBotTreeItem experimentItem = SWTBotUtils.getTraceProjectItem(fBot, project, "Experiments", "Experiment");
    experimentItem.select();
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace trace = traceManager.getActiveTrace();
    assertTrue(String.valueOf(trace), trace instanceof TmfExperiment);
    TmfExperiment experiment = (TmfExperiment) trace;
    assertNotNull(experiment);
    ITmfProjectModelElement elem = TmfProjectRegistry.findElement(experiment.getResource(), true);
    assertTrue(elem instanceof TmfExperimentElement);
    fOriginalExperiment = experiment;
    TmfTimeRange traceCutRange = getTraceCutRange(experiment);
    assertNotNull(traceCutRange);
    fRequestedTraceCutRange = traceCutRange;

    ITmfTimestamp requestedTraceCutEnd = traceCutRange.getEndTime();
    ITmfTimestamp requestedTraceCutStart = traceCutRange.getStartTime();
    assertTrue(experiment.getTimeRange().contains(traceCutRange));
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, requestedTraceCutStart, requestedTraceCutEnd, experiment));
    experimentItem.contextMenu("Export Time Selection as New Trace...").click();
    SWTBotShell shell = fBot.shell("Export trace section to...").activate();
    SWTBot dialogBot = shell.bot();
    assertEquals("Experiment", dialogBot.text().getText());
    dialogBot.text().setText("Experiment-trimmed");
    dialogBot.button("OK").click();
    SWTBotEditor newExperiment = fBot.editorByTitle("Experiment-trimmed");
    newExperiment.setFocus();
    fNewExperiment = traceManager.getActiveTrace();
    assertNotNull("No active trace", fNewExperiment);
    assertEquals("Incorrect active trace", "Experiment-trimmed", fNewExperiment.getName());
    WaitUtils.waitForJobs();
}
 
Example 8
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static List<String> listExpressionProposal(final SWTBot bot, final int index) {
    bot.toolbarButtonWithId(SWTBOT_ID_EXPRESSIONVIEWER_DROPDOWN, index).click();
    final SWTBotShell proposalShell = bot.shellWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_SHELL);
    final SWTBot proposalBot = proposalShell.bot();
    final SWTBotTable proposalTAble = proposalBot.tableWithId(SWTBOT_ID_EXPRESSIONVIEWER_PROPOSAL_TABLE);

    final List<String> result = new ArrayList<>();
    for (int i = 0; i < proposalTAble.rowCount(); i++) {
        result.add(proposalTAble.getTableItem(i).getText());
    }
    proposalShell.close();
    return result;
}
 
Example 9
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static boolean supplementaryFileExists(SWTBotTreeItem traceNode, String filename) {
    // make sure that analysis are finished
    WaitUtils.waitForJobs();
    try {
        ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
    }
    // Make sure that all jobs are finished after refresh
    WaitUtils.waitForJobs();

    traceNode.contextMenu().menu("Delete Supplementary Files...").click();

    SWTBotShell shell = fBot.shell("Delete Resources");
    SWTBot bot = shell.bot();
    SWTBotTree tree = bot.tree();
    SWTBotTreeItem traceSupplNode = SWTBotUtils.getTreeItem(bot, tree, traceNode.getText());

    SWTBotTreeItem[] supplFileNodes = traceSupplNode.getItems();

    boolean supplFound = false;
    for (SWTBotTreeItem swtBotTreeItem : supplFileNodes) {
        if (swtBotTreeItem.getText().equals(filename)) {
            supplFound = true;
            break;
        }
    }

    bot.button("Cancel").click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    return supplFound;
}
 
Example 10
Source File: StandardImportWizardTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void selectSyslog() throws Exception {
    SWTWorkbenchBot workbenchBot = getSWTBot();
    SWTBotShell shell = workbenchBot.shell("Trace Import");
    shell.setFocus();
    SWTBot bot = shell.bot();
    URL resource = TmfCoreTestPlugin.getDefault().getBundle().getResource(TEST_FOLDER_NAME);
    String path = FileLocator.toFileURL(resource).toURI().getPath();
    SWTBotImportWizardUtils.selectImportFromDirectory(bot, path);
    for (int i = 1; i <= 6; i++) {
        SWTBotImportWizardUtils.selectFile(bot, "syslog" + i, TEST_FOLDER_NAME);
    }
}
 
Example 11
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openTraceTypePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Trace Types", treeNode));
    treeNode = treeNode.getNode("Trace Types");
    treeNode.select();
    return preferencesShell;
}
 
Example 12
Source File: BotBdmModelEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotBdmModelEditor setType(String packageName, String businessObject, SWTBotTableItem item, String type,
        SWTBotTable attributeTable) {
    SWTBotShell activeShell = bot.activeShell();
    item.click(1);
    SWTBot activeBot = activeShell.bot();
    SWTBotCCombo ccomboBoxInGroup = activeBot.ccomboBoxWithId(FieldTypeEditingSupport.TYPE_COMBO_EDITOR_ID);
    activeBot.waitUntil(new ConditionBuilder()
            .withTest(() -> Stream.of(ccomboBoxInGroup.items()).anyMatch(type::equals))
            .withFailureMessage(() -> String.format("Type '%s' not found in combo", type))
            .create());
    ccomboBoxInGroup.setSelection(type);
    return this;
}
 
Example 13
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openXMLAnalysesPreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot, MANAGE_XML_ANALYSES_PREF_TITLE);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("XML Analyses", treeNode));
    treeNode = treeNode.getNode("XML Analyses");
    treeNode.select();
    return preferencesShell;
}
 
Example 14
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void openRemoteProfilePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);

    // The first tree is the preference "categories" on the left side
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Remote Profiles", treeNode));
    treeNode = treeNode.getNode("Remote Profiles");
    treeNode.select();
}
 
Example 15
Source File: TestInvalidCtfTrace.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Open an invalid trace and see the message
 */
@Test
public void testOpen() {
    SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.ui.type.ctf", false);
    final SWTBotShell shell = fBot.shell("Open Trace").activate();
    final SWTBot dialogBot = shell.bot();
    String text = dialogBot.label(1).getText();
    dialogBot.button().click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    assertContains(fExpectedMessage, text);

}
 
Example 16
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Integration test for the time event filtering dialog
 */
@Test
public void testHideEmptyRows() {
    resetTimeRange();

    SWTBotTimeGraph timegraph = fTimeGraph;
    assertTrue("timegraph visible", timegraph.isVisible());
    timegraph.setFocus();

    /* set time range */
    setWindowRange(49L, 75L);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 17, timegraph, () -> "All entries should be visible here: " + getVisibleItems(timegraph));

    /* hide empty rows (includes a row with only 1 marker) */
    fViewBot.toolbarButton("Hide Empty Rows").click();
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 10, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* change time range to exclude row with markers */
    setWindowRange(51L, 75L);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 9, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* add a time events filter */
    timegraph.setFocus();
    // Move mouse to middle of the timegraph
    timegraph.moveMouseToWidget();
    // Press '/' to open the filter dialog
    timegraph.pressShortcut(KeyStroke.getInstance('/'));

    SWTBot viewBot = fViewBot.bot();
    SWTBotShell dialogShell = viewBot.shell("Time Event Filter").activate();
    SWTBot shellBot = dialogShell.bot();
    SWTBotText text = shellBot.text();
    text.setText("Head3");
    text.setFocus();
    SWTBotUtils.pressShortcut(text, Keystrokes.CR);
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 2, timegraph, () -> "Fewer entries should be visible here: " + getVisibleItems(timegraph));

    /* show also empty rows */
    fViewBot.toolbarButton("Hide Empty Rows").click();
    /* All rows will be filtered by time events filter */
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 2, timegraph, () -> "Same number of entries should be visible here: " + getVisibleItems(timegraph));

    /* remove time events filter */
    dialogShell = viewBot.shell("Time Event Filter").activate();
    shellBot = dialogShell.bot();
    SWTBotButton button = shellBot.buttonWithTooltip("Close (Esc)");
    button.click();
    SWTBotUtils.waitUntil(tg -> getVisibleItems(tg).size() == 17, timegraph, () -> "All entries should be visible here: " + getVisibleItems(timegraph));
}
 
Example 17
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Integration test for the time event filtering dialog
 */
@Test
public void testTimegraphEventFiltering() {
    SWTWorkbenchBot bot = fBot;
    resetTimeRange();

    SWTBot viewBot = fViewBot.bot();
    SWTBotTimeGraph timegraph = fTimeGraph;
    assertTrue("timegraph visible", timegraph.isVisible());
    timegraph.setFocus();

    Rectangle bounds = fBounds;

    ImageHelper ref = ImageHelper.grabImage(bounds);

    timegraph.setFocus();
    // Move mouse to middle of the timegraph
    timegraph.moveMouseToWidget();
    // Press '/' to open the filter dialog
    timegraph.pressShortcut(KeyStroke.getInstance('/'));

    SWTBotShell dialogShell = viewBot.shell("Time Event Filter").activate();
    SWTBot shellBot = dialogShell.bot();
    SWTBotText text = shellBot.text();
    text.setText("Hat1");
    bot.waitWhile(fTimeGraphIsDirty);

    timegraph.setFocus();
    ImageHelper filtered = ImageHelper.waitForNewImage(bounds, ref);

    /* Compare with the original, they should be different */
    int refHatCount = ref.getHistogram().count(fHat);
    int filteredHatCount = filtered.getHistogram().count(fHat);
    int refHairCount = ref.getHistogram().count(fHair);
    int filteredHairCount = filtered.getHistogram().count(fHair);
    assertTrue("Count of \"HAT\" did not decrease to non-zero", filteredHatCount < refHatCount && filteredHatCount > 0);
    assertTrue("Count of \"HAIR\" did not decrease to zero", filteredHairCount < refHairCount && filteredHairCount == 0);

    dialogShell = viewBot.shell("Time Event Filter").activate();
    shellBot = dialogShell.bot();
    text = shellBot.text();
    text.setFocus();
    SWTBotUtils.pressShortcut(text, Keystrokes.CR);

    bot.waitWhile(fTimeGraphIsDirty);
    List<String> visibleItems = getVisibleItems(timegraph);
    assertEquals("Fewer entries should be visible here: " + visibleItems, 3, visibleItems.size());
}
 
Example 18
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the legend operation for an arrow. Change sliders and reset, do not
 * change colors as there is not mock of the color picker yet
 *
 * TODO: mock color picker
 *
 * TODO: make stable
 */
@Test
public void testLegendArrow() {
    resetTimeRange();
    Rectangle bounds = fBounds;

    ImageHelper ref = ImageHelper.grabImage(bounds);

    // Set the widths to 0.25

    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    legendShell.activate();
    SWTBot legendBot = legendShell.bot();
    assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).isEnabled());
    int defaultValue = legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).getValue();
    legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).setValue(100);
    assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).isEnabled());
    legendShell.bot().button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    // Take another picture
    ImageHelper thick = ImageHelper.waitForNewImage(bounds, ref);

    // Compare with the original, they should be different
    int refCount = ref.getHistogram().count(fLaser);
    int thickCount = thick.getHistogram().count(fLaser);
    assertTrue(String.format("Count of \"\"LASER\"\" (%s) did not get change despite change of width before: %d after:%d histogram:%s", fLaser, refCount, thickCount, Multisets.copyHighestCountFirst(thick.getHistogram())), thickCount > refCount);

    // reset all
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    legendShell = fBot.shell(LEGEND_NAME);
    legendBot = legendShell.bot();
    assertTrue(legendBot.buttonWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).isEnabled());
    legendBot.buttonWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).click();
    assertEquals(defaultValue, legendBot.scaleWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).getValue());
    assertFalse(legendBot.buttonWithId(LEGEND_ENTRY_KEY, QUOTE_LASER_UNQUOTE).isEnabled());
    legendBot.button(OK_BUTTON).click();
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    resetTimeRange();

    // take a third picture
    ImageHelper reset = ImageHelper.waitForNewImage(bounds, thick);

    // Compare with the original, they should be the same
    int resetCount = reset.getHistogram().count(fLaser);
    assertEquals("Count of \"\"LASER\"\" did not get change despite reset of width", refCount, resetCount);
}
 
Example 19
Source File: SDViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example 20
Source File: FlameChartViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test manipulating valid and invalid mapping files (add, remove and change
 * priority of files)
 *
 * @throws IOException
 *             Missing file
 */
@Test
public void testManipulatingMappingFiles() throws IOException {

    // 1- Open valid mapping files and invalid mapping file
    URL mapUrlA = CtfTmfTestTraceUtils.class.getResource("cyg-profile-mapping.txt");
    URL mapUrlB = CtfTmfTestTraceUtils.class.getResource("dummy-mapping.txt");
    URL mapUrlC = CtfTmfTestTraceUtils.class.getResource("invalid-cyg-profile-mapping.txt");
    URL mapUrlD = CtfTmfTestTraceUtils.class.getResource("random.out");
    URL mapUrlE = CtfTmfTestTraceUtils.class.getResource("win32Random.exe");

    String absoluteFileA = FileLocator.toFileURL(mapUrlA).getFile();
    String absoluteFileB = FileLocator.toFileURL(mapUrlB).getFile();
    String absoluteFileC = FileLocator.toFileURL(mapUrlC).getFile();
    String absoluteFileD = FileLocator.toFileURL(mapUrlD).getFile();
    String absoluteFileE = FileLocator.toFileURL(mapUrlE).getFile();
    String[] overrideFiles = { absoluteFileA, absoluteFileA, absoluteFileB, absoluteFileC, absoluteFileD, absoluteFileE };
    TmfFileDialogFactory.setOverrideFiles(overrideFiles);

    SWTBotShell shell = openSymbolProviderDialog();
    final SWTBot symbolDialog = shell.bot();
    symbolDialog.button("Add...").click();
    final SWTBot errorDialog = sfBot.shell("Import failure").bot();
    errorDialog.button("OK").click();
    final SWTBotTable table = symbolDialog.table();
    assertEquals(4, table.rowCount());
    assertEquals(absoluteFileA, table.getTableItem(0).getText());
    assertEquals(absoluteFileB, table.getTableItem(1).getText());
    assertEquals(absoluteFileD, table.getTableItem(2).getText());
    assertEquals(absoluteFileE, table.getTableItem(3).getText());

    // 2- Change priority of mapping files
    table.select(0);
    symbolDialog.button("Down").click().click().click();
    assertEquals(absoluteFileB, table.getTableItem(0).getText());
    assertEquals(absoluteFileD, table.getTableItem(1).getText());
    assertEquals(absoluteFileE, table.getTableItem(2).getText());
    assertEquals(absoluteFileA, table.getTableItem(3).getText());

    symbolDialog.button("Up").click().click().click();
    assertEquals(absoluteFileA, table.getTableItem(0).getText());
    assertEquals(absoluteFileB, table.getTableItem(1).getText());
    assertEquals(absoluteFileD, table.getTableItem(2).getText());
    assertEquals(absoluteFileE, table.getTableItem(3).getText());

    // 3- Remove multiple mapping files
    table.select(0, 1);
    symbolDialog.button("Remove").click();
    assertEquals(2, table.rowCount());

    // 4- Close symbol provider dialog
    symbolDialog.button("Cancel").click();
}