use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph in project tracecompass by tracecompass.
the class TmfAlignTimeAxisTest method setAlignmentPosition.
private static void setAlignmentPosition(AbstractSWTBot<?> control, int position) {
if (control instanceof SWTBotSash) {
SWTBotSash sash = (SWTBotSash) control;
Rectangle bounds = sash.getBounds();
Point dst = new Point(position, bounds.y + bounds.height / 2);
sash.drag(dst);
} else if (control instanceof SWTBotTimeGraph) {
((SWTBotTimeGraph) control).setNameSpace(position);
}
// the TmfAlignmentSynchronizer queues the alignment
SWTBotUtils.waitUntil(synchronizer -> !synchronizer.isBusy(), TmfAlignmentSynchronizer.getInstance(), "Alignment synchronizer is busy");
}
use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph in project tracecompass by tracecompass.
the class TimeGraphViewTest method testVerticalZoom.
/**
* Test vertical zoom in and out
*/
@Test
public void testVerticalZoom() {
resetTimeRange();
int threshold = 10;
SWTBotTimeGraph timegraph = fTimeGraph;
Rectangle bounds = fBounds;
ImageHelper ref = ImageHelper.grabImage(bounds);
fireKeyAndWait(timegraph, bounds, false, '+', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '-', SWT.CTRL);
ImageHelper bigSmall = ImageHelper.grabImage(bounds);
ImageHelper diff = ref.diff(bigSmall);
// 3% of the image
threshold = (int) (diff.getHistogram().size() * 0.03);
List<RGB> colors = filter(diff.getHistogram(), threshold);
assertEquals(colors.toString(), 1, colors.size());
fireKeyAndWait(timegraph, bounds, false, '+', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '+', SWT.CTRL);
ImageHelper bigBig = ImageHelper.grabImage(bounds);
diff = ref.diff(bigBig);
colors = filter(diff.getHistogram(), threshold);
assertNotEquals(colors.toString(), 1, colors.size());
fireKeyAndWait(timegraph, bounds, false, '+', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '-', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '0', SWT.CTRL);
ImageHelper bigSmallReset = ImageHelper.grabImage(bounds);
diff = ref.diff(bigSmallReset);
colors = filter(diff.getHistogram(), threshold);
assertEquals(colors.toString(), 1, colors.size());
fireKeyAndWait(timegraph, bounds, false, '-', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '-', SWT.CTRL);
ImageHelper smallSmall = ImageHelper.grabImage(bounds);
diff = ref.diff(smallSmall);
colors = filter(diff.getHistogram(), threshold);
assertNotEquals(colors.toString(), 1, colors.size());
fireKeyAndWait(timegraph, bounds, false, '-', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '+', SWT.CTRL);
fireKeyAndWait(timegraph, bounds, false, '0', SWT.CTRL);
ImageHelper smallBigReset = ImageHelper.grabImage(bounds);
diff = ref.diff(smallBigReset);
colors = filter(diff.getHistogram(), threshold);
assertEquals(colors.toString(), 1, colors.size());
}
use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph in project tracecompass by tracecompass.
the class TimeGraphViewTest method testZoomToSelection.
/**
* Test zoom to selection
*/
@Test
public void testZoomToSelection() {
resetTimeRange();
SWTBotTimeGraph timegraph = fTimeGraph;
TimeGraphViewStub view = getView();
timegraph.setFocus();
assertEquals(80, getDuration(view.getWindowRange()));
/* set selection to trace start time */
ITmfTimestamp selStartTime = TmfTimestamp.fromNanos(30L);
ITmfTimestamp selEndTime = TmfTimestamp.fromNanos(80L);
TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, selStartTime, selEndTime));
timeGraphIsReadyCondition(new TmfTimeRange(selStartTime, selEndTime));
fireKeyInGraph(timegraph, 'z');
fViewBot.bot().waitUntil(new WindowRangeCondition(view, 50));
}
use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph in project tracecompass by tracecompass.
the class TimeGraphViewTest method testKeyboardNavigation.
/**
* Test 'a' and 'd' navigation
*/
@Test
public void testKeyboardNavigation() {
resetTimeRange();
SWTBotTimeGraph timegraph = fTimeGraph;
TimeGraphViewStub view = getView();
timegraph.setFocus();
assertEquals(80, getDuration(view.getWindowRange()));
TmfTimeRange updatedWindowRange = new TmfTimeRange(TmfTimestamp.fromNanos(40), TmfTimestamp.fromNanos(120));
// move to the right
fireKeyInGraph(timegraph, 'd');
fViewBot.bot().waitUntil(new TgConditionHelper(t -> updatedWindowRange.equals(view.getWindowRange())));
// move to the left
fireKeyInGraph(timegraph, 'a');
fViewBot.bot().waitUntil(new TgConditionHelper(t -> INITIAL_WINDOW_RANGE.equals(view.getWindowRange())));
}
use of org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph in project tracecompass by tracecompass.
the class TimeGraphViewTest 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();
}
SWTBotUtils.openView(TimeGraphViewStub.ID);
fViewBot = fBot.viewById(TimeGraphViewStub.ID);
fViewBot.show();
fTrace = new TmfTraceStub() {
@Override
@NonNull
public String getName() {
return "Stub";
}
@Override
public TmfContext seekEvent(ITmfLocation location) {
return new TmfContext();
}
@Override
public ITmfTimestamp getInitialRangeOffset() {
return TmfTimestamp.fromNanos(80);
}
};
fTrace.setStartTime(TmfTimestamp.fromNanos(0));
fTrace.setEndTime(TmfTimestamp.fromNanos(180));
TmfTraceStub trace = fTrace;
trace.initialize(null, "", ITmfEvent.class);
assertNotNull(trace);
fTimeGraph = new SWTBotTimeGraph(fViewBot.bot());
// Wait for trace to be loaded
fViewBot.bot().waitUntil(new TgConditionHelper(t -> fTimeGraph.getEntries().length == 0));
fBounds = getBounds();
UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null)));
// Wait for trace to be loaded
fViewBot.bot().waitUntil(new TgConditionHelper(t -> fTimeGraph.getEntries().length >= 2));
resetTimeRange();
// Make sure the thumb is over 1 in size
fBot.waitUntil(new TgConditionHelper(t -> fViewBot.bot().slider().getThumb() > 1));
}
Aggregations