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 1 minute. */
62 public TestRule globalTimeout
= new Timeout(1, TimeUnit
.MINUTES
);
64 private static ITmfTrace trace1
;
65 private static final long t1start
= 1331668247314038062L;
66 private static final long t1end
= 1331668259054285979L;
68 private static ITmfTrace trace2
;
69 private static final long t2start
= 1332170682440133097L;
70 private static final long t2end
= 1332170692664579801L;
72 private static final long ONE_SECOND
= 1000000000L;
74 private TmfTraceManager tm
;
77 * Test class initialization
80 public static void setUpClass() {
81 trace1
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.TRACE2
);
82 trace2
= CtfTmfTestTraceUtils
.getTrace(CtfTestTrace
.KERNEL
);
84 trace1
.indexTrace(true);
85 trace2
.indexTrace(true);
87 // Deregister traces from signal manager so that they don't
88 // interfere with the TmfTraceManager tests
89 TmfSignalManager
.deregister(trace1
);
90 TmfSignalManager
.deregister(trace2
);
98 tm
= TmfTraceManager
.getInstance();
105 public void tearDown() {
106 while (tm
.getActiveTrace() != null) {
107 closeTrace(tm
.getActiveTrace());
112 * Test class clean-up
115 public static void tearDownClass() {
116 CtfTmfTestTraceUtils
.dispose(CtfTestTrace
.TRACE2
);
117 CtfTmfTestTraceUtils
.dispose(CtfTestTrace
.KERNEL
);
120 // ------------------------------------------------------------------------
121 // Dummy actions (fake signals)
122 // ------------------------------------------------------------------------
124 private void openTrace(ITmfTrace trace
) {
126 throw new IllegalArgumentException();
128 TmfSignalManager
.dispatchSignal(new TmfTraceOpenedSignal(this, trace
, null));
132 private void closeTrace(ITmfTrace trace
) {
134 throw new IllegalArgumentException();
136 TmfSignalManager
.dispatchSignal(new TmfTraceClosedSignal(this, trace
));
138 * In TMF, the next tab would now be selected (if there are some), which
139 * would select another trace automatically.
141 if (tm
.getOpenedTraces().size() > 0) {
142 selectTrace(tm
.getOpenedTraces().toArray(new ITmfTrace
[0])[0]);
146 private void selectTrace(ITmfTrace trace
) {
147 TmfSignalManager
.dispatchSignal(new TmfTraceSelectedSignal(this, trace
));
150 private void selectTimestamp(@NonNull ITmfTimestamp ts
) {
151 TmfSignalManager
.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, ts
));
154 private void selectWindowRange(TmfTimeRange tr
) {
155 TmfSignalManager
.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, tr
));
158 // ------------------------------------------------------------------------
160 // ------------------------------------------------------------------------
163 * Test that the manager is correctly initialized
166 public void testInitialize() {
167 TmfTraceManager mgr
= TmfTraceManager
.getInstance();
173 * Test the contents of a trace set with one trace.
176 public void testTraceSet() {
181 Collection
<ITmfTrace
> expected
= Collections
.singleton(trace2
);
182 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
184 assertEquals(1, actual
.size());
185 assertEquals(expected
, actual
);
189 * Test the contents of a trace set with an experiment.
192 public void testTraceSetExperiment() {
193 final ITmfTrace localTrace1
= trace1
;
194 final ITmfTrace localTrace2
= trace2
;
195 assertNotNull(localTrace1
);
196 assertNotNull(localTrace2
);
197 TmfExperiment exp
= createExperiment(localTrace1
, localTrace2
);
198 openTrace(localTrace1
);
201 Collection
<ITmfTrace
> expected
= ImmutableSet
.of(localTrace1
, localTrace2
);
202 Collection
<ITmfTrace
> actual
= tm
.getActiveTraceSet();
204 assertEquals(2, actual
.size());
205 assertEquals(expected
, actual
);
209 * Test the contents of the complete trace set.
212 public void testTraceSetWithExperiment() {
213 final ITmfTrace localTrace1
= trace1
;
214 final ITmfTrace localTrace2
= trace2
;
215 assertNotNull(localTrace1
);
216 assertNotNull(localTrace2
);
217 /* Test with a trace */
218 Collection
<ITmfTrace
> expected
= Collections
.singleton(localTrace1
);
219 Collection
<ITmfTrace
> actual
= TmfTraceManager
.getTraceSetWithExperiment(localTrace1
);
220 assertEquals(1, actual
.size());
221 assertEquals(expected
, actual
);
223 /* Test with an experiment */
224 TmfExperiment exp
= createExperiment(localTrace1
, localTrace2
);
226 expected
= ImmutableSet
.of(localTrace1
, localTrace2
, exp
);
227 actual
= TmfTraceManager
.getTraceSetWithExperiment(exp
);
228 assertEquals(3, actual
.size());
229 assertEquals(expected
, actual
);
233 * Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
236 public void testSupplementaryFileDir() {
237 final ITmfTrace localTrace1
= trace1
;
238 final ITmfTrace localTrace2
= trace2
;
239 assertNotNull(localTrace1
);
240 assertNotNull(localTrace2
);
241 String name1
= localTrace1
.getName();
242 String name2
= localTrace2
.getName();
243 String basePath
= TmfTraceManager
.getTemporaryDirPath() + File
.separator
;
245 String expected1
= basePath
+ name1
+ File
.separator
;
246 String expected2
= basePath
+ name2
+ File
.separator
;
248 assertEquals(expected1
, TmfTraceManager
.getSupplementaryFileDir(localTrace1
));
249 assertEquals(expected2
, TmfTraceManager
.getSupplementaryFileDir(localTrace2
));
252 // ------------------------------------------------------------------------
253 // Test a single trace
254 // ------------------------------------------------------------------------
257 * Test the initial range of a single trace.
260 public void testTraceInitialRange() {
262 final TmfTimeRange expectedRange
= new TmfTimeRange(
263 trace2
.getStartTime(),
264 calculateOffset(trace2
.getStartTime(), trace2
.getInitialRangeOffset()));
265 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
266 assertEquals(expectedRange
, actualRange
);
270 * Try selecting a timestamp contained inside the trace's range. The trace's
271 * current time should get updated correctly.
274 public void testNewTimestamp() {
276 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t2start
+ ONE_SECOND
);
279 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
280 assertEquals(ts
, selection
.getStartTime());
281 assertEquals(ts
, selection
.getEndTime());
285 * Try selecting a timestamp happening before the trace's start. The change
289 public void testTimestampBefore() {
291 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
292 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t2start
- ONE_SECOND
);
295 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
296 assertEquals(beforeTr
, selection
);
300 * Try selecting a timestamp happening after the trace's end. The change
304 public void testTimestampAfter() {
306 TmfTimeRange beforeTr
= tm
.getCurrentTraceContext().getSelectionRange();
307 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
);
310 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
311 assertEquals(beforeTr
, selection
);
315 * Test selecting a normal sub-range of a single trace.
318 public void testTraceNewTimeRange() {
320 TmfTimeRange range
= new TmfTimeRange(
321 TmfTimestamp
.fromNanos(t2start
+ ONE_SECOND
),
322 TmfTimestamp
.fromNanos(t2end
- ONE_SECOND
));
323 selectWindowRange(range
);
325 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
326 assertEquals(range
, curRange
);
330 * Test selecting a range whose start time is before the trace's start time.
331 * The selected range should get clamped to the trace's range.
334 public void testTraceTimeRangeClampingStart() {
336 TmfTimeRange range
= new TmfTimeRange(
337 TmfTimestamp
.fromNanos(t2start
- ONE_SECOND
), // minus here
338 TmfTimestamp
.fromNanos(t2end
- ONE_SECOND
));
339 selectWindowRange(range
);
341 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
342 assertEquals(t2start
, curRange
.getStartTime().getValue());
343 assertEquals(range
.getEndTime(), curRange
.getEndTime());
347 * Test selecting a range whose end time is after the trace's end time. The
348 * selected range should get clamped to the trace's range.
351 public void testTraceTimeRangeClampingEnd() {
353 TmfTimeRange range
= new TmfTimeRange(
354 TmfTimestamp
.fromNanos(t2start
+ ONE_SECOND
),
355 TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
)); // plus here
356 selectWindowRange(range
);
358 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
359 assertEquals(range
.getStartTime(), curRange
.getStartTime());
360 assertEquals(t2end
, curRange
.getEndTime().getValue());
364 * Test selecting a range whose both start and end times are outside of the
365 * trace's range. The selected range should get clamped to the trace's
369 public void testTraceTimeRangeClampingBoth() {
371 TmfTimeRange range
= new TmfTimeRange(
372 TmfTimestamp
.fromNanos(t2start
- ONE_SECOND
), // minus here
373 TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
)); // plus here
374 selectWindowRange(range
);
376 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
377 assertEquals(t2start
, curRange
.getStartTime().getValue());
378 assertEquals(t2end
, curRange
.getEndTime().getValue());
381 // ------------------------------------------------------------------------
382 // Test multiple, non-overlapping traces in parallel
383 // ------------------------------------------------------------------------
386 * Test, with two traces in parallel, when we select a timestamp that is
387 * part of the first trace.
389 * The first trace's timestamp should be updated, but the second trace's one
393 public void testTwoTracesTimestampValid() {
397 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t1start
+ ONE_SECOND
);
400 /* Timestamp of trace1 should have been updated */
401 TmfTraceContext ctx
= tm
.getCurrentTraceContext();
402 assertEquals(ts
, ctx
.getSelectionRange().getStartTime());
403 assertEquals(ts
, ctx
.getSelectionRange().getEndTime());
405 /* Timestamp of trace2 should not have changed */
407 ctx
= tm
.getCurrentTraceContext();
408 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getStartTime());
409 assertEquals(trace2
.getStartTime(), ctx
.getSelectionRange().getEndTime());
413 * Test, with two traces in parallel, when we select a timestamp that is
414 * between two traces.
416 * None of the trace's timestamps should be updated (we are not in an
420 public void testTwoTracesTimestampInBetween() {
424 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t1end
+ ONE_SECOND
);
427 /* Timestamp of trace1 should not have changed */
428 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
429 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
430 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
432 /* Timestamp of trace2 should not have changed */
434 selection
= tm
.getCurrentTraceContext().getSelectionRange();
435 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
436 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
440 * Test, with two traces in parallel, when we select a timestamp that is
441 * completely out of the trace's range.
443 * None of the trace's timestamps should be updated.
446 public void testTwoTracesTimestampInvalid() {
450 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
);
453 /* Timestamp of trace1 should not have changed */
454 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
455 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
456 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
458 /* Timestamp of trace2 should not have changed */
460 selection
= tm
.getCurrentTraceContext().getSelectionRange();
461 assertEquals(trace2
.getStartTime(), selection
.getStartTime());
462 assertEquals(trace2
.getStartTime(), selection
.getEndTime());
466 * Test, with two traces opened in parallel (not in an experiment), if we
467 * select a time range valid in one of them. That trace's time range should
468 * be updated, but not the other one.
471 public void testTwoTracesTimeRangeAllInOne() {
475 TmfTimeRange range
= new TmfTimeRange(
476 TmfTimestamp
.fromNanos(t1start
+ ONE_SECOND
),
477 TmfTimestamp
.fromNanos(t1end
- ONE_SECOND
));
478 selectWindowRange(range
);
480 /* Range of trace1 should be equal to the requested one */
481 assertEquals(range
, tm
.getCurrentTraceContext().getWindowRange());
483 /* The range of trace 2 should not have changed */
485 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
489 * Test, with two traces in parallel, when we select a time range that is
490 * only partially valid for one of the traces.
492 * The first trace's time range should be clamped to a valid range, and the
493 * second one's should not change.
496 public void testTwoTracesTimeRangePartiallyInOne() {
500 TmfTimeRange range
= new TmfTimeRange(
501 TmfTimestamp
.fromNanos(t1start
+ ONE_SECOND
),
502 TmfTimestamp
.fromNanos(t1end
+ ONE_SECOND
));
503 selectWindowRange(range
);
505 /* Range of trace1 should get clamped to its end time */
506 TmfTimeRange expectedRange
= new TmfTimeRange(
507 TmfTimestamp
.fromNanos(t1start
+ ONE_SECOND
),
508 TmfTimestamp
.fromNanos(t1end
));
509 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
511 /* Range of trace2 should not have changed */
513 assertEquals(getInitialRange(trace2
), tm
.getCurrentTraceContext().getWindowRange());
517 * Test, with two traces in parallel, when we select a time range that is
518 * only partially valid for both traces.
520 * Each trace's time range should get clamped to respectively valid ranges.
523 public void testTwoTracesTimeRangeInBoth() {
527 TmfTimeRange range
= new TmfTimeRange(
528 TmfTimestamp
.fromNanos(t1end
- ONE_SECOND
),
529 TmfTimestamp
.fromNanos(t2start
+ ONE_SECOND
));
530 selectWindowRange(range
);
532 /* Range of trace1 should be clamped to its end time */
533 TmfTimeRange expectedRange
= new TmfTimeRange(
534 TmfTimestamp
.fromNanos(t1end
- ONE_SECOND
),
535 TmfTimestamp
.fromNanos(t1end
));
536 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
538 /* Range of trace2 should be clamped to its start time */
540 expectedRange
= new TmfTimeRange(
541 TmfTimestamp
.fromNanos(t2start
),
542 TmfTimestamp
.fromNanos(t2start
+ ONE_SECOND
));
543 assertEquals(expectedRange
, tm
.getCurrentTraceContext().getWindowRange());
547 * Test, with two traces in parallel, when we select a time range that is
548 * not valid for any trace.
550 * Each trace's time range should not be modified.
553 public void testTwoTracesTimeRangeInBetween() {
557 TmfTimeRange range
= new TmfTimeRange(
558 TmfTimestamp
.fromNanos(t1end
+ ONE_SECOND
),
559 TmfTimestamp
.fromNanos(t1end
- ONE_SECOND
));
560 selectWindowRange(range
);
562 /* Range of trace1 should not have changed */
563 TmfTimeRange expectedRange
= getInitialRange(trace1
);
564 TmfTimeRange curRange
= tm
.getCurrentTraceContext().getWindowRange();
565 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
566 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
568 /* Range of trace2 should not have changed */
570 expectedRange
= getInitialRange(trace2
);
571 curRange
= tm
.getCurrentTraceContext().getWindowRange();
572 assertEquals(expectedRange
.getStartTime(), curRange
.getStartTime());
573 assertEquals(expectedRange
.getEndTime(), curRange
.getEndTime());
576 // ------------------------------------------------------------------------
577 // Test an experiment
578 // ------------------------------------------------------------------------
581 * Test in an experiment when we select a timestamp that is part of one of
582 * the experiment's traces.
584 * The experiment's current time should be correctly updated.
587 public void testExperimentTimestampInTrace() {
588 TmfExperiment exp
= createExperiment(trace1
, trace2
);
590 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t1start
+ ONE_SECOND
);
593 /* The experiment's current time should be updated. */
594 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
595 assertEquals(ts
, selection
.getStartTime());
596 assertEquals(ts
, selection
.getEndTime());
600 * Test in an experiment when we select a timestamp that is between two
601 * traces in the experiment.
603 * The experiment's current time should still be updated, since the
604 * timestamp is valid in the experiment itself.
607 public void testExperimentTimestampInBetween() {
608 TmfExperiment exp
= createExperiment(trace1
, trace2
);
610 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t1end
+ ONE_SECOND
);
613 /* The experiment's current time should be updated. */
614 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
615 assertEquals(ts
, selection
.getStartTime());
616 assertEquals(ts
, selection
.getEndTime());
620 * Test in an experiment when we select a timestamp that is outside of the
621 * total range of the experiment.
623 * The experiment's current time should not be updated.
626 public void testExperimentTimestampInvalid() {
627 TmfExperiment exp
= createExperiment(trace1
, trace2
);
629 ITmfTimestamp ts
= TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
);
632 /* The experiment's current time should NOT be updated. */
633 TmfTimeRange selection
= tm
.getCurrentTraceContext().getSelectionRange();
634 assertEquals(trace1
.getStartTime(), selection
.getStartTime());
635 assertEquals(trace1
.getStartTime(), selection
.getEndTime());
639 * Test the initial range of an experiment.
642 public void testExperimentInitialRange() {
643 TmfExperiment exp
= createExperiment(trace1
, trace2
);
646 * The initial range should be == to the initial range of the earliest
647 * trace (here trace1).
649 final TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
651 assertEquals(getInitialRange(trace1
), actualRange
);
652 assertEquals(getInitialRange(exp
), actualRange
);
656 * Test the range clamping with the start time of the range outside of the
657 * earliest trace's range. Only that start time should get clamped.
660 public void testExperimentRangeClampingOne() {
661 TmfExperiment exp
= createExperiment(trace1
, trace2
);
664 final TmfTimeRange range
= new TmfTimeRange(
665 TmfTimestamp
.fromNanos(t1start
- ONE_SECOND
),
666 TmfTimestamp
.fromNanos(t1end
- ONE_SECOND
));
667 selectWindowRange(range
);
669 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
670 assertEquals(t1start
, actualRange
.getStartTime().getValue());
671 assertEquals(t1end
- ONE_SECOND
, actualRange
.getEndTime().getValue());
675 * Test the range clamping when both the start and end times of the signal's
676 * range are outside of the trace's range. The range should clamp to the
677 * experiment's range.
680 public void testExperimentRangeClampingBoth() {
681 TmfExperiment exp
= createExperiment(trace1
, trace2
);
684 final TmfTimeRange range
= new TmfTimeRange(
685 TmfTimestamp
.fromNanos(t1start
- ONE_SECOND
),
686 TmfTimestamp
.fromNanos(t2end
+ ONE_SECOND
));
687 selectWindowRange(range
);
689 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
690 assertEquals(t1start
, actualRange
.getStartTime().getValue());
691 assertEquals(t2end
, actualRange
.getEndTime().getValue());
695 * Test selecting a range in-between two disjoint traces in an experiment.
696 * The range should still get correctly selected, even if no trace has any
697 * events in that range.
700 public void testExperimentRangeInBetween() {
701 TmfExperiment exp
= createExperiment(trace1
, trace2
);
704 final TmfTimeRange range
= new TmfTimeRange(
705 TmfTimestamp
.fromNanos(t1end
+ ONE_SECOND
),
706 TmfTimestamp
.fromNanos(t2start
- ONE_SECOND
));
707 selectWindowRange(range
);
709 TmfTimeRange actualRange
= tm
.getCurrentTraceContext().getWindowRange();
710 assertEquals(range
, actualRange
);
713 // ------------------------------------------------------------------------
715 // ------------------------------------------------------------------------
717 private static TmfExperiment
createExperiment(ITmfTrace t1
, ITmfTrace t2
) {
718 ITmfTrace
[] traces
= new ITmfTrace
[] { t1
, t2
};
719 TmfExperiment exp
= new TmfExperiment(ITmfEvent
.class, "test-exp", traces
,
720 TmfExperiment
.DEFAULT_INDEX_PAGE_SIZE
, null);
721 exp
.indexTrace(true);
722 // Deregister experiment from signal manager so that it doesn't
723 // interfere with the TmfTraceManager tests
724 TmfSignalManager
.deregister(exp
);
728 private static TmfTimeRange
getInitialRange(ITmfTrace trace
) {
729 return new TmfTimeRange(
730 trace
.getStartTime(),
731 calculateOffset(trace
.getStartTime(), trace
.getInitialRangeOffset()));
735 * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
737 private static @NonNull ITmfTimestamp
calculateOffset(ITmfTimestamp initialTs
, ITmfTimestamp offsetTs
) {
738 long start
= initialTs
.toNanos();
739 long offset
= offsetTs
.toNanos();
740 return TmfTimestamp
.fromNanos(start
+ offset
);