From 1157de776a70dec08c22901e8b6b7210d0b191d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 3 May 2008 16:00:04 +0000 Subject: [PATCH] tests/check/elements/subparse.c: Add unit test for the tmplayer variant from bug #530962. Original commit message from CVS: * tests/check/elements/subparse.c: (do_test), (test_tmplayer_style3b), (subparse_suite): Add unit test for the tmplayer variant from bug #530962. --- ChangeLog | 6 ++++++ tests/check/elements/subparse.c | 38 ++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b68d05591..3b936c88ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-03 Tim-Philipp Müller + + * tests/check/elements/subparse.c: (do_test), + (test_tmplayer_style3b), (subparse_suite): + Add unit test for the tmplayer variant from bug #530962. + 2008-05-03 Tim-Philipp Müller * gst/subparse/gstsubparse.c: (handle_buffer), diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c index 4a654650ed..4101df9839 100644 --- a/tests/check/elements/subparse.c +++ b/tests/check/elements/subparse.c @@ -1,6 +1,5 @@ /* GStreamer unit tests for subparse - * - * Copyright (C) 2006 Tim-Philipp Müller + * Copyright (C) 2006-2008 Tim-Philipp Müller * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -249,11 +248,19 @@ do_test (SubParseInputChunk * input, guint num, const gchar * media_type) buf = g_list_nth_data (buffers, n); fail_unless (buf != NULL); + + /* check timestamp */ fail_unless (GST_BUFFER_TIMESTAMP_IS_VALID (buf), NULL); - fail_unless (GST_BUFFER_DURATION_IS_VALID (buf), NULL); fail_unless_equals_uint64 (GST_BUFFER_TIMESTAMP (buf), input[n].from_ts); - fail_unless_equals_uint64 (GST_BUFFER_DURATION (buf), - input[n].to_ts - input[n].from_ts); + + /* might not be able to put a duration on the last buffer */ + if (input[n].to_ts != GST_CLOCK_TIME_NONE) { + /* check duration */ + fail_unless (GST_BUFFER_DURATION_IS_VALID (buf), NULL); + fail_unless_equals_uint64 (GST_BUFFER_DURATION (buf), + input[n].to_ts - input[n].from_ts); + } + out = (gchar *) GST_BUFFER_DATA (buf); out_size = GST_BUFFER_SIZE (buf); /* shouldn't have trailing newline characters */ @@ -382,6 +389,26 @@ GST_START_TEST (test_tmplayer_style3) GST_END_TEST; +GST_START_TEST (test_tmplayer_style3b) +{ + static SubParseInputChunk tmplayer_style3b_input[] = { + { + "0:00:10:This is the Earth at a time|when the dinosaurs roamed...\n", + 10 * GST_SECOND, 14 * GST_SECOND, + "This is the Earth at a time\nwhen the dinosaurs roamed..."}, { + "0:00:14:a lush and fertile planet.\n", + 14 * GST_SECOND, 16 * GST_SECOND, + "a lush and fertile planet."}, { + "0:00:16:Yet another line.", + 16 * GST_SECOND, GST_CLOCK_TIME_NONE, "Yet another line."} + }; + + test_tmplayer_do_test (tmplayer_style3b_input, + G_N_ELEMENTS (tmplayer_style3b_input)); +} + +GST_END_TEST; + GST_START_TEST (test_tmplayer_style4) { static SubParseInputChunk tmplayer_style4_input[] = { @@ -571,6 +598,7 @@ subparse_suite (void) tcase_add_test (tc_chain, test_tmplayer_style1); tcase_add_test (tc_chain, test_tmplayer_style2); tcase_add_test (tc_chain, test_tmplayer_style3); + tcase_add_test (tc_chain, test_tmplayer_style3b); tcase_add_test (tc_chain, test_tmplayer_style4); tcase_add_test (tc_chain, test_tmplayer_style4_with_bogus_lines); tcase_add_test (tc_chain, test_microdvd_with_fps);