[0.11] gst-plugins-good: tests: fix up rgvolume test for basetransform event caching

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 05:33:00 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: 60e53346af0c23588630879eac3de14f1e1fe8fa
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=60e53346af0c23588630879eac3de14f1e1fe8fa

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Sat Dec 10 12:32:32 2011 +0000

tests: fix up rgvolume test for basetransform event caching

Some tests assumed that tag events would always pushed through
immediately, which isn't the case any longer, so push a newsegment
event and an empty buffer first.

---

 tests/check/elements/rgvolume.c |   45 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/tests/check/elements/rgvolume.c b/tests/check/elements/rgvolume.c
index 3add27a..5226259 100644
--- a/tests/check/elements/rgvolume.c
+++ b/tests/check/elements/rgvolume.c
@@ -49,6 +49,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS (RG_VOLUME_CAPS_TEMPLATE_STRING)
     );
 
+static GstBuffer *test_buffer_new (gfloat value);
+
 /* gstcheck sets up a chain function that appends buffers to a global list.
  * This is our equivalent of that for event handling. */
 static gboolean
@@ -79,6 +81,35 @@ setup_rgvolume (void)
 }
 
 static void
+send_newsegment_and_empty_buffer (void)
+{
+  GstBuffer *buf;
+  GstEvent *ev;
+
+  fail_unless (g_list_length (events) == 0);
+
+  ev = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0);
+  fail_unless (gst_pad_push_event (mysrcpad, ev),
+      "Pushing newsegment event failed");
+
+  buf = test_buffer_new (0.0);
+  GST_BUFFER_SIZE (buf) = 0;
+  GST_BUFFER_DURATION (buf) = 0;
+  GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET (buf);
+  fail_unless (gst_pad_push (mysrcpad, buf) == GST_FLOW_OK);
+
+  fail_unless (g_list_length (events) == 1);
+  fail_unless (events->data == ev);
+  gst_mini_object_unref ((GstMiniObject *) events->data);
+  events = g_list_remove (events, ev);
+
+  fail_unless (g_list_length (buffers) == 1);
+  fail_unless (buffers->data == buf);
+  gst_mini_object_unref ((GstMiniObject *) buffers->data);
+  buffers = g_list_remove (buffers, buf);
+}
+
+static void
 cleanup_rgvolume (GstElement * element)
 {
   GST_DEBUG ("cleanup_rgvolume");
@@ -288,6 +319,8 @@ GST_START_TEST (test_events)
 
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, +4.95, GST_TAG_TRACK_PEAK, 0.59463,
@@ -336,6 +369,8 @@ GST_START_TEST (test_simple)
       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, -3.45, GST_TAG_TRACK_PEAK, 1.0,
@@ -376,6 +411,8 @@ GST_START_TEST (test_fallback_gain)
       "pre-amp", -6.00, "fallback-gain", -3.00, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, +3.5, GST_TAG_TRACK_PEAK, 1.0,
@@ -419,6 +456,8 @@ GST_START_TEST (test_fallback_track)
       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, +2.11, GST_TAG_TRACK_PEAK, 1.0, NULL);
@@ -444,6 +483,8 @@ GST_START_TEST (test_fallback_album)
       "pre-amp", -6.00, "fallback-gain", +1.23, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_ALBUM_GAIN, +3.73, GST_TAG_ALBUM_PEAK, 1.0, NULL);
@@ -466,6 +507,8 @@ GST_START_TEST (test_headroom)
       "pre-amp", +0.00, "fallback-gain", +1.23, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, +3.50, GST_TAG_TRACK_PEAK, 1.0, NULL);
@@ -508,6 +551,8 @@ GST_START_TEST (test_reference_level)
       "headroom", +0.00, "pre-amp", +0.00, "fallback-gain", +1.23, NULL);
   set_playing_state (element);
 
+  send_newsegment_and_empty_buffer ();
+
   tag_list = gst_tag_list_new ();
   gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE,
       GST_TAG_TRACK_GAIN, 0.00, GST_TAG_TRACK_PEAK, 0.2,



More information about the gstreamer-commits mailing list