summaryrefslogtreecommitdiff
path: root/tests/check/gst/gstghostpad.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-07-29 19:22:28 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-07-29 19:22:28 +0000
commitafbe73402460105e8487bd38d700a8b1c668d598 (patch)
tree7500ce412762ab86e4b00cb45170a927049e0d1a /tests/check/gst/gstghostpad.c
parent49de56dd1f32f8710c59b881419df358cd6eba95 (diff)
downloadgstreamer-afbe73402460105e8487bd38d700a8b1c668d598.tar.gz
check/gst/gstghostpad.c: Added test for removing an element with ghostpad from a bin.
Original commit message from CVS: * check/gst/gstghostpad.c: (GST_START_TEST), (gst_ghost_pad_suite): Added test for removing an element with ghostpad from a bin. Fixed test as current implementation does the right thing. * gst/gstghostpad.c: (gst_proxy_pad_class_init), (gst_proxy_pad_do_query_type), (gst_proxy_pad_do_event), (gst_proxy_pad_do_query), (gst_proxy_pad_do_internal_link), (gst_proxy_pad_do_bufferalloc), (gst_proxy_pad_do_activate), (gst_proxy_pad_do_activatepull), (gst_proxy_pad_do_activatepush), (gst_proxy_pad_do_chain), (gst_proxy_pad_do_getrange), (gst_proxy_pad_do_checkgetrange), (gst_proxy_pad_do_getcaps), (gst_proxy_pad_do_acceptcaps), (gst_proxy_pad_do_fixatecaps), (gst_proxy_pad_do_setcaps), (gst_proxy_pad_set_target), (gst_proxy_pad_get_target), (gst_proxy_pad_init), (gst_proxy_pad_dispose), (gst_proxy_pad_finalize), (gst_ghost_pad_class_init), (gst_ghost_pad_do_activate_push), (gst_ghost_pad_do_link), (gst_ghost_pad_do_unlink), (gst_ghost_pad_set_internal), (gst_ghost_pad_dispose), (gst_ghost_pad_new_notarget), (gst_ghost_pad_new), (gst_ghost_pad_get_target), (gst_ghost_pad_set_target): * gst/gstghostpad.h: Clean up ghostpads, remove properties for internal stuff. Make threadsafe. Fix refcounting. Prepare for switching targets, not all use cases work yet.
Diffstat (limited to 'tests/check/gst/gstghostpad.c')
-rw-r--r--tests/check/gst/gstghostpad.c57
1 files changed, 48 insertions, 9 deletions
diff --git a/tests/check/gst/gstghostpad.c b/tests/check/gst/gstghostpad.c
index 580c6301e8..274148337f 100644
--- a/tests/check/gst/gstghostpad.c
+++ b/tests/check/gst/gstghostpad.c
@@ -70,6 +70,46 @@ GST_START_TEST (test_remove1)
GST_END_TEST;
+/* test if removing a bin also cleans up the ghostpads
+ */
+GST_START_TEST (test_remove2)
+{
+ GstElement *b1, *b2, *src, *sink;
+ GstPad *srcpad, *sinkpad;
+ GstPadLinkReturn ret;
+
+ b1 = gst_element_factory_make ("pipeline", NULL);
+ b2 = gst_element_factory_make ("bin", NULL);
+ src = gst_element_factory_make ("fakesrc", NULL);
+ sink = gst_element_factory_make ("fakesink", NULL);
+
+ fail_unless (gst_bin_add (GST_BIN (b2), sink));
+ fail_unless (gst_bin_add (GST_BIN (b1), src));
+ fail_unless (gst_bin_add (GST_BIN (b1), b2));
+
+ sinkpad = gst_element_get_pad (sink, "sink");
+ gst_element_add_pad (b2, gst_ghost_pad_new ("sink", sinkpad));
+ gst_object_unref (sinkpad);
+
+ srcpad = gst_element_get_pad (src, "src");
+ /* get the ghostpad */
+ sinkpad = gst_element_get_pad (b2, "sink");
+
+ ret = gst_pad_link (srcpad, sinkpad);
+ fail_unless (ret == GST_PAD_LINK_OK);
+ gst_object_unref (srcpad);
+ gst_object_unref (sinkpad);
+
+ /* now remove the sink from the bin */
+ gst_bin_remove (GST_BIN (b2), sink);
+
+ srcpad = gst_element_get_pad (src, "src");
+ /* pad is still linked to ghostpad */
+ fail_if (!gst_pad_is_linked (srcpad));
+}
+
+GST_END_TEST;
+
/* test if linking fails over different bins using a pipeline
* like this:
*
@@ -186,23 +226,16 @@ GST_START_TEST (test_ghost_pads)
/* unreffing the bin will unref all elements, which will unlink and unparent
* all pads */
- /* FIXME: ghost pads need to drop their internal pad in the unlink function,
- * but can't right now. So internal pads have a ref from their parent, and the
- * internal pads' targets have refs from the internals. When we do the last
- * unref on the ghost pads, these refs should go away.
- */
-
assert_gstrefcount (fsrc, 2); /* gisrc */
assert_gstrefcount (gsink, 1);
assert_gstrefcount (gsrc, 1);
assert_gstrefcount (fsink, 2); /* gisink */
- assert_gstrefcount (gisrc, 2); /* gsink -- fixme drop ref in unlink */
+ assert_gstrefcount (gisrc, 1); /* gsink */
assert_gstrefcount (isink, 2); /* gsink */
- assert_gstrefcount (gisink, 2); /* gsrc -- fixme drop ref in unlink */
+ assert_gstrefcount (gisink, 1); /* gsrc */
assert_gstrefcount (isrc, 2); /* gsrc */
- /* while the fixme isn't fixed, check cleanup */
gst_object_unref (gsink);
assert_gstrefcount (isink, 1);
assert_gstrefcount (gisrc, 1);
@@ -216,6 +249,11 @@ GST_START_TEST (test_ghost_pads)
assert_gstrefcount (fsink, 2); /* gisrc */
gst_object_unref (gisink);
assert_gstrefcount (fsink, 1);
+
+ gst_object_unref (fsrc);
+ gst_object_unref (isrc);
+ gst_object_unref (isink);
+ gst_object_unref (fsink);
}
GST_END_TEST;
@@ -228,6 +266,7 @@ gst_ghost_pad_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_remove1);
+ tcase_add_test (tc_chain, test_remove2);
tcase_add_test (tc_chain, test_link);
tcase_add_test (tc_chain, test_ghost_pads);