Search in sources :

Example 71 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange 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));
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 72 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange 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())));
}
Also used : TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) UIThreadRunnable(org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable) TmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp) Conditions(org.eclipse.swtbot.swt.finder.waits.Conditions) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ConditionHelpers(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers) Point(org.eclipse.swt.graphics.Point) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) Logger(org.apache.log4j.Logger) SWTBotUtils(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils) KeyEvent(org.eclipse.swt.events.KeyEvent) After(org.junit.After) IPaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.IPaletteProvider) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) SequentialPaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.SequentialPaletteProvider) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) AfterClass(org.junit.AfterClass) Predicate(java.util.function.Predicate) SimpleLayout(org.apache.log4j.SimpleLayout) SWTBotPreferences(org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences) QualitativePaletteProvider(org.eclipse.tracecompass.tmf.core.presentation.QualitativePaletteProvider) TmfContext(org.eclipse.tracecompass.tmf.core.trace.TmfContext) Multisets(com.google.common.collect.Multisets) Display(org.eclipse.swt.widgets.Display) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) Collectors(java.util.stream.Collectors) TmfFileDialogFactory(org.eclipse.tracecompass.tmf.ui.dialog.TmfFileDialogFactory) Objects(java.util.Objects) MouseEvent(org.eclipse.swt.events.MouseEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) List(java.util.List) AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) Assert.assertFalse(org.junit.Assert.assertFalse) ConsoleAppender(org.apache.log4j.ConsoleAppender) SWT(org.eclipse.swt.SWT) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfLocation(org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) NonNull(org.eclipse.jdt.annotation.NonNull) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) KeyStroke(org.eclipse.jface.bindings.keys.KeyStroke) BeforeClass(org.junit.BeforeClass) Multiset(com.google.common.collect.Multiset) RunWith(org.junit.runner.RunWith) Rectangle(org.eclipse.swt.graphics.Rectangle) Keystrokes(org.eclipse.swtbot.swt.finder.keyboard.Keystrokes) Event(org.eclipse.swt.widgets.Event) ArrayList(java.util.ArrayList) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) Lists(com.google.common.collect.Lists) ImageHelper(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ImageHelper) ImmutableMultiset(com.google.common.collect.ImmutableMultiset) RGB(org.eclipse.swt.graphics.RGB) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Before(org.junit.Before) ITimeDataProvider(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) File(java.io.File) SWTBotButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotButton) SWTBotTimeGraphEntry(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraphEntry) SWTBotJunit4ClassRunner(org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner) ListResult(org.eclipse.swtbot.swt.finder.results.ListResult) Ignore(org.junit.Ignore) Result(org.eclipse.swtbot.swt.finder.results.Result) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) ICondition(org.eclipse.swtbot.swt.finder.waits.ICondition) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Assert.assertEquals(org.junit.Assert.assertEquals) Control(org.eclipse.swt.widgets.Control) RGBAUtil(org.eclipse.tracecompass.tmf.ui.colors.RGBAUtil) SWTBotTimeGraph(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 73 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class TimeGraphViewTest method setWindowRange.

private void setWindowRange(long start, long end) {
    ITmfTimestamp startTime = TmfTimestamp.fromNanos(start);
    ITmfTimestamp endTime = TmfTimestamp.fromNanos(end);
    TmfTimeRange range = new TmfTimeRange(startTime, endTime);
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range)));
    fViewBot.bot().waitUntil(ConditionHelpers.timeGraphRangeCondition(getView(), Objects.requireNonNull(fTrace), range));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 74 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class XYChartViewTest method testZoomToSelection.

/**
 * Test zoom to selection
 */
@Test
public void testZoomToSelection() {
    SWTBotEclipseSwtChart xyChart = new SWTBotEclipseSwtChart(fViewBot.bot());
    xyChart.setFocus();
    assertEquals(80, fXyViewer.getWindowDuration());
    /* set selection to trace start time */
    ITmfTimestamp selStartTime = TmfTimestamp.fromNanos(30L);
    ITmfTimestamp selEndTime = TmfTimestamp.fromNanos(80L);
    TmfTimeRange range = new TmfTimeRange(selStartTime, selEndTime);
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, selStartTime, selEndTime));
    // Wait till selection is finished
    fViewBot.bot().waitUntil(new DefaultCondition() {

        @Override
        public boolean test() throws Exception {
            return (fXyViewer.getSelectionEndTime() - fXyViewer.getSelectionBeginTime()) == getDuration(range);
        }

        @Override
        public String getFailureMessage() {
            return "SWT Chart is null";
        }
    });
    fireKeyInGraph(xyChart, 'z');
    fViewBot.bot().waitUntil(new SeriesCondition(fXyViewer, getDuration(range)));
}
Also used : SWTBotEclipseSwtChart(org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotEclipseSwtChart) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceException(org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException) Test(org.junit.Test)

Example 75 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class HistogramDataModelTest method testLostEventsScaleTo_4.

/**
 * Test method for {@link HistogramDataModel#scaleTo(int,int,int)}.
 */
@Test
public void testLostEventsScaleTo_4() {
    final int nbBuckets = 10;
    final int maxHeight = 10;
    final int nbEvents = 3 * nbBuckets;
    final int nbLostEvents_0 = 4;
    final int nbLostEvents_1 = 9;
    final int nbCombinedEvents = nbEvents + 2;
    final HistogramBucket[] expectedResult = new HistogramBucket[] { _3, _4, _4, _4, _4, _4, _4, _4, _4, _3 };
    final int[] expectedLostEventsResult = new int[] { 3, 1, 0, 0, 3, 3, 3, 3, 0, 0 };
    HistogramDataModel model = new HistogramDataModel(nbBuckets);
    final TmfTimeRange timeRange_0 = new TmfTimeRange(TmfTimestamp.fromNanos(5L), TmfTimestamp.fromNanos(10L));
    model.countLostEvent(timeRange_0, nbLostEvents_0, false);
    int firstNonLostEventTime = 6;
    countEventsInModel(nbEvents, model, 0, firstNonLostEventTime);
    final TmfTimeRange timeRange_1 = new TmfTimeRange(TmfTimestamp.fromNanos(18L), TmfTimestamp.fromNanos(27L));
    model.countLostEvent(timeRange_1, nbLostEvents_1, false);
    HistogramScaledData result = model.scaleTo(nbBuckets, maxHeight, 1);
    testModelConsistency(model, nbBuckets, nbCombinedEvents, 4, 5, 5, nbEvents + firstNonLostEventTime - 1, 4 * nbBuckets + firstNonLostEventTime - 1);
    assertArrayEquals(expectedResult, result.fData);
    assertArrayEquals(expectedLostEventsResult, result.fLostEventsData);
    assertEquals(7, result.fMaxCombinedValue);
}
Also used : HistogramDataModel(org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramDataModel) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) HistogramScaledData(org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramScaledData) HistogramBucket(org.eclipse.tracecompass.tmf.ui.views.histogram.HistogramBucket) Test(org.junit.Test)

Aggregations

TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)168 Test (org.junit.Test)98 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)53 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)29 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)24 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)24 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)21 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)20 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)19 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 SWTBotTimeGraph (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph)16 Vector (java.util.Vector)13 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)12 TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)10 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)9 AbstractTimeGraphView (org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView)9 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)8 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 Point (org.eclipse.swt.graphics.Point)7