@@ -67,6 +67,7 @@ public class CtfTmfTraceTest {
6767 @ BeforeClass
6868 public static void setUp () {
6969 fixture = CtfTmfTestTraceUtils .getTrace (testTrace );
70+ fixture .seekEvent (fixture .readEnd ());
7071 }
7172
7273 /**
@@ -213,18 +214,20 @@ public void testGetContainedEventTypes() {
213214 public void testGetLocationRatio () {
214215 ITmfContext context = fixture .seekEvent (0 );
215216 long t1 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
216- fixture .getNext (context );
217+ double ratio1 = 0.4 ;
218+ context = fixture .seekEvent (ratio1 );
217219 long t2 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
218- fixture .getNext (context );
220+ long tMid = (fixture .getEndTime ().getValue () - fixture .getStartTime ().getValue ()) / 2 + fixture .getStartTime ().getValue ();
221+ double ratio2 = 0.7 ;
222+ context = fixture .seekEvent (ratio2 );
219223 long t3 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
220- fixture .getNext (context );
221224 context .dispose ();
222- double ratio1 = fixture . getLocationRatio ( new CtfLocation ( t1 , 0 ));
223- assertEquals (0.0 , ratio1 , 0.01 );
224- double ratio2 = fixture .getLocationRatio (new CtfLocation (t2 , 0 ));
225- assertEquals (( double ) ( t2 - t1 ) / ( t3 - t1 ), ratio2 , 0.01 );
226- double ratio3 = fixture .getLocationRatio (new CtfLocation (t3 , 0 ));
227- assertEquals (1.0 , ratio3 , 0.01 );
225+
226+ assertEquals (0.0 , fixture . getLocationRatio ( new CtfLocation ( t1 , 0 )) , 0.01 );
227+ assertEquals ( ratio1 , fixture .getLocationRatio (new CtfLocation (t2 , 0 )), 0.01 );
228+ assertEquals (0.5 , fixture . getLocationRatio ( new CtfLocation ( tMid , 0 )) , 0.01 );
229+ assertEquals ( ratio2 , fixture .getLocationRatio (new CtfLocation (t3 , 0 )), 0.01 );
230+ assertEquals (1.0 , fixture . getLocationRatio ( new CtfLocation ( fixture . getEndTime (), 0 )) , 0.01 );
228231 }
229232
230233 /**
@@ -252,7 +255,7 @@ public void testGetTraceProperties() {
252255 @ Test
253256 public void testGetNbEvents () {
254257 long result = fixture .getNbEvents ();
255- assertEquals (1L , result );
258+ assertEquals (695319L , result );
256259 }
257260
258261 /**
@@ -328,21 +331,26 @@ public void testReadNextEvent() {
328331 @ Test
329332 public void testSeekEvent_ratio () {
330333 ITmfContext context = fixture .seekEvent (0 );
331- long t1 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
332- fixture .getNext (context );
333- long t2 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
334- fixture .getNext (context );
335- long t3 = ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ();
336- fixture .getNext (context );
334+ assertEquals (fixture .getStartTime ().getValue (), ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ());
337335 context .dispose ();
338- context = fixture .seekEvent (0.0 );
339- assertEquals (t1 , ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ());
336+
337+ double ratio1 = 0.3 ;
338+ context = fixture .seekEvent (ratio1 );
339+ assertEquals (ratio1 , fixture .getLocationRatio (context .getLocation ()), 0.01 );
340340 context .dispose ();
341+
341342 context = fixture .seekEvent (0.5 );
342- assertEquals (t2 , ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ());
343+ long tMid = (fixture .getEndTime ().getValue () - fixture .getStartTime ().getValue ()) / 2 + fixture .getStartTime ().getValue ();
344+ assertEquals (tMid , ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp (), 1000 );
345+ context .dispose ();
346+
347+ double ratio2 = 0.7 ;
348+ context = fixture .seekEvent (ratio2 );
349+ assertEquals (ratio2 , fixture .getLocationRatio (context .getLocation ()), 0.01 );
343350 context .dispose ();
351+
344352 context = fixture .seekEvent (1.0 );
345- assertEquals (t3 , ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ());
353+ assertEquals (fixture . getEndTime (). getValue () , ((CtfLocationInfo ) context .getLocation ().getLocationInfo ()).getTimestamp ());
346354 context .dispose ();
347355 }
348356
0 commit comments