tests/check/gst/gstghostpad.c: Add some more unit-tests for the ghostpad notify signa...
authorWim Taymans <wim.taymans@gmail.com>
Fri, 19 Dec 2008 11:24:36 +0000 (11:24 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Fri, 19 Dec 2008 11:24:36 +0000 (11:24 +0000)
Original commit message from CVS:
* tests/check/gst/gstghostpad.c: (ghost_notify_caps),
(GST_START_TEST):
Add some more unit-tests for the ghostpad notify signal, one of which
currently fails.

ChangeLog
tests/check/gst/gstghostpad.c

index a84db62..a0c8cee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-19  Wim Taymans  <wim.taymans@collabora.co.uk>
+
+       * tests/check/gst/gstghostpad.c: (ghost_notify_caps),
+       (GST_START_TEST):
+       Add some more unit-tests for the ghostpad notify signal, one of which
+       currently fails.
+
 2008-12-19  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
 
        * win32/common/libgstreamer.def:
index ed39268..258b54c 100644 (file)
@@ -671,6 +671,7 @@ GST_END_TEST;
 static void
 ghost_notify_caps (GObject * object, GParamSpec * pspec, gpointer * user_data)
 {
+  GST_DEBUG ("caps notify called");
   (*(gint *) user_data)++;
 }
 
@@ -691,7 +692,8 @@ GST_START_TEST (test_ghost_pads_forward_setcaps)
   src = gst_pad_new_from_template (src_template, "src");
   sink = gst_pad_new_from_template (sink_template, "sink");
 
-  /* ghost source pad */
+  /* ghost source pad, setting caps on the source influences the caps of the
+   * ghostpad. */
   ghost = gst_ghost_pad_new ("ghostsrc", src);
   g_signal_connect (ghost, "notify::caps",
       G_CALLBACK (ghost_notify_caps), &notify_counter);
@@ -706,7 +708,28 @@ GST_START_TEST (test_ghost_pads_forward_setcaps)
   gst_object_unref (ghost);
   gst_caps_unref (caps1);
 
-  /* ghost sink pad */
+  fail_unless (gst_pad_set_caps (src, NULL));
+
+  /* source 2, setting the caps on the ghostpad does not influence the caps of
+   * the target */
+  notify_counter = 0;
+  ghost = gst_ghost_pad_new ("ghostsrc", src);
+  g_signal_connect (ghost, "notify::caps",
+      G_CALLBACK (ghost_notify_caps), &notify_counter);
+  fail_unless (gst_pad_link (ghost, sink) == GST_PAD_LINK_OK);
+
+  caps1 = gst_caps_from_string ("meh");
+  fail_unless (gst_pad_set_caps (ghost, caps1));
+  caps2 = GST_PAD_CAPS (src);
+  fail_unless (gst_caps_is_equal (caps1, caps2));
+  fail_unless_equals_int (notify_counter, 1);
+
+  gst_object_unref (ghost);
+  gst_caps_unref (caps1);
+
+
+  /* ghost sink pad. Setting caps on the ghostpad will also set those caps on
+   * the target pad. */
   notify_counter = 0;
   ghost = gst_ghost_pad_new ("ghostsink", sink);
   g_signal_connect (ghost, "notify::caps",
@@ -719,6 +742,26 @@ GST_START_TEST (test_ghost_pads_forward_setcaps)
   fail_unless (gst_caps_is_equal (caps1, caps2));
   fail_unless_equals_int (notify_counter, 1);
 
+  gst_object_unref (ghost);
+  gst_caps_unref (caps1);
+
+  /* sink pad 2, setting caps just on the target pad should not influence the caps
+   * on the ghostpad. */
+  notify_counter = 0;
+  ghost = gst_ghost_pad_new ("ghostsink", sink);
+  g_signal_connect (ghost, "notify::caps",
+      G_CALLBACK (ghost_notify_caps), &notify_counter);
+  fail_unless (gst_pad_link (src, ghost) == GST_PAD_LINK_OK);
+
+  caps1 = gst_caps_from_string ("muh");
+  fail_unless (gst_pad_set_caps (sink, caps1));
+  caps2 = GST_PAD_CAPS (ghost);
+  fail_unless (caps2 == NULL);
+  fail_unless_equals_int (notify_counter, 0);
+
+  gst_object_unref (ghost);
+  gst_caps_unref (caps1);
+
   gst_object_unref (src);
   gst_object_unref (sink);
   gst_object_unref (src_template);