tests: fix remaining unit tests

This commit is contained in:
Wim Taymans 2011-03-28 15:51:46 +02:00
parent 40dc12da3a
commit 076f3f6fa3
3 changed files with 19 additions and 6 deletions

View file

@ -24,7 +24,6 @@
#include <gst/gst.h>
#include <gst/check/gstcheck.h>
#include <gst/app/gstappbuffer.h>
#include <gst/app/gstapp-marshal.h>
#include <gst/app/gstappsink.h>
#include <gst/app/gstappsrc.h>

View file

@ -606,14 +606,16 @@ GST_START_TEST (test_convert_frame)
guint8 *data;
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
data = GST_BUFFER_DATA (from_buffer);
data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
data[4 * i + 0] = 0; /* x */
data[4 * i + 1] = 255; /* R */
data[4 * i + 2] = 0; /* G */
data[4 * i + 3] = 0; /* B */
}
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
640, 480, 25, 1, 1, 1);
gst_buffer_set_caps (from_buffer, from_caps);
@ -675,14 +677,16 @@ GST_START_TEST (test_convert_frame_async)
ConvertFrameContext cf_data = { NULL, NULL, NULL };
from_buffer = gst_buffer_new_and_alloc (640 * 480 * 4);
data = GST_BUFFER_DATA (from_buffer);
data = gst_buffer_map (from_buffer, NULL, NULL, GST_MAP_WRITE);
for (i = 0; i < 640 * 480; i++) {
data[4 * i + 0] = 0; /* x */
data[4 * i + 1] = 255; /* R */
data[4 * i + 2] = 0; /* G */
data[4 * i + 3] = 0; /* B */
}
gst_buffer_unmap (from_buffer, data, 640 * 480 * 4);
from_caps = gst_video_format_new_caps (GST_VIDEO_FORMAT_xRGB,
640, 480, 25, 1, 1, 1);
gst_buffer_set_caps (from_buffer, from_caps);

View file

@ -122,6 +122,11 @@ static int n_in_caps = 0;
static gboolean
buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
{
guint8 *data;
gsize size;
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_IN_CAPS)) {
GstCaps *caps;
GstStructure *s;
@ -143,22 +148,27 @@ buffer_probe_cb (GstPad * pad, GstBuffer * buffer)
for (i = 0; i < 3; ++i) {
GValue *val;
guint8 *data2;
gsize size2;
val = &g_array_index (buffers, GValue, i);
buf = g_value_peek_pointer (val);
fail_unless (GST_IS_BUFFER (buf));
if (GST_BUFFER_SIZE (buf) == GST_BUFFER_SIZE (buffer)) {
if (memcmp (GST_BUFFER_DATA (buf), GST_BUFFER_DATA (buffer),
GST_BUFFER_SIZE (buffer)) == 0) {
data2 = gst_buffer_map (buf, &size2, NULL, GST_MAP_READ);
if (size2 == size) {
if (memcmp (data2, data, size) == 0) {
found = TRUE;
}
}
gst_buffer_unmap (buf, data2, size2);
}
fail_unless (found, "Did not find incoming IN_CAPS buffer %p on caps",
buffer);
gst_caps_unref (caps);
}
gst_buffer_unmap (buffer, data, size);
return TRUE;
}