Search in sources :

Example 1 with TmfTraceManager

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager in project tracecompass by tracecompass.

the class NewCounterViewPinAndCloneTest method testCloneSingleTrace.

/**
 * 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();
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) IViewPart(org.eclipse.ui.IViewPart) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) TmfChartView(org.eclipse.tracecompass.tmf.ui.views.xychart.TmfChartView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 2 with TmfTraceManager

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager in project tracecompass by tracecompass.

the class NewCounterViewPinAndCloneTest method testPinTwoTraces.

/**
 * 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();
}
Also used : IViewPart(org.eclipse.ui.IViewPart) SWTBotToolbarDropDownButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) TmfChartView(org.eclipse.tracecompass.tmf.ui.views.xychart.TmfChartView) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Example 3 with TmfTraceManager

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager in project tracecompass by tracecompass.

the class PinAndCloneTest method testPinTwoTraces.

/**
 * 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();
}
Also used : AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotToolbarDropDownButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotTableItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with TmfTraceManager

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager in project tracecompass by tracecompass.

the class TmfTraceManagerTest method testInitialize.

// ------------------------------------------------------------------------
// General tests
// ------------------------------------------------------------------------
/**
 * Test that the manager is correctly initialized
 */
@Test
public void testInitialize() {
    TmfTraceManager mgr = TmfTraceManager.getInstance();
    assertNotNull(mgr);
    assertSame(tm, mgr);
}
Also used : TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) Test(org.junit.Test)

Example 5 with TmfTraceManager

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager in project tracecompass by tracecompass.

the class CtfTmfExperimentTrimmingTest method setup.

/**
 * 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();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) ITmfProjectModelElement(org.eclipse.tracecompass.tmf.ui.project.model.ITmfProjectModelElement) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfExperimentElement(org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Before(org.junit.Before)

Aggregations

TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)11 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)9 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)6 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)6 Test (org.junit.Test)6 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)5 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)3 TmfCommonProjectElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfCommonProjectElement)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Shell (org.eclipse.swt.widgets.Shell)2 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)2 DefaultCondition (org.eclipse.swtbot.swt.finder.waits.DefaultCondition)2 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)2 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)2 SWTBotTableItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem)2 SWTBotToolbarDropDownButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton)2 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)2