tests: fix up rgvolume test for basetransform event caching
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 10 Dec 2011 12:32:32 +0000 (12:32 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 10 Dec 2011 13:05:07 +0000 (13:05 +0000)
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

index 3add27a..5226259 100644 (file)
@@ -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,