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
;
24 import java
.util
.concurrent
.TimeUnit
;
26 import org
.eclipse
.jdt
.annotation
.NonNull
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
28 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfWindowRangeUpdatedSignal
;
29 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSignalManager
;
30 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfSelectionRangeUpdatedSignal
;
31 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceClosedSignal
;
32 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
33 import org
.eclipse
.tracecompass
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
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
.CtfTmfTestTrace
;
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 assumeTrue(CtfTmfTestTrace
.TRACE2
.exists());
85 assumeTrue(CtfTmfTestTrace
.KERNEL
.exists());
86 trace1
= CtfTmfTestTrace
.TRACE2
.getTrace();
87 trace2
= CtfTmfTestTrace
.KERNEL
.getTrace();
89 trace1
.indexTrace(true);
90 trace2
.indexTrace(true);
92 // Deregister traces from signal manager so that they don't
93 // interfere with the TmfTraceManager tests
94 TmfSignalManager
.deregister(trace1
);
95 TmfSignalManager
.deregister(trace2
);
102 public void setUp() {
103 tm
= TmfTraceManager
.getInstance();
110 public void tearDown() {
111 while (tm
.getActiveTrace() != null) {
112 closeTrace(tm
.getActiveTrace());
117 * Test class clean-up
120 public static void tearDownClass() {
121 CtfTmfTestTrace
.TRACE2
.dispose();
122 CtfTmfTestTrace
.KERNEL
.dispose();
125 // ------------------------------------------------------------------------
126 // Dummy actions (fake signals)
127 // ------------------------------------------------------------------------
129 private void openTrace(ITmfTrace trace
) {
131 throw new IllegalArgumentException();
133 TmfSignalManager
.dispatchSignal(new TmfTraceOpenedSignal(this, trace
, null));
137 private void closeTrace(ITmfTrace trace
) {
139 throw new IllegalArgumentException();
141 TmfSignalManager
.dispatchSignal(new TmfTraceClosedSignal(this, trace
));
143 * In TMF, the next tab would now be selected (if there are some), which
144 * would select another trace automatically.
146 if (tm
.getOpenedTraces().size() > 0) {
147 selectTrace(tm
.getOpenedTraces().toArray(new ITmfTrace
[0])[0]);
151 private void selectTrace(ITmfTrace trace
) {
152 TmfSignalManager
.dispatchSignal(new TmfTraceSelectedSignal(this, trace
));
155 private void selectTimestamp(@NonNull ITmfTimestamp ts
) {
156 TmfSignalManager
.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, ts
));
159 private void selectWindowRange(TmfTimeRange tr
) {
160 TmfSignalManager
.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, tr
));
163 // ------------------------------------------------------------------------
165 // ------------------------------------------------------------------------
168 * Test that the manager is correctly initialized
171 public void testInitialize() {
172 TmfTraceManager mgr
= TmfTraceManager
.getInstance();
178 * Test the contents of a trace set with one trace.
181 public void testTraceSet() {
186 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace2
);
187 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
189 assertEquals(1, actual
.size());
190 assertEquals(expected
, actual
);
194 * Test the contents of a trace set with an experiment.
197 public void testTraceSetExperiment() {
198 TmfExperiment exp
= createExperiment(trace1
, trace2
);
202 Collection
<ITmfTrace
> expected
= ImmutableSet
.of(trace1
, trace2
);
203 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
205 assertEquals(2, actual
.size());
206 assertEquals(expected
, actual
);
210 * Test the contents of the complete trace set.
213 public void testTraceSetWithExperiment() {
214 /* Test with a trace */
215 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace1
);
216 Collection
<ITmfTrace
> actual
= TmfTraceManager
.getTraceSetWithExperiment(trace1
);
217 assertEquals(1, actual
.size());
218 assertEquals(expected
, actual
);
220 /* Test with an experiment */
221 TmfExperiment exp
= createExperiment(trace1
, trace2
);
222 expected
= ImmutableSet
.of(trace1
, trace2
, exp
);
223 actual
= TmfTraceManager
.getTraceSetWithExperiment(exp
);
224 assertEquals(3, actual
.size());
225 assertEquals(expected
, actual
);
229 * Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
232 public void testSupplementaryFileDir() {
233 String name1
= trace1
.getName();
234 String name2
= trace2
.getName();
235 String basePath
= TmfTraceManager
.getTemporaryDirPath() + File
.separator
;
237 String expected1
= basePath
+ name1
+ File
.separator
;
238 String expected2
= basePath
+ name2
+ File
.separator
;
240 assertEquals(expected1
, TmfTraceManager
.getSupplementaryFileDir(trace1
));
241 assertEquals(expected2
, TmfTraceManager
.getSupplementaryFileDir(trace2
));
244 // ------------------------------------------------------------------------
245 // Test a single trace
246 // ------------------------------------------------------------------------
249 * Test the initial range of a single trace.
252 public void testTraceInitialRange() {
254 final TmfTimeRange expectedRange
= new TmfTimeRange(
255 trace2
.getStartTime(),
256 calculateOffset(trace2
.getStartTime(), trace2
.getInitialRangeOffset()));
257 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
258 assertEquals(expectedRange
, actualRange
);
262 * Try selecting a timestamp contained inside the trace's range. The trace's
263 * current time should get updated correctly.
266 public void testNewTimestamp() {
268 ITmfTimestamp ts
= new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
);
271 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
272 assertEquals(ts
, selection
.getStartTime());
273 assertEquals(ts
, selection
.getEndTime());
277 * Try selecting a timestamp happening before the trace's start. The change
281 public void testTimestampBefore() {
283 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
284 ITmfTimestamp ts
= new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
);
287 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
288 assertEquals(beforeTr
, selection
);
292 * Try selecting a timestamp happening after the trace's end. The change
296 public void testTimestampAfter() {
298 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
299 ITmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
302 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
303 assertEquals(beforeTr
, selection
);
307 * Test selecting a normal sub-range of a single trace.
310 public void testTraceNewTimeRange() {
312 TmfTimeRange range
= new TmfTimeRange(
313 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
314 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
315 selectWindowRange(range
);
317 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
318 assertEquals(range
, curRange
);
322 * Test selecting a range whose start time is before the trace's start time.
323 * The selected range should get clamped to the trace's range.
326 public void testTraceTimeRangeClampingStart() {
328 TmfTimeRange range
= new TmfTimeRange(
329 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
330 new TmfTimestamp(t2end
- ONE_SECOND
, SCALE
));
331 selectWindowRange(range
);
333 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
334 assertEquals(t2start
, curRange
.getStartTime().getValue());
335 assertEquals(range
.getEndTime(), curRange
.getEndTime());
339 * Test selecting a range whose end time is after the trace's end time.
340 * The selected range should get clamped to the trace's range.
343 public void testTraceTimeRangeClampingEnd() {
345 TmfTimeRange range
= new TmfTimeRange(
346 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
),
347 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
348 selectWindowRange(range
);
350 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
351 assertEquals(range
.getStartTime(), curRange
.getStartTime());
352 assertEquals(t2end
, curRange
.getEndTime().getValue());
356 * Test selecting a range whose both start and end times are outside of the
357 * trace's range. The selected range should get clamped to the trace's
361 public void testTraceTimeRangeClampingBoth() {
363 TmfTimeRange range
= new TmfTimeRange(
364 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
), // minus here
365 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
)); // plus here
366 selectWindowRange(range
);
368 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
369 assertEquals(t2start
, curRange
.getStartTime().getValue());
370 assertEquals(t2end
, curRange
.getEndTime().getValue());
373 // ------------------------------------------------------------------------
374 // Test multiple, non-overlapping traces in parallel
375 // ------------------------------------------------------------------------
378 * Test, with two traces in parallel, when we select a timestamp that is
379 * part of the first trace.
381 * The first trace's timestamp should be updated, but the second trace's one
385 public void testTwoTracesTimestampValid() {
389 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
392 /* Timestamp of trace1 should have been updated */
393 TmfTraceContext ctx
= tm
.getCurrentTraceContext();
394 assertEquals(ts
, ctx
.getSelectionRange().getStartTime());
395 assertEquals(ts
, ctx
.getSelectionRange().getEndTime());
397 /* Timestamp of trace2 should not have changed */
399 ctx
= tm
.getCurrentTraceContext();
400 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getStartTime());
401 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getEndTime());
405 * Test, with two traces in parallel, when we select a timestamp that is
406 * between two traces.
408 * None of the trace's timestamps should be updated (we are not in an
412 public void testTwoTracesTimestampInBetween() {
416 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
419 /* Timestamp of trace1 should not have changed */
420 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
421 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
422 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
424 /* Timestamp of trace2 should not have changed */
426 selection
= tm
.getCurrentTraceContext().getSelectionRange();
427 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
428 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
432 * Test, with two traces in parallel, when we select a timestamp that is
433 * completely out of the trace's range.
435 * None of the trace's timestamps should be updated.
438 public void testTwoTracesTimestampInvalid() {
442 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
445 /* Timestamp of trace1 should not have changed */
446 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
447 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
448 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
450 /* Timestamp of trace2 should not have changed */
452 selection
= tm
.getCurrentTraceContext().getSelectionRange();
453 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
454 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
458 * Test, with two traces opened in parallel (not in an experiment), if we
459 * select a time range valid in one of them. That trace's time range should
460 * be updated, but not the other one.
463 public void testTwoTracesTimeRangeAllInOne() {
467 TmfTimeRange range
= new TmfTimeRange(
468 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
469 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
470 selectWindowRange(range
);
472 /* Range of trace1 should be equal to the requested one */
473 assertEquals(range
, tm
.getCurrentTraceContext().getWindowRange());
475 /* The range of trace 2 should not have changed */
477 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
481 * Test, with two traces in parallel, when we select a time range that is
482 * only partially valid for one of the traces.
484 * The first trace's time range should be clamped to a valid range, and the
485 * second one's should not change.
488 public void testTwoTracesTimeRangePartiallyInOne() {
492 TmfTimeRange range
= new TmfTimeRange(
493 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
494 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
));
495 selectWindowRange(range
);
497 /* Range of trace1 should get clamped to its end time */
498 TmfTimeRange expectedRange
= new TmfTimeRange(
499 new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
),
500 new TmfTimestamp(t1end
, SCALE
));
501 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
503 /* Range of trace2 should not have changed */
505 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
509 * Test, with two traces in parallel, when we select a time range that is
510 * only partially valid for both traces.
512 * Each trace's time range should get clamped to respectively valid ranges.
515 public void testTwoTracesTimeRangeInBoth() {
519 TmfTimeRange range
= new TmfTimeRange(
520 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
521 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
522 selectWindowRange(range
);
524 /* Range of trace1 should be clamped to its end time */
525 TmfTimeRange expectedRange
= new TmfTimeRange(
526 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
),
527 new TmfTimestamp(t1end
, SCALE
));
528 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
530 /* Range of trace2 should be clamped to its start time */
532 expectedRange
= new TmfTimeRange(
533 new TmfTimestamp(t2start
, SCALE
),
534 new TmfTimestamp(t2start
+ ONE_SECOND
, SCALE
));
535 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
539 * Test, with two traces in parallel, when we select a time range that is
540 * not valid for any trace.
542 * Each trace's time range should not be modified.
545 public void testTwoTracesTimeRangeInBetween() {
549 TmfTimeRange range
= new TmfTimeRange(
550 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
551 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
552 selectWindowRange(range
);
554 /* Range of trace1 should not have changed */
555 TmfTimeRange expectedRange
= getInitialRange(trace1
);
556 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
557 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
558 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
560 /* Range of trace2 should not have changed */
562 expectedRange
= getInitialRange(trace2
);
563 curRange
= tm
.getCurrentTraceContext().getWindowRange();
564 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
565 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
568 // ------------------------------------------------------------------------
569 // Test an experiment
570 // ------------------------------------------------------------------------
573 * Test in an experiment when we select a timestamp that is part of one of
574 * the experiment's traces.
576 * The experiment's current time should be correctly updated.
579 public void testExperimentTimestampInTrace() {
580 TmfExperiment exp
= createExperiment(trace1
, trace2
);
582 TmfTimestamp ts
= new TmfTimestamp(t1start
+ ONE_SECOND
, SCALE
);
585 /* The experiment's current time should be updated. */
586 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
587 assertEquals(ts
, selection
.getStartTime());
588 assertEquals(ts
, selection
.getEndTime());
592 * Test in an experiment when we select a timestamp that is between two
593 * traces in the experiment.
595 * The experiment's current time should still be updated, since the
596 * timestamp is valid in the experiment itself.
599 public void testExperimentTimestampInBetween() {
600 TmfExperiment exp
= createExperiment(trace1
, trace2
);
602 TmfTimestamp ts
= new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
);
605 /* The experiment's current time should be updated. */
606 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
607 assertEquals(ts
, selection
.getStartTime());
608 assertEquals(ts
, selection
.getEndTime());
612 * Test in an experiment when we select a timestamp that is outside of the
613 * total range of the experiment.
615 * The experiment's current time should not be updated.
618 public void testExperimentTimestampInvalid() {
619 TmfExperiment exp
= createExperiment(trace1
, trace2
);
621 TmfTimestamp ts
= new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
);
624 /* The experiment's current time should NOT be updated. */
625 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
626 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
627 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
631 * Test the initial range of an experiment.
634 public void testExperimentInitialRange() {
635 TmfExperiment exp
= createExperiment(trace1
, trace2
);
638 * The initial range should be == to the initial range of the earliest
639 * trace (here trace1).
641 final TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
643 assertEquals(getInitialRange(trace1
), actualRange
);
644 assertEquals(getInitialRange(exp
), actualRange
);
648 * Test the range clamping with the start time of the range outside of the
649 * earliest trace's range. Only that start time should get clamped.
652 public void testExperimentRangeClampingOne() {
653 TmfExperiment exp
= createExperiment(trace1
, trace2
);
656 final TmfTimeRange range
= new TmfTimeRange(
657 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
658 new TmfTimestamp(t1end
- ONE_SECOND
, SCALE
));
659 selectWindowRange(range
);
661 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
662 assertEquals(t1start
, actualRange
.getStartTime().getValue());
663 assertEquals(t1end
- ONE_SECOND
, actualRange
.getEndTime().getValue());
667 * Test the range clamping when both the start and end times of the signal's
668 * range are outside of the trace's range. The range should clamp to the
669 * experiment's range.
672 public void testExperimentRangeClampingBoth() {
673 TmfExperiment exp
= createExperiment(trace1
, trace2
);
676 final TmfTimeRange range
= new TmfTimeRange(
677 new TmfTimestamp(t1start
- ONE_SECOND
, SCALE
),
678 new TmfTimestamp(t2end
+ ONE_SECOND
, SCALE
));
679 selectWindowRange(range
);
681 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
682 assertEquals(t1start
, actualRange
.getStartTime().getValue());
683 assertEquals(t2end
, actualRange
.getEndTime().getValue());
687 * Test selecting a range in-between two disjoint traces in an experiment.
688 * The range should still get correctly selected, even if no trace has any
689 * events in that range.
692 public void testExperimentRangeInBetween() {
693 TmfExperiment exp
= createExperiment(trace1
, trace2
);
696 final TmfTimeRange range
= new TmfTimeRange(
697 new TmfTimestamp(t1end
+ ONE_SECOND
, SCALE
),
698 new TmfTimestamp(t2start
- ONE_SECOND
, SCALE
));
699 selectWindowRange(range
);
701 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
702 assertEquals(range
, actualRange
);
705 // ------------------------------------------------------------------------
707 // ------------------------------------------------------------------------
709 private static TmfExperiment
createExperiment(ITmfTrace t1
, ITmfTrace t2
) {
710 ITmfTrace
[] traces
= new ITmfTrace
[] { t1
, t2
};
711 TmfExperiment exp
= new TmfExperiment(ITmfEvent
.class, "test-exp", traces
,
712 TmfExperiment
.DEFAULT_INDEX_PAGE_SIZE
, null);
713 exp
.indexTrace(true);
714 // Deregister experiment from signal manager so that it doesn't
715 // interfere with the TmfTraceManager tests
716 TmfSignalManager
.deregister(exp
);
720 private static TmfTimeRange
getInitialRange(ITmfTrace trace
) {
721 return new TmfTimeRange(
722 trace
.getStartTime(),
723 calculateOffset(trace
.getStartTime(), trace
.getInitialRangeOffset()));
727 * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
729 private static @NonNull ITmfTimestamp
calculateOffset(ITmfTimestamp initialTs
, ITmfTimestamp offsetTs
) {
730 long start
= initialTs
.normalize(0, SCALE
).getValue();
731 long offset
= offsetTs
.normalize(0, SCALE
).getValue();
732 return new TmfTimestamp(start
+ offset
, SCALE
);