From: Thomas Vander Stichele Date: Fri, 13 Apr 2007 21:08:11 +0000 (+0000) Subject: tests/check/Makefile.am: tests/check/pipelines/streamheader.c (n_tags, tag_event_prob... X-Git-Tag: 1.19.3~511^2~11208 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57ba080628b85ca5396f5c9163ba99573c6b42a6;p=platform%2Fupstream%2Fgstreamer.git tests/check/Makefile.am: tests/check/pipelines/streamheader.c (n_tags, tag_event_probe_cb, Original commit message from CVS: * tests/check/Makefile.am: * tests/check/pipelines/streamheader.c (n_tags, tag_event_probe_cb, GST_START_TEST, streamheader_suite, main): Add a test for the streamheader bug Wim fixed. --- diff --git a/ChangeLog b/ChangeLog index 0ca850e..80b037a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-13 Thomas Vander Stichele + + * tests/check/Makefile.am: + * tests/check/pipelines/streamheader.c (n_tags, tag_event_probe_cb, + GST_START_TEST, streamheader_suite, main): + Add a test for the streamheader bug Wim fixed. + 2007-04-13 Jan Schmidt * ext/theora/theoradec.c: (theora_dec_sink_event): diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index cd0a1b2..8a63f82 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -86,7 +86,8 @@ check_PROGRAMS = \ libs/pbutils \ libs/tag \ libs/video \ - pipelines/simple-launch-lines + pipelines/simple-launch-lines \ + pipelines/streamheader # TORTURE_TO_FIX = \ # elements/adder diff --git a/tests/check/pipelines/streamheader.c b/tests/check/pipelines/streamheader.c new file mode 100644 index 0000000..feb9e85 --- /dev/null +++ b/tests/check/pipelines/streamheader.c @@ -0,0 +1,138 @@ +/* GStreamer + * + * unit test for streamheader handling + * + * Copyright (C) 2007 Thomas Vander Stichele + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include + +#ifndef GST_DISABLE_PARSE + +/* this tests a gdp-serialized tag from audiotestsrc being sent only once + * to clients of multifdsink */ + +static int n_tags = 0; + +gboolean +tag_event_probe_cb (GstPad * pad, GstEvent * event, GMainLoop * loop) +{ + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_TAG: + { + ++n_tags; + fail_if (n_tags > 1, "More than 1 tag received"); + break; + } + case GST_EVENT_EOS: + { + g_main_loop_quit (loop); + break; + } + default: + break; + } + + return TRUE; +} + +GST_START_TEST (test_multifdsink_gdp_tag) +{ + GstElement *p1, *p2; + GstElement *src, *sink, *depay; + GstPad *pad; + GMainLoop *loop; + int pfd[2]; + + loop = g_main_loop_new (NULL, FALSE); + + p1 = gst_parse_launch ("audiotestsrc num-buffers=10 ! gdppay" + " ! multifdsink name=p1sink", NULL); + fail_if (p1 == NULL); + p2 = gst_parse_launch ("fdsrc name=p2src ! gdpdepay name=depay" + " ! fakesink name=p2sink signal-handoffs=True", NULL); + fail_if (p2 == NULL); + + fail_if (pipe (pfd) == -1); + + + gst_element_set_state (p1, GST_STATE_READY); + + sink = gst_bin_get_by_name (GST_BIN (p1), "p1sink"); + g_signal_emit_by_name (sink, "add", pfd[1], NULL); + gst_object_unref (sink); + + src = gst_bin_get_by_name (GST_BIN (p2), "p2src"); + g_object_set (G_OBJECT (src), "fd", pfd[0], NULL); + gst_object_unref (src); + + depay = gst_bin_get_by_name (GST_BIN (p2), "depay"); + fail_if (depay == NULL); + + pad = gst_element_get_pad (depay, "src"); + fail_unless (pad != NULL, "Could not get pad out of depay"); + gst_object_unref (depay); + + gst_pad_add_event_probe (pad, G_CALLBACK (tag_event_probe_cb), loop); + + gst_element_set_state (p1, GST_STATE_PLAYING); + gst_element_set_state (p2, GST_STATE_PLAYING); + + g_main_loop_run (loop); + + assert_equals_int (n_tags, 1); +} + +GST_END_TEST; + +#endif /* #ifndef GST_DISABLE_PARSE */ + +Suite * +streamheader_suite (void) +{ + Suite *s = suite_create ("streamheader"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); +#ifndef GST_DISABLE_PARSE + tcase_add_test (tc_chain, test_multifdsink_gdp_tag); +#endif + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = streamheader_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +}