tests: add ghostpad test for setting target again after pad is linked

This commit is contained in:
Stefan Kost 2009-09-26 23:43:37 +03:00
parent 593fc8894b
commit 558f4aca59

View file

@ -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;
}