mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
tests: fix some unit tests
This commit is contained in:
parent
076f3f6fa3
commit
e6dc4c189d
6 changed files with 32 additions and 19 deletions
|
@ -416,7 +416,7 @@ gst_audio_buffer_clip (GstBuffer * buffer, GstSegment * segment, gint rate,
|
|||
}
|
||||
|
||||
/* Get a writable buffer and apply all changes */
|
||||
ret = gst_buffer_create_sub (buffer, offset, size);
|
||||
ret = gst_buffer_create_sub (buffer, trim, size);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (ret) = timestamp;
|
||||
|
|
|
@ -42,14 +42,22 @@ static const gchar dummytext[] =
|
|||
"over a Lazy Frog Quick Brown Fox Jumps over a Lazy Frog Quick Brown Fox ";
|
||||
|
||||
static void
|
||||
src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
|
||||
src_need_data_cb (GstElement * src, guint size, gpointer data)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
GstFlowReturn ret;
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
gst_buffer_take_memory (buf,
|
||||
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
|
||||
(gpointer) dummytext, NULL, sizeof (dummytext), 0,
|
||||
sizeof (dummytext)));
|
||||
|
||||
GST_BUFFER_OFFSET (buf) = 0;
|
||||
|
||||
g_signal_emit_by_name (src, "push-buffer", buf, &ret);
|
||||
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,13 +78,12 @@ GST_START_TEST (test_text_plain_streams)
|
|||
pipe = gst_pipeline_new (NULL);
|
||||
fail_unless (pipe != NULL, "failed to create pipeline");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
fail_unless (src != NULL, "Failed to create fakesrc element");
|
||||
src = gst_element_factory_make ("appsrc", "src");
|
||||
fail_unless (src != NULL, "Failed to create appsrc element");
|
||||
|
||||
g_object_set (src, "signal-handoffs", TRUE, NULL);
|
||||
g_object_set (src, "emit-signals", TRUE, NULL);
|
||||
g_object_set (src, "num-buffers", 1, NULL);
|
||||
g_object_set (src, "can-activate-pull", FALSE, NULL);
|
||||
g_signal_connect (src, "handoff", G_CALLBACK (src_handoff_cb), NULL);
|
||||
g_signal_connect (src, "need-data", G_CALLBACK (src_need_data_cb), NULL);
|
||||
|
||||
decodebin = gst_element_factory_make ("decodebin", "decodebin");
|
||||
fail_unless (decodebin != NULL, "Failed to create decodebin element");
|
||||
|
|
|
@ -42,14 +42,22 @@ static const gchar dummytext[] =
|
|||
"over a Lazy Frog Quick Brown Fox Jumps over a Lazy Frog Quick Brown Fox ";
|
||||
|
||||
static void
|
||||
src_handoff_cb (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
|
||||
src_need_data_cb (GstElement * src, guint size, gpointer data)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
GstFlowReturn ret;
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
gst_buffer_take_memory (buf,
|
||||
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
|
||||
(gpointer) dummytext, NULL, sizeof (dummytext), 0,
|
||||
sizeof (dummytext)));
|
||||
|
||||
GST_BUFFER_OFFSET (buf) = 0;
|
||||
|
||||
g_signal_emit_by_name (src, "push-buffer", buf, &ret);
|
||||
|
||||
fail_unless (ret == GST_FLOW_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,13 +78,12 @@ GST_START_TEST (test_text_plain_streams)
|
|||
pipe = gst_pipeline_new (NULL);
|
||||
fail_unless (pipe != NULL, "failed to create pipeline");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", "src");
|
||||
fail_unless (src != NULL, "Failed to create fakesrc element");
|
||||
src = gst_element_factory_make ("appsrc", "src");
|
||||
fail_unless (src != NULL, "Failed to create appsrc element");
|
||||
|
||||
g_object_set (src, "signal-handoffs", TRUE, NULL);
|
||||
g_object_set (src, "emit-signals", TRUE, NULL);
|
||||
g_object_set (src, "num-buffers", 1, NULL);
|
||||
g_object_set (src, "can-activate-pull", FALSE, NULL);
|
||||
g_signal_connect (src, "handoff", G_CALLBACK (src_handoff_cb), NULL);
|
||||
g_signal_connect (src, "need-data", G_CALLBACK (src_need_data_cb), NULL);
|
||||
|
||||
decodebin = gst_element_factory_make ("decodebin2", "decodebin");
|
||||
fail_unless (decodebin != NULL, "Failed to create decodebin element");
|
||||
|
|
|
@ -383,8 +383,8 @@ GST_START_TEST (test_video_passthrough)
|
|||
/* pushing gives away one of the two references we have ... */
|
||||
fail_unless (gst_pad_push (myvideosrcpad, inbuffer) == GST_FLOW_OK);
|
||||
|
||||
/* should be the parent for a new subbuffer for the stamp fix-up */
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 2);
|
||||
/* should be a new buffer for the stamp fix-up */
|
||||
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
||||
fail_unless_equals_int (g_list_length (buffers), 1);
|
||||
fail_unless (GST_BUFFER_CAST (buffers->data) != inbuffer);
|
||||
fail_unless (GST_BUFFER_TIMESTAMP (GST_BUFFER_CAST (buffers->data)) ==
|
||||
|
|
|
@ -168,8 +168,7 @@ compare_buffer (GstBuffer * buf, const guint8 * data, gsize size)
|
|||
|
||||
bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
|
||||
fail_unless_equals_int (bsize, size);
|
||||
fail_unless_equals_int (memcmp (bdata,
|
||||
title_comment_header, sizeof (title_comment_header)), 0);
|
||||
fail_unless_equals_int (memcmp (bdata, data, size), 0);
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
}
|
||||
|
||||
|
|
|
@ -356,11 +356,11 @@ GST_START_TEST (test_discontinuity)
|
|||
* samples (because of the overlap/add), so it won't increment the
|
||||
* granulepos, which should be 2048 after the discontinuity.
|
||||
*/
|
||||
fail_unless (GST_BUFFER_IS_DISCONT (buffer),
|
||||
"expected discontinuous buffer");
|
||||
fail_unless (GST_BUFFER_OFFSET_END (buffer) == 2048,
|
||||
"expected granulepos after gap: %" G_GUINT64_FORMAT,
|
||||
GST_BUFFER_OFFSET_END (buffer));
|
||||
fail_unless (GST_BUFFER_IS_DISCONT (buffer),
|
||||
"expected discontinuous buffer");
|
||||
gst_buffer_unref (buffer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue