From 558f4aca5987f9415bc0a0f8bc169f71f444117e Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Sat, 26 Sep 2009 23:43:37 +0300 Subject: [PATCH] tests: add ghostpad test for setting target again after pad is linked --- tests/check/gst/gstghostpad.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/check/gst/gstghostpad.c b/tests/check/gst/gstghostpad.c index 363a88a..ed22e2f 100644 --- a/tests/check/gst/gstghostpad.c +++ b/tests/check/gst/gstghostpad.c @@ -975,6 +975,51 @@ GST_START_TEST (test_ghost_pads_src_link_unlink) GST_END_TEST; +GST_START_TEST (test_ghost_pads_change_when_linked) +{ + GstElement *b1, *b2, *src, *fmt, *sink1, *sink2; + GstPad *sinkpad, *ghostpad; + GstCaps *caps; + + b1 = gst_element_factory_make ("pipeline", NULL); + b2 = gst_element_factory_make ("bin", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + fmt = gst_element_factory_make ("capsfilter", NULL); + sink1 = gst_element_factory_make ("fakesink", NULL); + sink2 = gst_element_factory_make ("fakesink", NULL); + + gst_bin_add (GST_BIN (b2), sink1); + gst_bin_add (GST_BIN (b2), sink2); + gst_bin_add (GST_BIN (b1), src); + gst_bin_add (GST_BIN (b1), fmt); + gst_bin_add (GST_BIN (b1), b2); + + caps = gst_caps_from_string ("audio/x-raw-int, width=16, channels=1"); + g_object_set (fmt, "caps", caps, NULL); + gst_caps_unref (caps); + + /* create the ghostpad as a sink-pad for bin 2 */ + ghostpad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK); + gst_element_add_pad (b2, ghostpad); + + sinkpad = gst_element_get_static_pad (sink1, "sink"); + fail_unless (gst_ghost_pad_set_target ((GstGhostPad *) ghostpad, sinkpad)); + gst_object_unref (sinkpad); + + fail_unless (gst_element_link_many (src, fmt, b2, NULL)); + + /* set different target after ghostpad is linked */ + sinkpad = gst_element_get_static_pad (sink2, "sink"); + fail_unless (gst_ghost_pad_set_target ((GstGhostPad *) ghostpad, sinkpad)); + gst_object_unref (sinkpad); + + /* clean up */ + gst_object_unref (b1); +} + +GST_END_TEST; + + static Suite * gst_ghost_pad_suite (void) { @@ -997,6 +1042,7 @@ gst_ghost_pad_suite (void) tcase_add_test (tc_chain, test_ghost_pads_forward_setcaps); tcase_add_test (tc_chain, test_ghost_pads_sink_link_unlink); tcase_add_test (tc_chain, test_ghost_pads_src_link_unlink); + tcase_add_test (tc_chain, test_ghost_pads_change_when_linked); return s; } -- 2.7.4