1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 * Patrick Tasse - Support selection range
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.temp
.tracemanager
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertNotNull
;
18 import static org
.junit
.Assert
.assertSame
;
19 import static org
.junit
.Assume
.assumeTrue
;
22 import java
.util
.Collection
;
23 import java
.util
.Collections
;
25 import org
.eclipse
.jdt
.annotation
.NonNull
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfRangeSynchSignal
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTimeSynchSignal
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceClosedSignal
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
33 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
34 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
35 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
36 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
37 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceContext
;
38 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
39 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.experiment
.TmfExperiment
;
40 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTrace
;
41 import org
.junit
.After
;
42 import org
.junit
.AfterClass
;
43 import org
.junit
.Before
;
44 import org
.junit
.BeforeClass
;
45 import org
.junit
.Test
;
47 import com
.google
.common
.collect
.ImmutableSet
;
50 * Test suite for the {@link TmfTraceManager}.
52 * @author Alexandre Montplaisir
54 public class TmfTraceManagerTest
{
56 private static final int SCALE
= ITmfTimestamp
.NANOSECOND_SCALE
;
58 private static ITmfTrace trace1
;
59 private static final long t1start
= 1331668247314038062L;
60 private static final long t1end
= 1331668259054285979L;
62 private static ITmfTrace trace2
;
63 private static final long t2start
= 1332170682440133097L;
64 private static final long t2end
= 1332170692664579801L;
66 private static final long ONE_SECOND
= 1000000000L;
68 private TmfTraceManager tm
;
72 * Test class initialization
75 public static void setUpClass() {
76 assumeTrue(CtfTmfTestTrace
.TRACE2
.exists());
77 assumeTrue(CtfTmfTestTrace
.KERNEL
.exists());
78 trace1
= CtfTmfTestTrace
.TRACE2
.getTrace();
79 trace2
= CtfTmfTestTrace
.KERNEL
.getTrace();
81 trace1
.indexTrace(true);
82 trace2
.indexTrace(true);
84 // Deregister traces from signal manager so that they don't
85 // interfere with the TmfTraceManager tests
86 TmfSignalManager
.deregister(trace1
);
87 TmfSignalManager
.deregister(trace2
);
95 tm
= TmfTraceManager
.getInstance();
102 public void tearDown() {
103 while (tm
.getActiveTrace() != null) {
104 closeTrace(tm
.getActiveTrace());
109 * Test class clean-up
112 public static void tearDownClass() {
113 CtfTmfTestTrace
.TRACE2
.dispose();
114 CtfTmfTestTrace
.KERNEL
.dispose();
117 // ------------------------------------------------------------------------
118 // Dummy actions (fake signals)
119 // ------------------------------------------------------------------------
121 private void openTrace(ITmfTrace trace
) {
123 throw new IllegalArgumentException();
125 TmfSignalManager
.dispatchSignal(new TmfTraceOpenedSignal(this, trace
, null));
129 private void closeTrace(ITmfTrace trace
) {
131 throw new IllegalArgumentException();
133 TmfSignalManager
.dispatchSignal(new TmfTraceClosedSignal(this, trace
));
135 * In TMF, the next tab would now be selected (if there are some), which
136 * would select another trace automatically.
138 if (tm
.getOpenedTraces().size() > 0) {
139 selectTrace(tm
.getOpenedTraces().toArray(new ITmfTrace
[0])[0]);
143 private void selectTrace(ITmfTrace trace
) {
144 TmfSignalManager
.dispatchSignal(new TmfTraceSelectedSignal(this, trace
));
147 private void selectTimestamp(@NonNull ITmfTimestamp ts
) {
148 TmfSignalManager
.dispatchSignal(new TmfTimeSynchSignal(this, ts
));
151 private void selectWindowRange(TmfTimeRange tr
) {
152 TmfSignalManager
.dispatchSignal(new TmfRangeSynchSignal(this, tr
));
155 // ------------------------------------------------------------------------
157 // ------------------------------------------------------------------------
160 * Test that the manager is correctly initialized
163 public void testInitialize() {
164 TmfTraceManager mgr
= TmfTraceManager
.getInstance();
170 * Test the contents of a trace set with one trace.
173 public void testTraceSet() {
178 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace2
);
179 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
181 assertEquals(1, actual
.size());
182 assertEquals(expected
, actual
);
186 * Test the contents of a trace set with an experiment.
189 public void testTraceSetExperiment() {
190 TmfExperiment exp
= createExperiment(trace1
, trace2
);
194 Collection
<ITmfTrace
> expected
= ImmutableSet
.of(trace1
, trace2
);
195 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
197 assertEquals(2, actual
.size());
198 assertEquals(expected
, actual
);
202 * Test the contents of the complete trace set.
205 public void testTraceSetWithExperiment() {
206 /* Test with a trace */
207 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace1
);
208 Collection
<ITmfTrace
> actual
= TmfTraceManager
.getTraceSetWithExperiment(trace1
);
209 assertEquals(1, actual
.size());
210 assertEquals(expected
, actual
);
212 /* Test with an experiment */
213 TmfExperiment exp
= createExperiment(trace1
, trace2
);
214 expected
= ImmutableSet
.of(trace1
, trace2
, exp
);
215 actual
= TmfTraceManager
.getTraceSetWithExperiment(exp
);
216 assertEquals(3, actual
.size());
217 assertEquals(expected
, actual
);
221 * Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
224 public void testSupplementaryFileDir() {
225 String name1
= trace1
.getName();
226 String name2
= trace2
.getName();
227 String basePath
= TmfTraceManager
.getTemporaryDirPath() + File
.separator
;
229 String expected1
= basePath
+ name1
+ File
.separator
;
230 String expected2
= basePath
+ name2
+ File
.separator
;
232 assertEquals(expected1
, TmfTraceManager
.getSupplementaryFileDir(trace1
));
233 assertEquals(expected2
, TmfTraceManager
.getSupplementaryFileDir(trace2
));
236 // ------------------------------------------------------------------------
237 // Test a single trace
238 // ------------------------------------------------------------------------
241 * Test the initial range of a single trace.
244 public void testTraceInitialRange() {
246 final TmfTimeRange expectedRange
= new TmfTimeRange(
247 trace2
.getStartTime(),
248 calculateOffset(trace2
.getStartTime(), trace2
.getInitialRangeOffset()));
249 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
250 assertEquals(expectedRange
, actualRange
);
254 * Try selecting a timestamp contained inside the trace's range. The trace's
255 * current time should get updated correctly.
258 public void testNewTimestamp() {
260 ITmfTimestamp ts
= new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
);
263 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
264 assertEquals(ts
, selection
.getStartTime());
265 assertEquals(ts
, selection
.getEndTime());
269 * Try selecting a timestamp happening before the trace's start. The change
273 public void testTimestampBefore() {
275 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
276 ITmfTimestamp ts
= new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
);
279 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
280 assertEquals(beforeTr
, selection
);
284 * Try selecting a timestamp happening after the trace's end. The change
288 public void testTimestampAfter() {
290 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
291 ITmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
294 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
295 assertEquals(beforeTr
, selection
);
299 * Test selecting a normal sub-range of a single trace.
302 public void testTraceNewTimeRange() {
304 TmfTimeRange range
= new TmfTimeRange(
305 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
306 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
307 selectWindowRange(range
);
309 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
310 assertEquals(range
, curRange
);
314 * Test selecting a range whose start time is before the trace's start time.
315 * The selected range should get clamped to the trace's range.
318 public void testTraceTimeRangeClampingStart() {
320 TmfTimeRange range
= new TmfTimeRange(
321 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
322 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
323 selectWindowRange(range
);
325 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
326 assertEquals(t2start
, curRange
.getStartTime().getValue());
327 assertEquals(range
.getEndTime(), curRange
.getEndTime());
331 * Test selecting a range whose end time is after the trace's end time.
332 * The selected range should get clamped to the trace's range.
335 public void testTraceTimeRangeClampingEnd() {
337 TmfTimeRange range
= new TmfTimeRange(
338 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
339 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
340 selectWindowRange(range
);
342 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
343 assertEquals(range
.getStartTime(), curRange
.getStartTime());
344 assertEquals(t2end
, curRange
.getEndTime().getValue());
348 * Test selecting a range whose both start and end times are outside of the
349 * trace's range. The selected range should get clamped to the trace's
353 public void testTraceTimeRangeClampingBoth() {
355 TmfTimeRange range
= new TmfTimeRange(
356 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
357 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
358 selectWindowRange(range
);
360 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
361 assertEquals(t2start
, curRange
.getStartTime().getValue());
362 assertEquals(t2end
, curRange
.getEndTime().getValue());
365 // ------------------------------------------------------------------------
366 // Test multiple, non-overlapping traces in parallel
367 // ------------------------------------------------------------------------
370 * Test, with two traces in parallel, when we select a timestamp that is
371 * part of the first trace.
373 * The first trace's timestamp should be updated, but the second trace's one
377 public void testTwoTracesTimestampValid() {
381 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
384 /* Timestamp of trace1 should have been updated */
385 TmfTraceContext ctx
= tm
.getCurrentTraceContext();
386 assertEquals(ts
, ctx
.getSelectionRange().getStartTime());
387 assertEquals(ts
, ctx
.getSelectionRange().getEndTime());
389 /* Timestamp of trace2 should not have changed */
391 ctx
= tm
.getCurrentTraceContext();
392 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getStartTime());
393 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getEndTime());
397 * Test, with two traces in parallel, when we select a timestamp that is
398 * between two traces.
400 * None of the trace's timestamps should be updated (we are not in an
404 public void testTwoTracesTimestampInBetween() {
408 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
411 /* Timestamp of trace1 should not have changed */
412 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
413 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
414 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
416 /* Timestamp of trace2 should not have changed */
418 selection
= tm
.getCurrentTraceContext().getSelectionRange();
419 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
420 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
424 * Test, with two traces in parallel, when we select a timestamp that is
425 * completely out of the trace's range.
427 * None of the trace's timestamps should be updated.
430 public void testTwoTracesTimestampInvalid() {
434 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
437 /* Timestamp of trace1 should not have changed */
438 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
439 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
440 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
442 /* Timestamp of trace2 should not have changed */
444 selection
= tm
.getCurrentTraceContext().getSelectionRange();
445 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
446 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
450 * Test, with two traces opened in parallel (not in an experiment), if we
451 * select a time range valid in one of them. That trace's time range should
452 * be updated, but not the other one.
455 public void testTwoTracesTimeRangeAllInOne() {
459 TmfTimeRange range
= new TmfTimeRange(
460 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
461 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
462 selectWindowRange(range
);
464 /* Range of trace1 should be equal to the requested one */
465 assertEquals(range
, tm
.getCurrentTraceContext().getWindowRange());
467 /* The range of trace 2 should not have changed */
469 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
473 * Test, with two traces in parallel, when we select a time range that is
474 * only partially valid for one of the traces.
476 * The first trace's time range should be clamped to a valid range, and the
477 * second one's should not change.
480 public void testTwoTracesTimeRangePartiallyInOne() {
484 TmfTimeRange range
= new TmfTimeRange(
485 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
486 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
));
487 selectWindowRange(range
);
489 /* Range of trace1 should get clamped to its end time */
490 TmfTimeRange expectedRange
= new TmfTimeRange(
491 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
492 new TmfTimestamp(t1end
, SCALE
));
493 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
495 /* Range of trace2 should not have changed */
497 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
501 * Test, with two traces in parallel, when we select a time range that is
502 * only partially valid for both traces.
504 * Each trace's time range should get clamped to respectively valid ranges.
507 public void testTwoTracesTimeRangeInBoth() {
511 TmfTimeRange range
= new TmfTimeRange(
512 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
513 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
514 selectWindowRange(range
);
516 /* Range of trace1 should be clamped to its end time */
517 TmfTimeRange expectedRange
= new TmfTimeRange(
518 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
519 new TmfTimestamp(t1end
, SCALE
));
520 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
522 /* Range of trace2 should be clamped to its start time */
524 expectedRange
= new TmfTimeRange(
525 new TmfTimestamp(t2start
, SCALE
),
526 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
527 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
531 * Test, with two traces in parallel, when we select a time range that is
532 * not valid for any trace.
534 * Each trace's time range should not be modified.
537 public void testTwoTracesTimeRangeInBetween() {
541 TmfTimeRange range
= new TmfTimeRange(
542 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
543 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
544 selectWindowRange(range
);
546 /* Range of trace1 should not have changed */
547 TmfTimeRange expectedRange
= getInitialRange(trace1
);
548 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
549 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
550 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
552 /* Range of trace2 should not have changed */
554 expectedRange
= getInitialRange(trace2
);
555 curRange
= tm
.getCurrentTraceContext().getWindowRange();
556 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
557 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
560 // ------------------------------------------------------------------------
561 // Test an experiment
562 // ------------------------------------------------------------------------
565 * Test in an experiment when we select a timestamp that is part of one of
566 * the experiment's traces.
568 * The experiment's current time should be correctly updated.
571 public void testExperimentTimestampInTrace() {
572 TmfExperiment exp
= createExperiment(trace1
, trace2
);
574 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
577 /* The experiment's current time should be updated. */
578 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
579 assertEquals(ts
, selection
.getStartTime());
580 assertEquals(ts
, selection
.getEndTime());
584 * Test in an experiment when we select a timestamp that is between two
585 * traces in the experiment.
587 * The experiment's current time should still be updated, since the
588 * timestamp is valid in the experiment itself.
591 public void testExperimentTimestampInBetween() {
592 TmfExperiment exp
= createExperiment(trace1
, trace2
);
594 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
597 /* The experiment's current time should be updated. */
598 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
599 assertEquals(ts
, selection
.getStartTime());
600 assertEquals(ts
, selection
.getEndTime());
604 * Test in an experiment when we select a timestamp that is outside of the
605 * total range of the experiment.
607 * The experiment's current time should not be updated.
610 public void testExperimentTimestampInvalid() {
611 TmfExperiment exp
= createExperiment(trace1
, trace2
);
613 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
616 /* The experiment's current time should NOT be updated. */
617 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
618 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
619 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
623 * Test the initial range of an experiment.
626 public void testExperimentInitialRange() {
627 TmfExperiment exp
= createExperiment(trace1
, trace2
);
630 * The initial range should be == to the initial range of the earliest
631 * trace (here trace1).
633 final TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
635 assertEquals(getInitialRange(trace1
), actualRange
);
636 assertEquals(getInitialRange(exp
), actualRange
);
640 * Test the range clamping with the start time of the range outside of the
641 * earliest trace's range. Only that start time should get clamped.
644 public void testExperimentRangeClampingOne() {
645 TmfExperiment exp
= createExperiment(trace1
, trace2
);
648 final TmfTimeRange range
= new TmfTimeRange(
649 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
650 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
651 selectWindowRange(range
);
653 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
654 assertEquals(t1start
, actualRange
.getStartTime().getValue());
655 assertEquals(t1end
- ONE_SECOND
, actualRange
.getEndTime().getValue());
659 * Test the range clamping when both the start and end times of the signal's
660 * range are outside of the trace's range. The range should clamp to the
661 * experiment's range.
664 public void testExperimentRangeClampingBoth() {
665 TmfExperiment exp
= createExperiment(trace1
, trace2
);
668 final TmfTimeRange range
= new TmfTimeRange(
669 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
670 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
));
671 selectWindowRange(range
);
673 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
674 assertEquals(t1start
, actualRange
.getStartTime().getValue());
675 assertEquals(t2end
, actualRange
.getEndTime().getValue());
679 * Test selecting a range in-between two disjoint traces in an experiment.
680 * The range should still get correctly selected, even if no trace has any
681 * events in that range.
684 public void testExperimentRangeInBetween() {
685 TmfExperiment exp
= createExperiment(trace1
, trace2
);
688 final TmfTimeRange range
= new TmfTimeRange(
689 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
690 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
));
691 selectWindowRange(range
);
693 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
694 assertEquals(range
, actualRange
);
697 // ------------------------------------------------------------------------
699 // ------------------------------------------------------------------------
701 private static TmfExperiment
createExperiment(ITmfTrace t1
, ITmfTrace t2
) {
702 ITmfTrace
[] traces
= new ITmfTrace
[] { t1
, t2
};
703 TmfExperiment exp
= new TmfExperiment(ITmfEvent
.class, "test-exp", traces
,
704 TmfExperiment
.DEFAULT_INDEX_PAGE_SIZE
, null);
705 exp
.indexTrace(true);
706 // Deregister experiment from signal manager so that it doesn't
707 // interfere with the TmfTraceManager tests
708 TmfSignalManager
.deregister(exp
);
712 private static TmfTimeRange
getInitialRange(ITmfTrace trace
) {
713 return new TmfTimeRange(
714 trace
.getStartTime(),
715 calculateOffset(trace
.getStartTime(), trace
.getInitialRangeOffset()));
719 * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
721 private static @NonNull ITmfTimestamp
calculateOffset(ITmfTimestamp initialTs
, ITmfTimestamp offsetTs
) {
722 long start
= initialTs
.normalize(0, SCALE
).getValue();
723 long offset
= offsetTs
.normalize(0, SCALE
).getValue();
724 return new TmfTimestamp(start
+ offset
, SCALE
);