From 300f02af2aaacdc2c32d2f4be61635882e5c495c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 22 May 2009 12:23:27 +0200 Subject: tests: add rtpbin unit test Add the beginnings of an rtpbin unit test Add some more stuff to .gitignore --- tests/check/Makefile.am | 1 + tests/check/elements/.gitignore | 2 + tests/check/elements/rtpbin.c | 94 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 tests/check/elements/rtpbin.c (limited to 'tests/check') diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 8d3e3839..bf216c12 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -92,6 +92,7 @@ check_PROGRAMS = \ elements/camerabin \ elements/legacyresample \ elements/qtmux \ + elements/rtpbin \ elements/selector \ elements/mxfdemux \ elements/mxfmux \ diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 8b69efb6..091fb4e5 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -18,6 +18,7 @@ souphttpsrc rganalysis rglimiter rgvolume +rtpbin selector spectrum timidity @@ -26,3 +27,4 @@ wavpackdec wavpackenc wavpackparse x264enc +y4menc diff --git a/tests/check/elements/rtpbin.c b/tests/check/elements/rtpbin.c new file mode 100644 index 00000000..b98e1b5f --- /dev/null +++ b/tests/check/elements/rtpbin.c @@ -0,0 +1,94 @@ +/* GStreamer + * + * unit test for gstrtpbin + * + * Copyright (C) <2009> Wim Taymans + * + * 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 + +GST_START_TEST (test_cleanup_send) +{ + GstElement *rtpbin; + GstPad *rtp_sink, *rtp_src; + GObject *session; + + rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin"); + + rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0"); + fail_unless (rtp_sink != NULL); + ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2); + + rtp_src = gst_element_get_static_pad (rtpbin, "send_rtp_src_0"); + fail_unless (rtp_src != NULL); + ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 2); + + /* we should be able to get an internal session 0 now */ + g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); + fail_unless (session != NULL); + g_object_unref (session); + + gst_element_release_request_pad (rtpbin, rtp_sink); + ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1); + ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1); + + /* the session should be gone now */ + g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); + fail_unless (session == NULL); + + /* the other pad should be gone too now */ + fail_unless (gst_element_get_static_pad (rtpbin, "send_rtp_src_0") == NULL); + + /* unref the request pad and the static pad */ + gst_object_unref (rtp_sink); + gst_object_unref (rtp_src); + + gst_object_unref (rtpbin); +} + +GST_END_TEST; + + +Suite * +gstrtpbin_suite (void) +{ + Suite *s = suite_create ("gstrtpbin"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_cleanup_send); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = gstrtpbin_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; +} -- cgit v1.2.1