ghostpad: add some tests for activation

https://bugzilla.gnome.org/show_bug.cgi?id=761913
This commit is contained in:
Havard Graff 2016-02-17 11:02:34 +01:00 committed by Sebastian Dröge
parent ab55ad7eaa
commit 87c2254b1d

View file

@ -20,6 +20,7 @@
*/
#include <gst/check/gstcheck.h>
#include <gst/check/gstharness.h>
/* test if removing a bin also cleans up the ghostpads
*/
@ -1167,6 +1168,67 @@ GST_START_TEST (test_ghost_pads_remove_while_playing)
GST_END_TEST;
GST_START_TEST (test_activate_src)
{
GstHarness *h;
GstElement *b;
GstElement *src;
GstPad *srcpad;
b = gst_bin_new (NULL);
src = gst_element_factory_make ("fakesrc", NULL);
g_object_set (src, "sync", TRUE, NULL);
gst_bin_add (GST_BIN (b), src);
srcpad = gst_element_get_static_pad (src, "src");
gst_element_add_pad (b, gst_ghost_pad_new ("src", srcpad));
gst_object_unref (srcpad);
h = gst_harness_new_with_element (b, NULL, "src");
gst_harness_play (h);
gst_harness_crank_single_clock_wait (h);
gst_buffer_unref (gst_harness_pull (h));
gst_object_unref (b);
gst_harness_teardown (h);
}
GST_END_TEST;
GST_START_TEST (test_activate_sink_and_src)
{
GstHarness *h;
GstElement *b;
GstElement *element;
GstPad *sinkpad;
GstPad *srcpad;
b = gst_bin_new (NULL);
element = gst_element_factory_make ("identity", NULL);
gst_bin_add (GST_BIN (b), element);
sinkpad = gst_element_get_static_pad (element, "sink");
gst_element_add_pad (b, gst_ghost_pad_new ("sink", sinkpad));
gst_object_unref (sinkpad);
srcpad = gst_element_get_static_pad (element, "src");
gst_element_add_pad (b, gst_ghost_pad_new ("src", srcpad));
gst_object_unref (srcpad);
h = gst_harness_new_with_element (b, "sink", "src");
gst_harness_set_src_caps_str (h, "mycaps");
gst_harness_push (h, gst_buffer_new());
gst_buffer_unref (gst_harness_pull (h));
gst_object_unref (b);
gst_harness_teardown (h);
}
GST_END_TEST;
static Suite *
gst_ghost_pad_suite (void)
{
@ -1193,6 +1255,9 @@ gst_ghost_pad_suite (void)
tcase_add_test (tc_chain, test_ghost_pads_internal_link);
tcase_add_test (tc_chain, test_ghost_pads_remove_while_playing);
tcase_add_test (tc_chain, test_activate_src);
tcase_add_test (tc_chain, test_activate_sink_and_src);
return s;
}