mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 08:11:16 +00:00
tests: add unit test for segment _offset_running_time()
Add a unit test to check that positive and negative offsets are applied correctly in various cases.
This commit is contained in:
parent
f664fbd198
commit
b5e4e24e75
1 changed files with 91 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue