y4menc: adjust unit test to element behaviour

This commit is contained in:
Mark Nauwelaerts 2010-04-20 12:17:26 +02:00
parent c3dc498278
commit 798ccb7e97

View file

@ -30,6 +30,7 @@
static GstPad *mysrcpad, *mysinkpad; static GstPad *mysrcpad, *mysinkpad;
#define VIDEO_CAPS_STRING "video/x-raw-yuv, " \ #define VIDEO_CAPS_STRING "video/x-raw-yuv, " \
"format = (fourcc) I420, "\
"width = (int) 384, " \ "width = (int) 384, " \
"height = (int) 288, " \ "height = (int) 288, " \
"framerate = (fraction) 25/1, " \ "framerate = (fraction) 25/1, " \
@ -83,7 +84,9 @@ GST_START_TEST (test_y4m)
GstBuffer *inbuffer, *outbuffer; GstBuffer *inbuffer, *outbuffer;
GstCaps *caps; GstCaps *caps;
int i, num_buffers, size; int i, num_buffers, size;
const gchar *data0 = "YUV4MPEG2 W384 H288 Ip F25:1 A1:1\nFRAME\n"; const gchar *data0 = "YUV4MPEG2 W384 H288 Ip F25:1 A1:1\n";
const gchar *data1 = "YUV4MPEG2 C420 W384 H288 Ip F25:1 A1:1\n";
const gchar *data2 = "FRAME\n";
y4menc = setup_y4menc (); y4menc = setup_y4menc ();
fail_unless (gst_element_set_state (y4menc, fail_unless (gst_element_set_state (y4menc,
@ -107,15 +110,27 @@ GST_START_TEST (test_y4m)
/* clean up buffers */ /* clean up buffers */
for (i = 0; i < num_buffers; ++i) { for (i = 0; i < num_buffers; ++i) {
gchar *data;
outbuffer = GST_BUFFER (buffers->data); outbuffer = GST_BUFFER (buffers->data);
fail_if (outbuffer == NULL); fail_if (outbuffer == NULL);
switch (i) { switch (i) {
case 0: case 0:
fail_unless (strlen (data0) == 40); fail_unless (GST_BUFFER_SIZE (outbuffer) > size);
fail_unless (GST_BUFFER_SIZE (outbuffer) == size + 40);
fail_unless (memcmp (data0, GST_BUFFER_DATA (outbuffer), fail_unless (memcmp (data0, GST_BUFFER_DATA (outbuffer),
strlen (data0)) == 0); strlen (data0)) == 0 ||
memcmp (data1, GST_BUFFER_DATA (outbuffer), strlen (data1)) == 0);
/* so we know there is a newline */
data = (gchar *) GST_BUFFER_DATA (outbuffer);
data = strchr (data, '\n');
fail_unless (data != NULL);
data++;
fail_unless (memcmp (data2, data, strlen (data2)) == 0);
data += strlen (data2);
/* remainder must be frame data */
fail_unless ((data - (gchar *) GST_BUFFER_DATA (outbuffer)) + size ==
GST_BUFFER_SIZE (outbuffer));
break; break;
default: default:
break; break;