use of org.eclipse.tracecompass.tmf.ui.views.xychart.TmfChartView 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();
}
use of org.eclipse.tracecompass.tmf.ui.views.xychart.TmfChartView 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();
}
use of org.eclipse.tracecompass.tmf.ui.views.xychart.TmfChartView in project tracecompass by tracecompass.
the class XYChartViewTest method before.
/**
* Before the test is run, make the view see the items.
*
* Reset the perspective and close all the views.
*
* @throws TmfTraceException
* could not load a trace
*/
@Before
public void before() throws TmfTraceException {
fBot = new SWTWorkbenchBot();
fBot.closeAllEditors();
for (SWTBotView viewBot : fBot.views()) {
viewBot.close();
}
fTrace = new TmfTraceStub() {
@Override
@NonNull
public String getName() {
return "Stub";
}
@Override
public TmfContext seekEvent(ITmfLocation location) {
return new TmfContext();
}
};
fTrace.setStartTime(TmfTimestamp.fromNanos(0));
fTrace.setEndTime(TmfTimestamp.fromNanos(180));
TmfTraceStub trace = fTrace;
trace.initialize(null, "", ITmfEvent.class);
assertNotNull(trace);
// Register trace to trace manager
UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null)));
// Open view
SWTBotUtils.openView(XYChartViewStub.ID);
fViewBot = fBot.viewById(XYChartViewStub.ID);
fViewBot.show();
TmfChartView viewPart = (TmfChartView) fViewBot.getViewReference().getView(true);
fXyViewer = viewPart.getChartViewer();
// Wait till SWT chart is constructed
fViewBot.bot().waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
return fXyViewer.getSwtChart() != null;
}
@Override
public String getFailureMessage() {
return "SWT Chart is null";
}
});
// Wait for trace to be loaded
resetTimeRange();
}
Aggregations