diff --git a/tests/check/gst/gstsegment.c b/tests/check/gst/gstsegment.c index 4c15133cd7..7464deea6a 100644 --- a/tests/check/gst/gstsegment.c +++ b/tests/check/gst/gstsegment.c @@ -613,6 +613,96 @@ GST_START_TEST (segment_seek_noupdate) GST_END_TEST; +GST_START_TEST (segment_offset) +{ + GstSegment segment; + + gst_segment_init (&segment, GST_FORMAT_TIME); + + segment.start = 0; + segment.position = 50; + segment.stop = 200; + segment.time = 0; + + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 20) == 20); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 220) == -1); + + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + 0) == TRUE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 0); + fail_unless (segment.offset == 0); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 20) == 20); + + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + 100) == TRUE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 100); + fail_unless (segment.offset == 0); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 20) == 120); + + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + -50) == TRUE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 50); + fail_unless (segment.offset == 0); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 20) == 70); + + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + -100) == TRUE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 0); + fail_unless (segment.offset == 50); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 20) == -1); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 200) == 150); + + /* can go negative */ + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + -151) == FALSE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 0); + fail_unless (segment.offset == 50); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 100) == 50); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 200) == 150); + + fail_unless (gst_segment_offset_running_time (&segment, GST_FORMAT_TIME, + -150) == TRUE); + fail_unless (segment.start == 0); + fail_unless (segment.stop == 200); + fail_unless (segment.time == 0); + fail_unless (segment.position == 50); + fail_unless (segment.base == 0); + fail_unless (segment.offset == 200); + fail_unless (gst_segment_to_running_time (&segment, GST_FORMAT_TIME, + 200) == 0); +} + +GST_END_TEST; + static Suite * gst_segment_suite (void) @@ -629,6 +719,7 @@ gst_segment_suite (void) tcase_add_test (tc_chain, segment_seek_rate); tcase_add_test (tc_chain, segment_copy); tcase_add_test (tc_chain, segment_seek_noupdate); + tcase_add_test (tc_chain, segment_offset); return s; }