Search in sources :

Example 21 with ITmfTimestamp

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

the class TmfTimestampDeltaTest method testCopyConstructor.

@Test
public void testCopyConstructor() {
    final ITmfTimestamp ts = TmfTimestamp.create(12345, 2);
    final ITmfTimestamp copy = TmfTimestamp.create(12345, 2);
    assertEquals("getValue", ts.getValue(), copy.getValue());
    assertEquals("getscale", ts.getScale(), copy.getScale());
    assertEquals("getValue", 12345, copy.getValue());
    assertEquals("getscale", 2, copy.getScale());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 22 with ITmfTimestamp

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

the class TmfTimestampDeltaTest method testNormalizeOffset.

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

Example 23 with ITmfTimestamp

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

the class TmfTimestampTest method testCompareToLargeScale3.

@Test
public void testCompareToLargeScale3() {
    final ITmfTimestamp ts0a = TmfTimestamp.create(1, Integer.MAX_VALUE);
    final ITmfTimestamp ts0b = TmfTimestamp.create(2, Integer.MAX_VALUE);
    assertTrue("CompareTo", ts0b.compareTo(ts0a) > 0);
    assertTrue("CompareTo", ts0a.compareTo(ts0b) < 0);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 24 with ITmfTimestamp

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

the class TmfTimestampTest method testNormalizeOffsetUpperLimits.

@Test
public void testNormalizeOffsetUpperLimits() {
    final ITmfTimestamp ref = TmfTimestamp.create(Long.MAX_VALUE - 5, 0);
    ITmfTimestamp ts = ref.normalize(4, 0);
    assertEquals("getValue", Long.MAX_VALUE - 1, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ref.normalize(5, 0);
    assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ref.normalize(6, 0);
    assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 25 with ITmfTimestamp

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

the class TmfTimestampTest method testDelta.

// ------------------------------------------------------------------------
// getDelta
// ------------------------------------------------------------------------
@Test
public void testDelta() {
    // Delta for same scale and precision (delta > 0)
    ITmfTimestamp t0 = TmfTimestamp.create(10, 9);
    ITmfTimestamp t1 = TmfTimestamp.create(5, 9);
    ITmfTimestamp exp = TmfTimestamp.create(5, 9);
    ITmfTimestamp delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for same scale and precision (delta < 0)
    t0 = TmfTimestamp.create(5, 9);
    t1 = TmfTimestamp.create(10, 9);
    exp = TmfTimestamp.create(-5, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for different scale and same precision (delta > 0)
    t0 = TmfTimestamp.create(5, 9);
    t1 = TmfTimestamp.create(10, 8);
    exp = TmfTimestamp.create(4, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for different scale and same precision (delta > 0)
    t0 = TmfTimestamp.create(5, 9);
    t1 = TmfTimestamp.create(10, 7);
    exp = TmfTimestamp.create(5, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for different scale and same precision
    t0 = TmfTimestamp.create(10, 9);
    t1 = TmfTimestamp.create(5, 8);
    exp = TmfTimestamp.create(10, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for same scale
    t0 = TmfTimestamp.create(10, 9);
    t1 = TmfTimestamp.create(5, 9);
    exp = TmfTimestamp.create(5, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
    // Delta for different scale
    t0 = TmfTimestamp.create(5, 9);
    t1 = TmfTimestamp.create(10, 8);
    exp = TmfTimestamp.create(4, 9);
    delta = t0.getDelta(t1);
    assertEquals("getDelta", 0, delta.compareTo(exp));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) 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