From e50267593ef76c9b0a3d2312a316dfca04aeb4fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 5 Aug 2010 01:09:02 +0100 Subject: [PATCH] tests: add basic unit test for gst_pad_proxy_getcaps() https://bugzilla.gnome.org/show_bug.cgi?id=624203 --- tests/check/gst/gstutils.c | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/check/gst/gstutils.c b/tests/check/gst/gstutils.c index 69d02220a7..f5e95fa88c 100644 --- a/tests/check/gst/gstutils.c +++ b/tests/check/gst/gstutils.c @@ -948,6 +948,83 @@ GST_END_TEST; #endif #endif +GST_START_TEST (test_pad_proxy_getcaps_aggregation) +{ + GstElement *tee, *sink1, *sink2; + GstCaps *caps; + GstPad *tee_src1, *tee_src2, *tee_sink, *sink1_sink, *sink2_sink; + + tee = gst_element_factory_make ("tee", "tee"); + + sink1 = gst_element_factory_make ("fakesink", "sink1"); + tee_src1 = gst_element_get_request_pad (tee, "src%d"); + sink1_sink = gst_element_get_static_pad (sink1, "sink"); + fail_unless_equals_int (gst_pad_link (tee_src1, sink1_sink), GST_PAD_LINK_OK); + + sink2 = gst_element_factory_make ("fakesink", "sink2"); + tee_src2 = gst_element_get_request_pad (tee, "src%d"); + sink2_sink = gst_element_get_static_pad (sink2, "sink"); + fail_unless_equals_int (gst_pad_link (tee_src2, sink2_sink), GST_PAD_LINK_OK); + + tee_sink = gst_element_get_static_pad (tee, "sink"); + + /* by default, ANY caps should intersect to ANY */ + caps = gst_pad_get_caps (tee_sink); + GST_INFO ("got caps: %" GST_PTR_FORMAT, caps); + fail_unless (caps != NULL); + fail_unless (gst_caps_is_any (caps)); + gst_caps_unref (caps); + + /* these don't intersect we should get empty caps */ + caps = gst_caps_new_simple ("foo/bar", NULL); + fail_unless (gst_pad_set_caps (sink1_sink, caps)); + gst_pad_use_fixed_caps (sink1_sink); + gst_caps_unref (caps); + + caps = gst_caps_new_simple ("bar/ter", NULL); + fail_unless (gst_pad_set_caps (sink2_sink, caps)); + gst_pad_use_fixed_caps (sink2_sink); + gst_caps_unref (caps); + + caps = gst_pad_get_caps (tee_sink); + GST_INFO ("got caps: %" GST_PTR_FORMAT, caps); + fail_unless (caps != NULL); + fail_unless (gst_caps_is_empty (caps)); + gst_caps_unref (caps); + + /* test intersection */ + caps = gst_caps_new_simple ("foo/bar", "barversion", G_TYPE_INT, 1, NULL); + fail_unless (gst_pad_set_caps (sink2_sink, caps)); + gst_pad_use_fixed_caps (sink2_sink); + gst_caps_unref (caps); + + caps = gst_pad_get_caps (tee_sink); + GST_INFO ("got caps: %" GST_PTR_FORMAT, caps); + fail_unless (caps != NULL); + fail_if (gst_caps_is_empty (caps)); + { + GstStructure *s = gst_caps_get_structure (caps, 0); + + fail_unless_equals_string (gst_structure_get_name (s), "foo/bar"); + fail_unless (gst_structure_has_field_typed (s, "barversion", G_TYPE_INT)); + } + gst_caps_unref (caps); + + /* clean up */ + gst_element_release_request_pad (tee, tee_src1); + gst_object_unref (tee_src1); + gst_element_release_request_pad (tee, tee_src2); + gst_object_unref (tee_src2); + gst_object_unref (tee_sink); + gst_object_unref (tee); + gst_object_unref (sink1_sink); + gst_object_unref (sink1); + gst_object_unref (sink2_sink); + gst_object_unref (sink2); +} + +GST_END_TEST; + static Suite * gst_utils_suite (void) { @@ -978,6 +1055,8 @@ gst_utils_suite (void) tcase_add_test (tc_chain, test_element_unlink); tcase_add_test (tc_chain, test_set_value_from_string); tcase_add_test (tc_chain, test_binary_search); + + tcase_add_test (tc_chain, test_pad_proxy_getcaps_aggregation); return s; }