use of org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal in project tracecompass by tracecompass.
the class DisksIOViewTest method testDiskView.
/**
* Test to check the Disks IO Activity view. First, when trace opened, there
* should not be any activity. Then, we move to a time range where there are
* write activity. Afterward, we test the zoom
*/
@Test
public void testDiskView() {
// Wait for analysis to finish.
WaitUtils.waitForJobs();
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof DiskIOActivityView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
final Chart chart = getChart();
assertNotNull(chart);
SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
for (SWTBotTreeItem item : items) {
item.check();
}
SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length > 0, chart, "No data available");
chartViewer.setNbPoints(NUMBER_OF_POINT);
/* Initially, no disk activity */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk0-res50.json", "Chart data is not valid");
/* Change time range where there is disks activity */
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
fBot.waitUntil(ConditionHelpers.windowRange(new TmfTimeRange(ZOOM_START_TIME, ZOOM_END_TIME)));
fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
/* Test type, style and color of series */
verifyChartStyle();
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk1-res50.json", "Chart data is not valid");
/* Change Zoom and number of points */
chartViewer.setNbPoints(MORE_POINTS);
/* Test type, style and color of series */
verifyChartStyle();
/* Test data model */
SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, WRITE_SERIES_NAME), "resources/disk/disk2-res100.json", "Chart data is not valid");
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal in project tracecompass by tracecompass.
the class ResourcesAndCpuViewTest method testResetTimeRange.
/**
* Test that the reset time range button resets the time range for both the CPU
* view and the Resources view.
*/
@Test
public void testResetTimeRange() {
ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
assertNotNull(activeTrace);
IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
assertTrue(viewPart instanceof CpuUsageView);
final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
assertNotNull(chartViewer);
IWorkbenchPart part = fResourcesViewBot.getViewReference().getPart(false);
assertTrue(part instanceof AbstractTimeGraphView);
AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
// click the reset time range button in the CPU view
getSWTBotView().toolbarButton(RESET).click();
assertChartRange(chartViewer, FULL_RANGE);
fResourcesViewBot.setFocus();
fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
// go back to the original range
broadcast(new TmfWindowRangeUpdatedSignal(this, activeTrace.getInitialTimeRange(), activeTrace));
// click the reset time range button in the Resources View
fResourcesViewBot.toolbarButton(RESET).click();
assertChartRange(chartViewer, FULL_RANGE);
fResourcesViewBot.setFocus();
fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, activeTrace, FULL_RANGE));
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal in project tracecompass by tracecompass.
the class ResourcesViewTest method testAddRemoveBookmark.
/**
* Test tool bar button "Add Bookmark..." and "Remove Bookmark"
*/
@Test
public void testAddRemoveBookmark() {
SWTBotView viewBot = getViewBot();
/* change window range to 10 ms */
TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
fBot.waitUntil(ConditionHelpers.windowRange(range));
/* set selection to trace start time */
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME));
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME), START_TIME);
/* set focus on time graph */
SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(viewBot.bot());
timeGraph.setFocus();
/* select first CPU resource */
timeGraph.getEntry(LttngTraceGenerator.getName(), CPU0_THREADS).select();
/* click "Select Next State Change" 2 times */
viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME1, CPU0_TIME1), CPU0_TIME1);
viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME2, CPU0_TIME2), CPU0_TIME2);
/* click "Add Bookmark..." and fill Add Bookmark dialog */
viewBot.toolbarButton(ADD_BOOKMARK).click();
SWTBot dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot();
dialogBot.text().setText("B1");
dialogBot.button(OK).click();
/*
* click "Select Next State Change" 2 times and shift-click "Select Next
* State Change
*/
viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME3, CPU0_TIME3), CPU0_TIME3);
viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME4), CPU0_TIME4);
viewBot.toolbarButton(SELECT_NEXT_STATE_CHANGE).click(SWT.SHIFT);
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5);
/* click "Add Bookmark..." and fill Add Bookmark dialog */
viewBot.toolbarButton(ADD_BOOKMARK).click();
dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot();
dialogBot.text().setText("B2");
dialogBot.button(OK).click();
/* click "Previous Marker" */
viewBot.toolbarButton(PREVIOUS_MARKER).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME2, CPU0_TIME2), CPU0_TIME2);
/* click "Remove Bookmark" */
viewBot.toolbarButton(REMOVE_BOOKMARK).click();
/* click "Next Marker" */
viewBot.toolbarButton(NEXT_MARKER).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5);
/* click "Remove Bookmark" */
viewBot.toolbarButton(REMOVE_BOOKMARK).click();
/* click "Previous Marker" */
viewBot.toolbarButton(PREVIOUS_MARKER).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME5), CPU0_TIME5);
/* click "Select Previous State Change" */
viewBot.toolbarButton(SELECT_PREVIOUS_STATE_CHANGE).click();
timeGraphIsReadyCondition(new TmfTimeRange(CPU0_TIME4, CPU0_TIME4), CPU0_TIME4);
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal 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");
}
use of org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal 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();
}
Aggregations