tmf: Fix most Number unboxing problems
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / trace / TmfTraceManagerTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 * Patrick Tasse - Support selection range
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.tests.trace;
15
16 import static org.junit.Assert.assertArrayEquals;
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertSame;
20 import static org.junit.Assume.assumeTrue;
21
22 import java.io.File;
23
24 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
25 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
26 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
27 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
28 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
29 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
30 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
31 import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
32 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
33 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
34 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
35 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
36 import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment;
37 import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
38 import org.junit.After;
39 import org.junit.Before;
40 import org.junit.BeforeClass;
41 import org.junit.Test;
42
43 /**
44 * Test suite for the {@link TmfTraceManager}.
45 *
46 * @author Alexandre Montplaisir
47 */
48 public class TmfTraceManagerTest {
49
50 private static final int SCALE = ITmfTimestamp.NANOSECOND_SCALE;
51
52 private static ITmfTrace trace1;
53 private static final long t1start = 1331668247314038062L;
54 private static final long t1end = 1331668259054285979L;
55
56 private static ITmfTrace trace2;
57 private static final long t2start = 1332170682440133097L;
58 private static final long t2end = 1332170692664579801L;
59
60 private static final long ONE_SECOND = 1000000000L;
61
62 private TmfTraceManager tm;
63
64
65 /**
66 * Test class initialization
67 */
68 @BeforeClass
69 public static void setUpClass() {
70 assumeTrue(CtfTmfTestTrace.TRACE2.exists());
71 assumeTrue(CtfTmfTestTrace.KERNEL.exists());
72 trace1 = CtfTmfTestTrace.TRACE2.getTrace();
73 trace2 = CtfTmfTestTrace.KERNEL.getTrace();
74
75 trace1.indexTrace(true);
76 trace2.indexTrace(true);
77 }
78
79 /**
80 * Test initialization
81 */
82 @Before
83 public void setUp() {
84 tm = TmfTraceManager.getInstance();
85 }
86
87 /**
88 * Test clean-up
89 */
90 @After
91 public void tearDown() {
92 while (tm.getActiveTrace() != null) {
93 closeTrace(tm.getActiveTrace());
94 }
95 }
96
97 // ------------------------------------------------------------------------
98 // Dummy actions (fake signals)
99 // ------------------------------------------------------------------------
100
101 private void openTrace(ITmfTrace trace) {
102 TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(this, trace, null));
103 selectTrace(trace);
104 }
105
106 private void closeTrace(ITmfTrace trace) {
107 TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace));
108 /*
109 * In TMF, the next tab would now be selected (if there are some), which
110 * would select another trace automatically.
111 */
112 if (tm.getOpenedTraces().size() > 0) {
113 selectTrace(tm.getOpenedTraces().toArray(new ITmfTrace[0])[0]);
114 }
115 }
116
117 private void selectTrace(ITmfTrace trace) {
118 TmfSignalManager.dispatchSignal(new TmfTraceSelectedSignal(this, trace));
119 }
120
121 private void selectTimestamp(ITmfTimestamp ts) {
122 TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(this, ts));
123 }
124
125 private void selectTimeRange(TmfTimeRange tr) {
126 TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(this, tr));
127 }
128
129 // ------------------------------------------------------------------------
130 // General tests
131 // ------------------------------------------------------------------------
132
133 /**
134 * Test that the manager is correctly initialized
135 */
136 @Test
137 public void testInitialize() {
138 TmfTraceManager mgr = TmfTraceManager.getInstance();
139 assertNotNull(mgr);
140 assertSame(tm, mgr);
141 }
142
143 /**
144 * Test the contents of a trace set with one trace.
145 */
146 @Test
147 public void testTraceSet() {
148 openTrace(trace1);
149 openTrace(trace2);
150 selectTrace(trace2);
151
152 ITmfTrace[] expected = new ITmfTrace[] { trace2 };
153 ITmfTrace[] actual = tm.getActiveTraceSet();
154
155 assertEquals(1, actual.length);
156 assertArrayEquals(expected, actual);
157 }
158
159 /**
160 * Test the contents of a trace set with an experiment.
161 */
162 @Test
163 public void testTraceSetExperiment() {
164 TmfExperiment exp = createExperiment(trace1, trace2);
165 openTrace(trace1);
166 openTrace(exp);
167
168 ITmfTrace[] expected = new ITmfTrace[] { trace1, trace2 };
169 ITmfTrace[] actual = tm.getActiveTraceSet();
170
171 assertEquals(2, actual.length);
172 assertArrayEquals(expected, actual);
173 }
174
175 /**
176 * Test the {@link TmfTraceManager#getSupplementaryFileDir} method.
177 */
178 @Test
179 public void testSupplementaryFileDir() {
180 String name1 = trace1.getName();
181 String name2 = trace2.getName();
182 String basePath = System.getProperty("java.io.tmpdir") + File.separator;
183
184 String expected1 = basePath + name1 + File.separator;
185 String expected2 = basePath + name2 + File.separator;
186
187 assertEquals(expected1, TmfTraceManager.getSupplementaryFileDir(trace1));
188 assertEquals(expected2, TmfTraceManager.getSupplementaryFileDir(trace2));
189 }
190
191 // ------------------------------------------------------------------------
192 // Test a single trace
193 // ------------------------------------------------------------------------
194
195 /**
196 * Test the initial range of a single trace.
197 */
198 @Test
199 public void testTraceInitialRange() {
200 openTrace(trace2);
201 final TmfTimeRange expectedRange = new TmfTimeRange(
202 trace2.getStartTime(),
203 calculateOffset(trace2.getStartTime(), trace2.getInitialRangeOffset()));
204 TmfTimeRange actualRange = tm.getCurrentRange();
205 assertEquals(expectedRange, actualRange);
206 }
207
208 /**
209 * Try selecting a timestamp contained inside the trace's range. The trace's
210 * current time should get updated correctly.
211 */
212 @Test
213 public void testNewTimestamp() {
214 openTrace(trace2);
215 ITmfTimestamp ts = new TmfTimestamp(t2start + ONE_SECOND, SCALE);
216 selectTimestamp(ts);
217
218 ITmfTimestamp afterTs = tm.getSelectionBeginTime();
219 assertEquals(ts, afterTs);
220 afterTs = tm.getSelectionEndTime();
221 assertEquals(ts, afterTs);
222 }
223
224 /**
225 * Try selecting a timestamp happening before the trace's start. The change
226 * should be ignored.
227 */
228 @Test
229 public void testTimestampBefore() {
230 openTrace(trace2);
231 ITmfTimestamp beforeTs = tm.getSelectionBeginTime();
232 ITmfTimestamp ts = new TmfTimestamp(t2start - ONE_SECOND, SCALE);
233 selectTimestamp(ts);
234
235 ITmfTimestamp curTs = tm.getSelectionBeginTime();
236 assertEquals(beforeTs, curTs);
237 curTs = tm.getSelectionEndTime();
238 assertEquals(beforeTs, curTs);
239 }
240
241 /**
242 * Try selecting a timestamp happening after the trace's end. The change
243 * should be ignored.
244 */
245 @Test
246 public void testTimestampAfter() {
247 openTrace(trace2);
248 ITmfTimestamp beforeTs = tm.getSelectionBeginTime();
249 ITmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
250 selectTimestamp(ts);
251
252 ITmfTimestamp curTs = tm.getSelectionBeginTime();
253 assertEquals(beforeTs, curTs);
254 curTs = tm.getSelectionEndTime();
255 assertEquals(beforeTs, curTs);
256 }
257
258 /**
259 * Test selecting a normal sub-range of a single trace.
260 */
261 @Test
262 public void testTraceNewTimeRange() {
263 openTrace(trace2);
264 TmfTimeRange range = new TmfTimeRange(
265 new TmfTimestamp(t2start + ONE_SECOND, SCALE),
266 new TmfTimestamp(t2end - ONE_SECOND, SCALE));
267 selectTimeRange(range);
268
269 TmfTimeRange curRange = tm.getCurrentRange();
270 assertEquals(range.getStartTime(), curRange.getStartTime());
271 assertEquals(range.getEndTime(), curRange.getEndTime());
272 }
273
274 /**
275 * Test selecting a range whose start time is before the trace's start time.
276 * The selected range should get clamped to the trace's range.
277 */
278 @Test
279 public void testTraceTimeRangeClampingStart() {
280 openTrace(trace2);
281 TmfTimeRange range = new TmfTimeRange(
282 new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here
283 new TmfTimestamp(t2end - ONE_SECOND, SCALE));
284 selectTimeRange(range);
285
286 TmfTimeRange curRange = tm.getCurrentRange();
287 assertEquals(t2start, curRange.getStartTime().getValue());
288 assertEquals(range.getEndTime(), curRange.getEndTime());
289 }
290
291 /**
292 * Test selecting a range whose end time is after the trace's end time.
293 * The selected range should get clamped to the trace's range.
294 */
295 @Test
296 public void testTraceTimeRangeClampingEnd() {
297 openTrace(trace2);
298 TmfTimeRange range = new TmfTimeRange(
299 new TmfTimestamp(t2start + ONE_SECOND, SCALE),
300 new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here
301 selectTimeRange(range);
302
303 TmfTimeRange curRange = tm.getCurrentRange();
304 assertEquals(range.getStartTime(), curRange.getStartTime());
305 assertEquals(t2end, curRange.getEndTime().getValue());
306 }
307
308 /**
309 * Test selecting a range whose both start and end times are outside of the
310 * trace's range. The selected range should get clamped to the trace's
311 * range.
312 */
313 @Test
314 public void testTraceTimeRangeClampingBoth() {
315 openTrace(trace2);
316 TmfTimeRange range = new TmfTimeRange(
317 new TmfTimestamp(t2start - ONE_SECOND, SCALE), // minus here
318 new TmfTimestamp(t2end + ONE_SECOND, SCALE)); // plus here
319 selectTimeRange(range);
320
321 TmfTimeRange curRange = tm.getCurrentRange();
322 assertEquals(t2start, curRange.getStartTime().getValue());
323 assertEquals(t2end, curRange.getEndTime().getValue());
324 }
325
326 // ------------------------------------------------------------------------
327 // Test multiple, non-overlapping traces in parallel
328 // ------------------------------------------------------------------------
329
330 /**
331 * Test, with two traces in parallel, when we select a timestamp that is
332 * part of the first trace.
333 *
334 * The first trace's timestamp should be updated, but the second trace's one
335 * should not change.
336 */
337 @Test
338 public void testTwoTracesTimestampValid() {
339 openTrace(trace1);
340 openTrace(trace2);
341 selectTrace(trace1);
342 TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE);
343 selectTimestamp(ts);
344
345 /* Timestamp of trace1 should have been updated */
346 assertEquals(ts, tm.getSelectionBeginTime());
347 assertEquals(ts, tm.getSelectionEndTime());
348
349 /* Timestamp of trace2 should not have changed */
350 selectTrace(trace2);
351 assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
352 assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
353 }
354
355 /**
356 * Test, with two traces in parallel, when we select a timestamp that is
357 * between two traces.
358 *
359 * None of the trace's timestamps should be updated (we are not in an
360 * experiment!)
361 */
362 @Test
363 public void testTwoTracesTimestampInBetween() {
364 openTrace(trace1);
365 openTrace(trace2);
366 selectTrace(trace1);
367 TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE);
368 selectTimestamp(ts);
369
370 /* Timestamp of trace1 should not have changed */
371 assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
372 assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
373
374 /* Timestamp of trace2 should not have changed */
375 selectTrace(trace2);
376 assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
377 assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
378 }
379
380 /**
381 * Test, with two traces in parallel, when we select a timestamp that is
382 * completely out of the trace's range.
383 *
384 * None of the trace's timestamps should be updated.
385 */
386 @Test
387 public void testTwoTracesTimestampInvalid() {
388 openTrace(trace1);
389 openTrace(trace2);
390 selectTrace(trace1);
391 TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
392 selectTimestamp(ts);
393
394 /* Timestamp of trace1 should not have changed */
395 assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
396 assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
397
398 /* Timestamp of trace2 should not have changed */
399 selectTrace(trace2);
400 assertEquals(trace2.getStartTime(), tm.getSelectionBeginTime());
401 assertEquals(trace2.getStartTime(), tm.getSelectionEndTime());
402 }
403
404 /**
405 * Test, with two traces opened in parallel (not in an experiment), if we
406 * select a time range valid in one of them. That trace's time range should
407 * be updated, but not the other one.
408 */
409 @Test
410 public void testTwoTracesTimeRangeAllInOne() {
411 openTrace(trace1);
412 openTrace(trace2);
413 selectTrace(trace1);
414 TmfTimeRange range = new TmfTimeRange(
415 new TmfTimestamp(t1start + ONE_SECOND, SCALE),
416 new TmfTimestamp(t1end - ONE_SECOND, SCALE));
417 selectTimeRange(range);
418
419 /* Range of trace1 should be equal to the requested one */
420 assertEquals(range, tm.getCurrentRange());
421
422 /* The range of trace 2 should not have changed */
423 selectTrace(trace2);
424 assertEquals(getInitialRange(trace2), tm.getCurrentRange());
425 }
426
427 /**
428 * Test, with two traces in parallel, when we select a time range that is
429 * only partially valid for one of the traces.
430 *
431 * The first trace's time range should be clamped to a valid range, and the
432 * second one's should not change.
433 */
434 @Test
435 public void testTwoTracesTimeRangePartiallyInOne() {
436 openTrace(trace1);
437 openTrace(trace2);
438 selectTrace(trace1);
439 TmfTimeRange range = new TmfTimeRange(
440 new TmfTimestamp(t1start + ONE_SECOND, SCALE),
441 new TmfTimestamp(t1end + ONE_SECOND, SCALE));
442 selectTimeRange(range);
443
444 /* Range of trace1 should get clamped to its end time */
445 TmfTimeRange expectedRange = new TmfTimeRange(
446 new TmfTimestamp(t1start + ONE_SECOND, SCALE),
447 new TmfTimestamp(t1end, SCALE));
448 assertEquals(expectedRange, tm.getCurrentRange());
449
450 /* Range of trace2 should not have changed */
451 selectTrace(trace2);
452 assertEquals(getInitialRange(trace2), tm.getCurrentRange());
453 }
454
455 /**
456 * Test, with two traces in parallel, when we select a time range that is
457 * only partially valid for both traces.
458 *
459 * Each trace's time range should get clamped to respectively valid ranges.
460 */
461 @Test
462 public void testTwoTracesTimeRangeInBoth() {
463 openTrace(trace1);
464 openTrace(trace2);
465 selectTrace(trace1);
466 TmfTimeRange range = new TmfTimeRange(
467 new TmfTimestamp(t1end - ONE_SECOND, SCALE),
468 new TmfTimestamp(t2start + ONE_SECOND, SCALE));
469 selectTimeRange(range);
470
471 /* Range of trace1 should be clamped to its end time */
472 TmfTimeRange expectedRange = new TmfTimeRange(
473 new TmfTimestamp(t1end - ONE_SECOND, SCALE),
474 new TmfTimestamp(t1end, SCALE));
475 assertEquals(expectedRange, tm.getCurrentRange());
476
477 /* Range of trace2 should be clamped to its start time */
478 selectTrace(trace2);
479 expectedRange = new TmfTimeRange(
480 new TmfTimestamp(t2start, SCALE),
481 new TmfTimestamp(t2start + ONE_SECOND, SCALE));
482 assertEquals(expectedRange, tm.getCurrentRange());
483 }
484
485 /**
486 * Test, with two traces in parallel, when we select a time range that is
487 * not valid for any trace.
488 *
489 * Each trace's time range should not be modified.
490 */
491 @Test
492 public void testTwoTracesTimeRangeInBetween() {
493 openTrace(trace1);
494 openTrace(trace2);
495 selectTrace(trace1);
496 TmfTimeRange range = new TmfTimeRange(
497 new TmfTimestamp(t1end + ONE_SECOND, SCALE),
498 new TmfTimestamp(t1end - ONE_SECOND, SCALE));
499 selectTimeRange(range);
500
501 /* Range of trace1 should not have changed */
502 TmfTimeRange expectedRange = getInitialRange(trace1);
503 TmfTimeRange curRange = tm.getCurrentRange();
504 assertEquals(expectedRange.getStartTime(), curRange.getStartTime());
505 assertEquals(expectedRange.getEndTime(), curRange.getEndTime());
506
507 /* Range of trace2 should not have changed */
508 selectTrace(trace2);
509 expectedRange = getInitialRange(trace2);
510 curRange = tm.getCurrentRange();
511 assertEquals(expectedRange.getStartTime(), curRange.getStartTime());
512 assertEquals(expectedRange.getEndTime(), curRange.getEndTime());
513 }
514
515 // ------------------------------------------------------------------------
516 // Test an experiment
517 // ------------------------------------------------------------------------
518
519 /**
520 * Test in an experiment when we select a timestamp that is part of one of
521 * the experiment's traces.
522 *
523 * The experiment's current time should be correctly updated.
524 */
525 @Test
526 public void testExperimentTimestampInTrace() {
527 TmfExperiment exp = createExperiment(trace1, trace2);
528 openTrace(exp);
529 TmfTimestamp ts = new TmfTimestamp(t1start + ONE_SECOND, SCALE);
530 selectTimestamp(ts);
531
532 /* The experiment's current time should be updated. */
533 assertEquals(ts, tm.getSelectionBeginTime());
534 assertEquals(ts, tm.getSelectionEndTime());
535 }
536
537 /**
538 * Test in an experiment when we select a timestamp that is between two
539 * traces in the experiment.
540 *
541 * The experiment's current time should still be updated, since the
542 * timestamp is valid in the experiment itself.
543 */
544 @Test
545 public void testExperimentTimestampInBetween() {
546 TmfExperiment exp = createExperiment(trace1, trace2);
547 openTrace(exp);
548 TmfTimestamp ts = new TmfTimestamp(t1end + ONE_SECOND, SCALE);
549 selectTimestamp(ts);
550
551 /* The experiment's current time should be updated. */
552 assertEquals(ts, tm.getSelectionBeginTime());
553 assertEquals(ts, tm.getSelectionEndTime());
554 }
555
556 /**
557 * Test in an experiment when we select a timestamp that is outside of the
558 * total range of the experiment.
559 *
560 * The experiment's current time should not be updated.
561 */
562 @Test
563 public void testExperimentTimestampInvalid() {
564 TmfExperiment exp = createExperiment(trace1, trace2);
565 openTrace(exp);
566 TmfTimestamp ts = new TmfTimestamp(t2end + ONE_SECOND, SCALE);
567 selectTimestamp(ts);
568
569 /* The experiment's current time should NOT be updated. */
570 assertEquals(trace1.getStartTime(), tm.getSelectionBeginTime());
571 assertEquals(trace1.getStartTime(), tm.getSelectionEndTime());
572 }
573
574 /**
575 * Test the initial range of an experiment.
576 */
577 @Test
578 public void testExperimentInitialRange() {
579 TmfExperiment exp = createExperiment(trace1, trace2);
580 openTrace(exp);
581 /*
582 * The initial range should be == to the initial range of the earliest
583 * trace (here trace1).
584 */
585 final TmfTimeRange actualRange = tm.getCurrentRange();
586
587 assertEquals(getInitialRange(trace1), actualRange);
588 assertEquals(getInitialRange(exp), actualRange);
589 }
590
591 /**
592 * Test the range clamping with the start time of the range outside of the
593 * earliest trace's range. Only that start time should get clamped.
594 */
595 @Test
596 public void testExperimentRangeClampingOne() {
597 TmfExperiment exp = createExperiment(trace1, trace2);
598 openTrace(exp);
599
600 final TmfTimeRange range = new TmfTimeRange(
601 new TmfTimestamp(t1start - ONE_SECOND, SCALE),
602 new TmfTimestamp(t1end - ONE_SECOND, SCALE));
603 selectTimeRange(range);
604
605 TmfTimeRange actualRange = tm.getCurrentRange();
606 assertEquals(t1start, actualRange.getStartTime().getValue());
607 assertEquals(t1end - ONE_SECOND, actualRange.getEndTime().getValue());
608 }
609
610 /**
611 * Test the range clamping when both the start and end times of the signal's
612 * range are outside of the trace's range. The range should clamp to the
613 * experiment's range.
614 */
615 @Test
616 public void testExperimentRangeClampingBoth() {
617 TmfExperiment exp = createExperiment(trace1, trace2);
618 openTrace(exp);
619
620 final TmfTimeRange range = new TmfTimeRange(
621 new TmfTimestamp(t1start - ONE_SECOND, SCALE),
622 new TmfTimestamp(t2end + ONE_SECOND, SCALE));
623 selectTimeRange(range);
624
625 TmfTimeRange actualRange = tm.getCurrentRange();
626 assertEquals(t1start, actualRange.getStartTime().getValue());
627 assertEquals(t2end, actualRange.getEndTime().getValue());
628 }
629
630 /**
631 * Test selecting a range in-between two disjoint traces in an experiment.
632 * The range should still get correctly selected, even if no trace has any
633 * events in that range.
634 */
635 @Test
636 public void testExperimentRangeInBetween() {
637 TmfExperiment exp = createExperiment(trace1, trace2);
638 openTrace(exp);
639
640 final TmfTimeRange range = new TmfTimeRange(
641 new TmfTimestamp(t1end + ONE_SECOND, SCALE),
642 new TmfTimestamp(t2start - ONE_SECOND, SCALE));
643 selectTimeRange(range);
644
645 TmfTimeRange actualRange = tm.getCurrentRange();
646 assertEquals(range, actualRange);
647 }
648
649 // ------------------------------------------------------------------------
650 // Utility methods
651 // ------------------------------------------------------------------------
652
653 private static TmfExperiment createExperiment(ITmfTrace t1, ITmfTrace t2) {
654 ITmfTrace[] traces = new ITmfTrace[] { t1, t2 };
655 TmfExperiment exp = new TmfExperiment(ITmfEvent.class, "test-exp", traces);
656 exp.indexTrace(true);
657 return exp;
658 }
659
660 private static TmfTimeRange getInitialRange(ITmfTrace trace) {
661 return new TmfTimeRange(
662 trace.getStartTime(),
663 calculateOffset(trace.getStartTime(), trace.getInitialRangeOffset()));
664 }
665
666 /**
667 * Basically a "initial + offset" operation, but for ITmfTimetamp objects.
668 */
669 private static ITmfTimestamp calculateOffset(ITmfTimestamp initialTs, ITmfTimestamp offsetTs) {
670 long start = initialTs.normalize(0, SCALE).getValue();
671 long offset = offsetTs.normalize(0, SCALE).getValue();
672 return new TmfTimestamp(start + offset, SCALE);
673 }
674 }
This page took 0.052876 seconds and 5 git commands to generate.