Search in sources :

Example 11 with ITmfTimestamp

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

the class TmfSecondTimestampTest method testDelta.

// ------------------------------------------------------------------------
// getDelta
// ------------------------------------------------------------------------
@Test
public void testDelta() {
    // Delta for same scale and precision (delta > 0)
    ITmfTimestamp tstamp0 = TmfTimestamp.fromSeconds(10);
    ITmfTimestamp tstamp1 = TmfTimestamp.fromSeconds(5);
    ITmfTimestamp expectd = TmfTimestamp.fromSeconds(5);
    ITmfTimestamp delta = tstamp0.getDelta(tstamp1);
    assertEquals("getDelta", 0, delta.compareTo(expectd));
    // Delta for same scale and precision (delta < 0)
    tstamp0 = TmfTimestamp.fromSeconds(5);
    tstamp1 = TmfTimestamp.fromSeconds(10);
    expectd = TmfTimestamp.fromSeconds(-5);
    delta = tstamp0.getDelta(tstamp1);
    assertEquals("getDelta", 0, delta.compareTo(expectd));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 12 with ITmfTimestamp

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

the class TmfSecondTimestampTest method testNormalizeScale0.

// ------------------------------------------------------------------------
// normalize
// ------------------------------------------------------------------------
@Test
public void testNormalizeScale0() {
    ITmfTimestamp ts = ts0.normalize(0, 0);
    assertEquals("getValue", 0, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(12345, 0);
    assertEquals("getValue", 12345, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(10, 0);
    assertEquals("getValue", 10, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(-10, 0);
    assertEquals("getValue", -10, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 13 with ITmfTimestamp

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

the class TmfTimeRangeTest method testContainsRange.

@Test
public void testContainsRange() {
    final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(10);
    final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(20);
    final ITmfTimestamp ts3 = TmfTimestamp.fromSeconds(30);
    final ITmfTimestamp ts4 = TmfTimestamp.fromSeconds(40);
    final ITmfTimestamp ts5 = TmfTimestamp.fromSeconds(50);
    final ITmfTimestamp ts6 = TmfTimestamp.fromSeconds(60);
    final ITmfTimestamp ts7 = TmfTimestamp.fromSeconds(70);
    final ITmfTimestamp ts8 = TmfTimestamp.fromSeconds(80);
    // Reference range
    final TmfTimeRange range0 = new TmfTimeRange(ts3, ts6);
    // Start time below range
    final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
    final TmfTimeRange range2 = new TmfTimeRange(ts2, ts3);
    final TmfTimeRange range3 = new TmfTimeRange(ts2, ts4);
    final TmfTimeRange range4 = new TmfTimeRange(ts2, ts6);
    final TmfTimeRange range5 = new TmfTimeRange(ts2, ts7);
    assertFalse("contains", range0.contains(range1));
    assertFalse("contains", range0.contains(range2));
    assertFalse("contains", range0.contains(range3));
    assertFalse("contains", range0.contains(range4));
    assertFalse("contains", range0.contains(range5));
    // End time above range
    final TmfTimeRange range6 = new TmfTimeRange(ts3, ts7);
    final TmfTimeRange range7 = new TmfTimeRange(ts4, ts7);
    final TmfTimeRange range8 = new TmfTimeRange(ts6, ts7);
    final TmfTimeRange range9 = new TmfTimeRange(ts7, ts8);
    assertFalse("contains", range0.contains(range6));
    assertFalse("contains", range0.contains(range7));
    assertFalse("contains", range0.contains(range8));
    assertFalse("contains", range0.contains(range9));
    // Within range
    final TmfTimeRange range10 = new TmfTimeRange(ts3, ts4);
    final TmfTimeRange range11 = new TmfTimeRange(ts3, ts6);
    final TmfTimeRange range12 = new TmfTimeRange(ts4, ts5);
    final TmfTimeRange range13 = new TmfTimeRange(ts4, ts6);
    assertTrue("contains", range0.contains(range10));
    assertTrue("contains", range0.contains(range11));
    assertTrue("contains", range0.contains(range12));
    assertTrue("contains", range0.contains(range13));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 14 with ITmfTimestamp

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

the class TmfTimeRangeTest method testOpenRange2.

@Test
public void testOpenRange2() {
    final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
    final TmfTimeRange range = new TmfTimeRange(ts1, TmfTimestamp.BIG_CRUNCH);
    assertEquals("startTime", ts1, range.getStartTime());
    assertEquals("endTime", TmfTimestamp.BIG_CRUNCH, range.getEndTime());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Example 15 with ITmfTimestamp

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

the class TmfTimeRangeTest method testEqualsBadType.

@Test
public void testEqualsBadType() {
    final ITmfTimestamp ts1 = TmfTimestamp.fromSeconds(12345);
    final ITmfTimestamp ts2 = TmfTimestamp.fromSeconds(12350);
    final TmfTimeRange range1 = new TmfTimeRange(ts1, ts2);
    assertTrue("equals", !range1.equals(ts1));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Test(org.junit.Test)

Aggregations

ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)162 Test (org.junit.Test)102 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)52 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)12 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)10 Point (org.eclipse.swt.graphics.Point)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)8 ArrayList (java.util.ArrayList)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4 File (java.io.File)3 Path (java.nio.file.Path)3 HashSet (java.util.HashSet)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3