Java Code Examples for org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor#close()

The following examples show how to use org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor#close() . 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: OpenExistingApplicationIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_create_and_open_applications() {
    final BotApplicationWorkbenchWindow workBenchBot = new BotApplicationWorkbenchWindow(bot);
    String applicationName1 = createApplication(workBenchBot);
    String applicationName2 = createApplication(workBenchBot);

    workBenchBot.openApplication().select(applicationName1 + ".xml").finish();
    final SWTBotEditor app1Editor = bot.activeEditor();
    assertEquals(applicationName1 + ".xml", app1Editor.getTitle());
    app1Editor.close();

    workBenchBot.openApplication()
            .select(applicationName1 + ".xml", applicationName2 + ".xml")
            .finish();
    assertEquals(2, bot.editors().size());

    deleteApplications(workBenchBot, applicationName1 + ".xml", applicationName2 + ".xml");
}
 
Example 2
Source File: FixedDefaultWorkbench.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Close all editors.
 *
 * @return the fixed default workbench
 */
FixedDefaultWorkbench closeAllEditors() {
  List<? extends SWTBotEditor> editors = bot.editors();
  for (SWTBotEditor editor : editors) {
    editor.close();
  }
  return this;
}
 
Example 3
Source File: GotoDefinitionTest.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * See first issue mentioned in https://github.com/tlaplus/tlaplus/issues/106
 * 
 * We don't need to test the hyperlink jump, we only need to test that the TokenSpec instance returned by
 *     TokenSpec.findCurrentTokenSpec(IRegion) has a non-null resolvedSymbol attribute.
 * @throws InterruptedException 
 */
@Test
public void verifyTokenSpecSymbolResolution () throws InterruptedException {
	final BlockingQueue<TokenSpec> queue = new ArrayBlockingQueue<TokenSpec>(1);
	final Region r = new Region(193, 0);
    // This region is expected to place the cursor just prior to the subscripted identifier, the 's' in "..._s" in:
    //             Spec == s = "" /\ [][Next(s)]_s
    UIHelper.runUIAsync(new Runnable() {
		@Override
		public void run() {
			queue.add(TokenSpec.findCurrentTokenSpec(r));
		}
	});
	
	final TokenSpec ts = queue.poll(15, TimeUnit.SECONDS);

	Assert.assertNotNull("TokenSpec was unable to find any token at " + r.toString(), ts);

	Assert.assertEquals("TokenSpec was not for the expected token, perhaps someone has changed GotoDefinition.tla?",
			"_s", ts.token);

	Assert.assertNotNull(
			"TokenSpec was unable to resolve the symbol for the token [" + ts.token + "] at " + r.toString(),
			ts.resolvedSymbol);
    
    // No real reason this need be done from a test functionality perspective
       SWTBotEditor activeEditor = bot.activeEditor();
       activeEditor.close();
}
 
Example 4
Source File: SwtBotProjectHelper.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public static void closeAllEditors(final SWTWorkbenchBot it) {
  final Consumer<SWTBotEditor> _function = (SWTBotEditor it_1) -> {
    it_1.close();
  };
  it.editors().forEach(_function);
}
 
Example 5
Source File: BookmarksViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private static void bookmarkTest(String editorName) throws IOException {
    SWTBotView fViewBot = fBot.viewByPartName("Bookmarks");
    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    assertEquals("Failed to show the Bookmarks View", "Bookmarks", fViewBot.getTitle());
    /**
     * Add a bookmark: a) Double click to select an event in the event
     * editor b) Go to the Edit > Add Bookmark... menu c) Enter the bookmark
     * description in dialog box
     */
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, editorName);
    SWTBotTable tableBot = editorBot.bot().table();
    SWTBotTableItem tableItem = tableBot.getTableItem(7);
    String expectedTimeStamp = tableItem.getText(1);
    assertNull("The image should not be bookmarked yet", getBookmarkImage(tableItem));

    tableItem.select();
    tableItem.doubleClick();
    fBot.menu("Edit").menu("Add Bookmark...").click();
    WaitUtils.waitForJobs();
    SWTBotShell addBookmarkShell = fBot.shell("Add Bookmark");
    addBookmarkShell.bot().text().setText(BOOKMARK_NAME);
    addBookmarkShell.bot().button("OK").click();
    assertNotNull("Failed to add bookmark in event editor", getBookmarkImage(tableItem));

    fViewBot.setFocus();
    WaitUtils.waitForJobs();
    SWTBotTree bookmarkTree = fViewBot.bot().tree();
    WaitUtils.waitForJobs();
    /**
     * throws WidgetNotFoundException - if the node was not found, nothing
     * to assert
     */
    SWTBotTreeItem bookmark = bookmarkTree.getTreeItem(BOOKMARK_NAME);
    assertEquals(BOOKMARK_NAME, bookmark.cell(0));

    /**
     * Scroll within event table so that bookmark is not visible anymore and
     * then double-click on bookmark in Bookmarks View
     */
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(null, TmfTimestamp.fromMicros(22))));
    bookmark.doubleClick();
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    TableCollection selection = tableBot.selection();
    TableRow row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Open another trace #2 and then double-click on bookmark in Bookmarks
     * view
     */
    SWTBotUtils.openTrace(PROJECT_NAME, FileLocator.toFileURL(TmfTraceStub.class.getResource("/testfiles/E-Test-10K")).getPath(), TRACE_TYPE);
    WaitUtils.waitForJobs();
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(TABLE_NOT_EMPTY, tableBot, "Table is still empty");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Close the trace #1 and then double-click on bookmark in Bookmarks
     * view
     */
    editorBot.close();
    WaitUtils.waitUntil(eb -> !eb.isActive(), editorBot, "Waiting for the editor to close");
    bookmark.doubleClick();
    editorBot = SWTBotUtils.activeEventsEditor(fBot, editorName);
    WaitUtils.waitUntil(eb -> eb.bot().table().selection().rowCount() > 0, editorBot, "Selection is still empty");
    tableBot = editorBot.bot().table();
    WaitUtils.waitUntil(tb -> !Objects.equal(tb.selection().get(0).get(1), "<srch>"), tableBot, "Header is still selected");
    selection = tableBot.selection();
    row = selection.get(0);
    assertNotNull(selection.toString(), row);
    assertEquals("Wrong event was selected " + selection, expectedTimeStamp, row.get(1));

    /**
     * Select bookmarks icon in bookmark view right-click on icon and select
     * "Remove Bookmark"
     */
    bookmark.select();
    bookmark.contextMenu("Delete").click();
    SWTBotShell deleteBookmarkShell = fBot.shell("Delete Selected Entries");
    SWTBotUtils.anyButtonOf(deleteBookmarkShell.bot(), "Delete", "Yes").click();
    fBot.waitUntil(Conditions.treeHasRows(bookmarkTree, 0));
    tableItem = editorBot.bot().table().getTableItem(7);
    assertNull("Bookmark not deleted from event table", getBookmarkImage(tableItem));
}
 
Example 6
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the behavior with two traces.
 */
@Ignore
@Test
public void testPinTwoTraces() {
    ITmfTrace ust = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTestTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTestTrace.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTestTrace.getName());

    // assert that the pin to drop down menuItems are present for both traces.
    fBot.waitUntil(new DefaultCondition() {
        WidgetNotFoundException fException;

        @Override
        public boolean test() throws Exception {
            try {
                SWTBotToolbarDropDownButton toolbarDropDownButton = fOriginalViewBot.toolbarDropDownButton(PIN_VIEW_BUTTON_NAME);
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + kernelTestTrace.getName());
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + fUstTestTrace.getName()).click();
                return true;
            } catch (WidgetNotFoundException e) {
                fException = e;
                return false;
            }
        }

        @Override
        public String getFailureMessage() {
            return "Traces not available in toolbar drop down menu: " + fException;
        }
    });

    /*
     * assert that the pinned view is the UST trace despite the active trace being
     * the kernel trace.
     */
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull("There should be an active trace", activeTrace);
    assertEquals("context-switches-kernel should be the active trace", kernelTestTrace.getName(), activeTrace.getName());

    // Get the window range of the kernel trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace kernelTrace = traceManager.getActiveTrace();
    assertNotNull(kernelTrace);

    // switch back and forth
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);

    SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);

    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace));

    // assert that the ust trace's window range did not change
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, INITIAL_UST_RANGE));

    // unpin from another active trace
    SWTBotUtils.activateEditor(fBot, kernelTrace.getName());
    fOriginalViewBot.toolbarButton(UNPIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);

    fOriginalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(PINNED_TO_KERNEL_TIME_GRAPH_VIEW_TITLE);

    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();

    TmfTimeRange expectedUstWindowRange = new TmfTimeRange(TmfTimestamp.fromNanos(UST_START + SECOND), TmfTimestamp.fromNanos(UST_END - SECOND));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, expectedUstWindowRange, ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernelTrace, expectedUstWindowRange));

    // close the pinned trace
    SWTBotEditor kernelTable = fBot.editorByTitle(kernelTestTrace.getName());
    kernelTable.close();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);

    kernelTestTrace.dispose();
}
 
Example 7
Source File: PinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the cloning feature.
 */
@Test
public void testCloneSingleTrace() {
    // single trace.
    SWTBotMenu cloneMenu = fOriginalViewBot.viewMenu().menu(NEW_VIEW_MENU);

    /*
     * assert that the original editor was not renamed and that the cloned one
     * exists and is pinned to the UST trace.
     */
    cloneMenu.menu(PINNED_TO_PREFIX + fUstTestTrace.getName()).click();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);
    SWTBotView clonedView = fBot.viewByTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    assertEquals("Should not have created a new instance", 1, fBot.editors().size());
    clonedView.close();

    /*
     * Assert that a new instance is created.
     */
    cloneMenu.menu(PINNED_TO_PREFIX + fUstTestTrace.getName() + " | new instance").click();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);
    clonedView = fBot.viewByTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE2);
    assertEquals("Should have created a new instance", 2, fBot.editors().size());
    SWTBotEditor cloneEditor = fBot.editorByTitle(fUstTestTrace.getName() + CLONED_TRACE_SUFFIX);

    // Get the window range of the cloned trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace cloneTrace = traceManager.getActiveTrace();
    assertNotNull(cloneTrace);

    // go back to original trace, pin it
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    fOriginalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();
    ITmfTrace ust = traceManager.getActiveTrace();
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, ust));

    // assert that the cloned trace's window range did not change
    SWTBotUtils.activateEditor(fBot, cloneTrace.getName() + CLONED_TRACE_SUFFIX);
    IWorkbenchPart part = clonedView.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, cloneTrace, INITIAL_UST_RANGE));
    cloneEditor.close();
}
 
Example 8
Source File: CounterViewPinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the behavior with two traces.
 */
@Test
public void testPinTwoTraces() {
    SWTBotView originalViewBot = getSWTBotView();

    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(activeTrace);
    ITmfTrace kernelTestTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTestTrace.getPath(), TRACETYPE_ID);

    /// Finish waiting for the trace to index
    WaitUtils.waitForJobs();
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTestTrace.getName());

    // Assert that the pin to drop down menuItems are present for both traces.
    fBot.waitUntil(new DefaultCondition() {
        WidgetNotFoundException fException;

        @Override
        public boolean test() throws Exception {
            try {
                SWTBotToolbarDropDownButton toolbarDropDownButton = originalViewBot.toolbarDropDownButton(PIN_VIEW_BUTTON_NAME);
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + kernelTestTrace.getName());
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + getTestTrace().getName()).click();
                return true;
            } catch (WidgetNotFoundException e) {
                fException = e;
                return false;
            }
        }

        @Override
        public String getFailureMessage() {
            return "Traces not available in toolbar drop down menu: " + fException;
        }
    });

    /*
     * Assert that the pinned view is the kernel_vm trace despite the active trace being
     * the context-switch trace.
     */
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);
    activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull("There should be an active trace", activeTrace);
    assertEquals("context-switches-kernel should be the active trace", kernelTestTrace.getName(), activeTrace.getName());

    // Get the window range of the kernel trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace kernelTrace = traceManager.getActiveTrace();
    assertNotNull(kernelTrace);

    // Switch back and forth
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);

    SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);

    IViewPart viewPart = originalViewBot.getViewReference().getView(false);
    assertTrue(viewPart instanceof TmfChartView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace));

    // Assert that the original views trace's window range did not change
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    SWTBotUtils.waitUntil(v -> (v.getWindowStartTime() == KERNEL_START && v.getWindowEndTime() == KERNEL_TEST_INITIAL_END), chartViewer, "Range of cloned view changed");

    // Unpin from active trace
    SWTBotUtils.activateEditor(fBot, kernelTrace.getName());
    originalViewBot.toolbarButton(UNPIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);

    originalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();

    assertOriginalViewTitle(PINNED_TO_CTX_SWITCH_VIEW_TITLE);

    // Close the pinned trace
    SWTBotEditor kernelTable = fBot.editorByTitle(kernelTestTrace.getName());
    kernelTable.close();

    // Verify that view title is reset
    SWTBotUtils.waitUntil(v -> v.getReference().getPartName().equals(COUNTERS_VIEW_TITLE), originalViewBot, "View name didn't change");
    kernelTestTrace.dispose();
}
 
Example 9
Source File: CounterViewPinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the cloning feature.
 */
@Test
public void testCloneSingleTrace() {
    SWTBotView originalViewBot = getSWTBotView();
    SWTBotMenu cloneMenu = originalViewBot.viewMenu().menu(NEW_COUNTER_STACK_MENU);

    /*
     * Assert that the original editor was not renamed and that the cloned one
     * exists and is pinned to the kernel_vm trace.
     */
    cloneMenu.menu(PINNED_TO_PREFIX + getTestTrace().getName()).click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);
    SWTBotView clonedView = fBot.viewByTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);
    assertEquals("Should not have created a new instance", 1, fBot.editors().size());
    clonedView.close();

     // Assert that a new instance is created.
    cloneMenu.menu(PINNED_TO_PREFIX + getTestTrace().getName() + " | new instance").click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);
    clonedView = fBot.viewByTitle(CLONED_VIEW_TITLE_NAME);
    assertEquals("Should have created a new instance", 2, fBot.editors().size());
    SWTBotEditor cloneEditor = fBot.editorByTitle(getTestTrace().getName() + CLONED_TRACE_SUFFIX);

    // Get the window range of the cloned trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace cloneTrace = traceManager.getActiveTrace();
    assertNotNull(cloneTrace);

    // Go back to original trace, pin it
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    originalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();

    // Assert that the cloned trace's window range did not change
    SWTBotUtils.activateEditor(fBot, cloneTrace.getName() + CLONED_TRACE_SUFFIX);
    IViewPart viewPart = clonedView.getViewReference().getView(false);
    assertTrue(viewPart instanceof TmfChartView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);

    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, getTestTrace()));
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    SWTBotUtils.waitUntil(v -> (v.getWindowStartTime() == KERNEL_START && v.getWindowEndTime() == KERNEL_INITIAL_END), chartViewer, "Range of cloned view changed");

    cloneEditor.close();
}
 
Example 10
Source File: NewCounterViewPinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the behavior with two traces.
 */
@Test
public void testPinTwoTraces() {
    SWTBotView originalViewBot = getSWTBotView();

    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(activeTrace);
    ITmfTrace kernelTestTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTestTrace.getPath(), TRACETYPE_ID);

    /// Finish waiting for the trace to index
    WaitUtils.waitForJobs();
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTestTrace.getName());

    // Assert that the pin to drop down menuItems are present for both traces.
    fBot.waitUntil(new DefaultCondition() {
        WidgetNotFoundException fException;

        @Override
        public boolean test() throws Exception {
            try {
                SWTBotToolbarDropDownButton toolbarDropDownButton = originalViewBot.toolbarDropDownButton(PIN_VIEW_BUTTON_NAME);
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + kernelTestTrace.getName());
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + getTestTrace().getName()).click();
                return true;
            } catch (WidgetNotFoundException e) {
                fException = e;
                return false;
            }
        }

        @Override
        public String getFailureMessage() {
            return "Traces not available in toolbar drop down menu: " + fException;
        }
    });

    /*
     * Assert that the pinned view is the kernel_vm trace despite the active trace being
     * the context-switch trace.
     */
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);
    activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull("There should be an active trace", activeTrace);
    assertEquals("context-switches-kernel should be the active trace", kernelTestTrace.getName(), activeTrace.getName());

    // Get the window range of the kernel trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace kernelTrace = traceManager.getActiveTrace();
    assertNotNull(kernelTrace);

    // Switch back and forth
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);

    SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);

    IViewPart viewPart = originalViewBot.getViewReference().getView(false);
    assertTrue(viewPart instanceof TmfChartView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace));

    // Assert that the original views trace's window range did not change
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    SWTBotUtils.waitUntil(v -> (v.getWindowStartTime() == KERNEL_START && v.getWindowEndTime() == KERNEL_TEST_INITIAL_END), chartViewer, "Range of cloned view changed");

    // Unpin from active trace
    SWTBotUtils.activateEditor(fBot, kernelTrace.getName());
    originalViewBot.toolbarButton(UNPIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);

    originalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();

    assertOriginalViewTitle(PINNED_TO_CTX_SWITCH_VIEW_TITLE);

    // Close the pinned trace
    SWTBotEditor kernelTable = fBot.editorByTitle(kernelTestTrace.getName());
    kernelTable.close();

    // Verify that view title is reset
    SWTBotUtils.waitUntil(v -> v.getReference().getPartName().equals(COUNTERS_VIEW_TITLE), originalViewBot, "View name didn't change");
    kernelTestTrace.dispose();
}
 
Example 11
Source File: NewCounterViewPinAndCloneTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the cloning feature.
 */
@Test
public void testCloneSingleTrace() {
    SWTBotView originalViewBot = getSWTBotView();
    SWTBotMenu cloneMenu = originalViewBot.viewMenu().menu(NEW_COUNTER_STACK_MENU);

    /*
     * Assert that the original editor was not renamed and that the cloned one
     * exists and is pinned to the kernel_vm trace.
     */
    cloneMenu.menu(PINNED_TO_PREFIX + getTestTrace().getName()).click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);
    SWTBotView clonedView = fBot.viewByTitle(PINNED_TO_TRACE_COUNTERS_VIEW_TITLE);
    assertEquals("Should not have created a new instance", 1, fBot.editors().size());
    clonedView.close();

     // Assert that a new instance is created.
    cloneMenu.menu(PINNED_TO_PREFIX + getTestTrace().getName() + " | new instance").click();
    assertOriginalViewTitle(COUNTERS_VIEW_TITLE);
    clonedView = fBot.viewByTitle(CLONED_VIEW_TITLE_NAME);
    assertEquals("Should have created a new instance", 2, fBot.editors().size());
    SWTBotEditor cloneEditor = fBot.editorByTitle(getTestTrace().getName() + CLONED_TRACE_SUFFIX);

    // Get the window range of the cloned trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace cloneTrace = traceManager.getActiveTrace();
    assertNotNull(cloneTrace);

    // Go back to original trace, pin it
    SWTBotUtils.activateEditor(fBot, getTestTrace().getName());
    originalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();

    // Assert that the cloned trace's window range did not change
    SWTBotUtils.activateEditor(fBot, cloneTrace.getName() + CLONED_TRACE_SUFFIX);
    IViewPart viewPart = clonedView.getViewReference().getView(false);
    assertTrue(viewPart instanceof TmfChartView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);

    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, getTestTrace()));
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    SWTBotUtils.waitUntil(v -> (v.getWindowStartTime() == KERNEL_START && v.getWindowEndTime() == KERNEL_INITIAL_END), chartViewer, "Range of cloned view changed");

    cloneEditor.close();
}