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
;
21 import java
.util
.Collection
;
22 import java
.util
.Collections
;
23 import java
.util
.concurrent
.TimeUnit
;
25 import org
.eclipse
.jdt
.annotation
.NonNull
;
26 import org
.eclipse
.tracecompass
.testtraces
.ctf
.CtfTestTrace
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSelectionRangeUpdatedSignal
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
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
.signal
.TmfWindowRangeUpdatedSignal
;
34 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
35 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
36 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
37 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
38 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceContext
;
39 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
40 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.experiment
.TmfExperiment
;
41 import org
.eclipse
.tracecompass
.tmf
.ctf
.core
.tests
.shared
.CtfTmfTestTraceUtils
;
42 import org
.junit
.After
;
43 import org
.junit
.AfterClass
;
44 import org
.junit
.Before
;
45 import org
.junit
.BeforeClass
;
46 import org
.junit
.Rule
;
47 import org
.junit
.Test
;
48 import org
.junit
.rules
.TestRule
;
49 import org
.junit
.rules
.Timeout
;
51 import com
.google
.common
.collect
.ImmutableSet
;
54 * Test suite for the {@link TmfTraceManager}.
56 * @author Alexandre Montplaisir
58 public class TmfTraceManagerTest
{
60 /** Time-out tests after 20 seconds */
62 public TestRule globalTimeout
= new Timeout(20, TimeUnit
.SECONDS
);
64 private static final int SCALE
= ITmfTimestamp
.NANOSECOND_SCALE
;
66 private static ITmfTrace trace1
;
67 private static final long t1start
= 1331668247314038062L;
68 private static final long t1end
= 1331668259054285979L;
70 private static ITmfTrace trace2
;
71 private static final long t2start
= 1332170682440133097L;
72 private static final long t2end
= 1332170692664579801L;
74 private static final long ONE_SECOND
= 1000000000L;
76 private TmfTraceManager tm
;
80 * Test class initialization
83 public static void setUpClass() {
84 trace1
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.TRACE2
);
85 trace2
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.KERNEL
);
87 trace1
.indexTrace(true);
88 trace2
.indexTrace(true);
90 // Deregister traces from signal manager so that they don't
91 // interfere with the TmfTraceManager tests
92 TmfSignalManager
.deregister(trace1
);
93 TmfSignalManager
.deregister(trace2
);
100 public void setUp() {
101 tm
= TmfTraceManager
.getInstance();
108 public void tearDown() {
109 while (tm
.getActiveTrace() != null) {
110 closeTrace(tm
.getActiveTrace());
115 * Test class clean-up
118 public static void tearDownClass() {
119 CtfTmfTestTraceUtils
.dispose(CtfTestTrace
.TRACE2
);
120 CtfTmfTestTraceUtils
.dispose(CtfTestTrace
.KERNEL
);
123 // ------------------------------------------------------------------------
124 // Dummy actions (fake signals)
125 // ------------------------------------------------------------------------
127 private void openTrace(ITmfTrace trace
) {
129 throw new IllegalArgumentException();
131 TmfSignalManager
.dispatchSignal(new TmfTraceOpenedSignal(this, trace
, null));
135 private void closeTrace(ITmfTrace trace
) {
137 throw new IllegalArgumentException();
139 TmfSignalManager
.dispatchSignal(new TmfTraceClosedSignal(this, trace
));
141 * In TMF, the next tab would now be selected (if there are some), which
142 * would select another trace automatically.
144 if (tm
.getOpenedTraces().size() > 0) {
145 selectTrace(tm
.getOpenedTraces().toArray(new ITmfTrace
[0])[0]);
149 private void selectTrace(ITmfTrace trace
) {
150 TmfSignalManager
.dispatchSignal(new TmfTraceSelectedSignal(this, trace
));
153 private void selectTimestamp(@NonNull ITmfTimestamp ts
) {
154 TmfSignalManager
.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, ts
));
157 private void selectWindowRange(TmfTimeRange tr
) {
158 TmfSignalManager
.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, tr
));
161 // ------------------------------------------------------------------------
163 // ------------------------------------------------------------------------
166 * Test that the manager is correctly initialized
169 public void testInitialize() {
170 TmfTraceManager mgr
= TmfTraceManager
.getInstance();
176 * Test the contents of a trace set with one trace.
179 public void testTraceSet() {
184 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace2
);
185 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
187 assertEquals(1, actual
.size());
188 assertEquals(expected
, actual
);
192 * Test the contents of a trace set with an experiment.
195 public void testTraceSetExperiment() {
196 TmfExperiment exp
= createExperiment(trace1
, trace2
);
200 Collection
<ITmfTrace
> expected
= ImmutableSet
.of(trace1
, trace2
);
201 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
203 assertEquals(2, actual
.size());
204 assertEquals(expected
, actual
);
208 * Test the contents of the complete trace set.
211 public void testTraceSetWithExperiment() {
212 /* Test with a trace */
213 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace1
);
214 Collection
<ITmfTrace
> actual
= TmfTraceManager
.getTraceSetWithExperiment(trace1
);
215 assertEquals(1, actual
.size());
216 assertEquals(expected
, actual
);
218 /* Test with an experiment */
219 TmfExperiment exp
= createExperiment(trace1
, trace2
);
220 expected
= ImmutableSet
.of(trace1
, trace2
, exp
);
221 actual
= TmfTraceManager
.getTraceSetWithExperiment(exp
);
222 assertEquals(3, actual
.size());
223 assertEquals(expected
, actual
);
227 * Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
230 public void testSupplementaryFileDir() {
231 String name1
= trace1
.getName();
232 String name2
= trace2
.getName();
233 String basePath
= TmfTraceManager
.getTemporaryDirPath() + File
.separator
;
235 String expected1
= basePath
+ name1
+ File
.separator
;
236 String expected2
= basePath
+ name2
+ File
.separator
;
238 assertEquals(expected1
, TmfTraceManager
.getSupplementaryFileDir(trace1
));
239 assertEquals(expected2
, TmfTraceManager
.getSupplementaryFileDir(trace2
));
242 // ------------------------------------------------------------------------
243 // Test a single trace
244 // ------------------------------------------------------------------------
247 * Test the initial range of a single trace.
250 public void testTraceInitialRange() {
252 final TmfTimeRange expectedRange
= new TmfTimeRange(
253 trace2
.getStartTime(),
254 calculateOffset(trace2
.getStartTime(), trace2
.getInitialRangeOffset()));
255 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
256 assertEquals(expectedRange
, actualRange
);
260 * Try selecting a timestamp contained inside the trace's range. The trace's
261 * current time should get updated correctly.
264 public void testNewTimestamp() {
266 ITmfTimestamp ts
= new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
);
269 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
270 assertEquals(ts
, selection
.getStartTime());
271 assertEquals(ts
, selection
.getEndTime());
275 * Try selecting a timestamp happening before the trace's start. The change
279 public void testTimestampBefore() {
281 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
282 ITmfTimestamp ts
= new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
);
285 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
286 assertEquals(beforeTr
, selection
);
290 * Try selecting a timestamp happening after the trace's end. The change
294 public void testTimestampAfter() {
296 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
297 ITmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
300 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
301 assertEquals(beforeTr
, selection
);
305 * Test selecting a normal sub-range of a single trace.
308 public void testTraceNewTimeRange() {
310 TmfTimeRange range
= new TmfTimeRange(
311 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
312 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
313 selectWindowRange(range
);
315 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
316 assertEquals(range
, curRange
);
320 * Test selecting a range whose start time is before the trace's start time.
321 * The selected range should get clamped to the trace's range.
324 public void testTraceTimeRangeClampingStart() {
326 TmfTimeRange range
= new TmfTimeRange(
327 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
328 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
329 selectWindowRange(range
);
331 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
332 assertEquals(t2start
, curRange
.getStartTime().getValue());
333 assertEquals(range
.getEndTime(), curRange
.getEndTime());
337 * Test selecting a range whose end time is after the trace's end time.
338 * The selected range should get clamped to the trace's range.
341 public void testTraceTimeRangeClampingEnd() {
343 TmfTimeRange range
= new TmfTimeRange(
344 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
345 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
346 selectWindowRange(range
);
348 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
349 assertEquals(range
.getStartTime(), curRange
.getStartTime());
350 assertEquals(t2end
, curRange
.getEndTime().getValue());
354 * Test selecting a range whose both start and end times are outside of the
355 * trace's range. The selected range should get clamped to the trace's
359 public void testTraceTimeRangeClampingBoth() {
361 TmfTimeRange range
= new TmfTimeRange(
362 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
363 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
364 selectWindowRange(range
);
366 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
367 assertEquals(t2start
, curRange
.getStartTime().getValue());
368 assertEquals(t2end
, curRange
.getEndTime().getValue());
371 // ------------------------------------------------------------------------
372 // Test multiple, non-overlapping traces in parallel
373 // ------------------------------------------------------------------------
376 * Test, with two traces in parallel, when we select a timestamp that is
377 * part of the first trace.
379 * The first trace's timestamp should be updated, but the second trace's one
383 public void testTwoTracesTimestampValid() {
387 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
390 /* Timestamp of trace1 should have been updated */
391 TmfTraceContext ctx
= tm
.getCurrentTraceContext();
392 assertEquals(ts
, ctx
.getSelectionRange().getStartTime());
393 assertEquals(ts
, ctx
.getSelectionRange().getEndTime());
395 /* Timestamp of trace2 should not have changed */
397 ctx
= tm
.getCurrentTraceContext();
398 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getStartTime());
399 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getEndTime());
403 * Test, with two traces in parallel, when we select a timestamp that is
404 * between two traces.
406 * None of the trace's timestamps should be updated (we are not in an
410 public void testTwoTracesTimestampInBetween() {
414 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
417 /* Timestamp of trace1 should not have changed */
418 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
419 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
420 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
422 /* Timestamp of trace2 should not have changed */
424 selection
= tm
.getCurrentTraceContext().getSelectionRange();
425 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
426 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
430 * Test, with two traces in parallel, when we select a timestamp that is
431 * completely out of the trace's range.
433 * None of the trace's timestamps should be updated.
436 public void testTwoTracesTimestampInvalid() {
440 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
443 /* Timestamp of trace1 should not have changed */
444 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
445 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
446 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
448 /* Timestamp of trace2 should not have changed */
450 selection
= tm
.getCurrentTraceContext().getSelectionRange();
451 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
452 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
456 * Test, with two traces opened in parallel (not in an experiment), if we
457 * select a time range valid in one of them. That trace's time range should
458 * be updated, but not the other one.
461 public void testTwoTracesTimeRangeAllInOne() {
465 TmfTimeRange range
= new TmfTimeRange(
466 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
467 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
468 selectWindowRange(range
);
470 /* Range of trace1 should be equal to the requested one */
471 assertEquals(range
, tm
.getCurrentTraceContext().getWindowRange());
473 /* The range of trace 2 should not have changed */
475 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
479 * Test, with two traces in parallel, when we select a time range that is
480 * only partially valid for one of the traces.
482 * The first trace's time range should be clamped to a valid range, and the
483 * second one's should not change.
486 public void testTwoTracesTimeRangePartiallyInOne() {
490 TmfTimeRange range
= new TmfTimeRange(
491 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
492 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
));
493 selectWindowRange(range
);
495 /* Range of trace1 should get clamped to its end time */
496 TmfTimeRange expectedRange
= new TmfTimeRange(
497 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
498 new TmfTimestamp(t1end
, SCALE
));
499 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
501 /* Range of trace2 should not have changed */
503 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
507 * Test, with two traces in parallel, when we select a time range that is
508 * only partially valid for both traces.
510 * Each trace's time range should get clamped to respectively valid ranges.
513 public void testTwoTracesTimeRangeInBoth() {
517 TmfTimeRange range
= new TmfTimeRange(
518 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
519 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
520 selectWindowRange(range
);
522 /* Range of trace1 should be clamped to its end time */
523 TmfTimeRange expectedRange
= new TmfTimeRange(
524 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
525 new TmfTimestamp(t1end
, SCALE
));
526 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
528 /* Range of trace2 should be clamped to its start time */
530 expectedRange
= new TmfTimeRange(
531 new TmfTimestamp(t2start
, SCALE
),
532 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
533 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
537 * Test, with two traces in parallel, when we select a time range that is
538 * not valid for any trace.
540 * Each trace's time range should not be modified.
543 public void testTwoTracesTimeRangeInBetween() {
547 TmfTimeRange range
= new TmfTimeRange(
548 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
549 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
550 selectWindowRange(range
);
552 /* Range of trace1 should not have changed */
553 TmfTimeRange expectedRange
= getInitialRange(trace1
);
554 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
555 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
556 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
558 /* Range of trace2 should not have changed */
560 expectedRange
= getInitialRange(trace2
);
561 curRange
= tm
.getCurrentTraceContext().getWindowRange();
562 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
563 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
566 // ------------------------------------------------------------------------
567 // Test an experiment
568 // ------------------------------------------------------------------------
571 * Test in an experiment when we select a timestamp that is part of one of
572 * the experiment's traces.
574 * The experiment's current time should be correctly updated.
577 public void testExperimentTimestampInTrace() {
578 TmfExperiment exp
= createExperiment(trace1
, trace2
);
580 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
583 /* The experiment's current time should be updated. */
584 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
585 assertEquals(ts
, selection
.getStartTime());
586 assertEquals(ts
, selection
.getEndTime());
590 * Test in an experiment when we select a timestamp that is between two
591 * traces in the experiment.
593 * The experiment's current time should still be updated, since the
594 * timestamp is valid in the experiment itself.
597 public void testExperimentTimestampInBetween() {
598 TmfExperiment exp
= createExperiment(trace1
, trace2
);
600 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
603 /* The experiment's current time should be updated. */
604 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
605 assertEquals(ts
, selection
.getStartTime());
606 assertEquals(ts
, selection
.getEndTime());
610 * Test in an experiment when we select a timestamp that is outside of the
611 * total range of the experiment.
613 * The experiment's current time should not be updated.
616 public void testExperimentTimestampInvalid() {
617 TmfExperiment exp
= createExperiment(trace1
, trace2
);
619 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
622 /* The experiment's current time should NOT be updated. */
623 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
624 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
625 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
629 * Test the initial range of an experiment.
632 public void testExperimentInitialRange() {
633 TmfExperiment exp
= createExperiment(trace1
, trace2
);
636 * The initial range should be == to the initial range of the earliest
637 * trace (here trace1).
639 final TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
641 assertEquals(getInitialRange(trace1
), actualRange
);
642 assertEquals(getInitialRange(exp
), actualRange
);
646 * Test the range clamping with the start time of the range outside of the
647 * earliest trace's range. Only that start time should get clamped.
650 public void testExperimentRangeClampingOne() {
651 TmfExperiment exp
= createExperiment(trace1
, trace2
);
654 final TmfTimeRange range
= new TmfTimeRange(
655 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
656 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
657 selectWindowRange(range
);
659 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
660 assertEquals(t1start
, actualRange
.getStartTime().getValue());
661 assertEquals(t1end
- ONE_SECOND
, actualRange
.getEndTime().getValue());
665 * Test the range clamping when both the start and end times of the signal's
666 * range are outside of the trace's range. The range should clamp to the
667 * experiment's range.
670 public void testExperimentRangeClampingBoth() {
671 TmfExperiment exp
= createExperiment(trace1
, trace2
);
674 final TmfTimeRange range
= new TmfTimeRange(
675 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
676 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
));
677 selectWindowRange(range
);
679 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
680 assertEquals(t1start
, actualRange
.getStartTime().getValue());
681 assertEquals(t2end
, actualRange
.getEndTime().getValue());
685 * Test selecting a range in-between two disjoint traces in an experiment.
686 * The range should still get correctly selected, even if no trace has any
687 * events in that range.
690 public void testExperimentRangeInBetween() {
691 TmfExperiment exp
= createExperiment(trace1
, trace2
);
694 final TmfTimeRange range
= new TmfTimeRange(
695 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
696 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
));
697 selectWindowRange(range
);
699 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
700 assertEquals(range
, actualRange
);
703 // ------------------------------------------------------------------------
705 // ------------------------------------------------------------------------
707 private static TmfExperiment
createExperiment(ITmfTrace t1
, ITmfTrace t2
) {
708 ITmfTrace
[] traces
= new ITmfTrace
[] { t1
, t2
};
709 TmfExperiment exp
= new TmfExperiment(ITmfEvent
.class, "test-exp", traces
,
710 TmfExperiment
.DEFAULT_INDEX_PAGE_SIZE
, null);
711 exp
.indexTrace(true);
712 // Deregister experiment from signal manager so that it doesn't
713 // interfere with the TmfTraceManager tests
714 TmfSignalManager
.deregister(exp
);
718 private static TmfTimeRange
getInitialRange(ITmfTrace trace
) {
719 return new TmfTimeRange(
720 trace
.getStartTime(),
721 calculateOffset(trace
.getStartTime(), trace
.getInitialRangeOffset()));
725 * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
727 private static @NonNull ITmfTimestamp
calculateOffset(ITmfTimestamp initialTs
, ITmfTimestamp offsetTs
) {
728 long start
= initialTs
.normalize(0, SCALE
).getValue();
729 long offset
= offsetTs
.normalize(0, SCALE
).getValue();
730 return new TmfTimestamp(start
+ offset
, SCALE
);