From 77833b886d1ac162cb75d749e3e4d912823cabd5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Thu, 28 Nov 2013 11:58:42 -0500 Subject: [PATCH] videoflip: Add unit test for the 'automatic' method These new tests send a tag event before seding the buffer. Tested case are an empty tag list, a tag list with orientation-180 set and an invalid orientation value. https://bugzilla.gnome.org/show_bug.cgi?id=719497 --- tests/check/elements/videofilter.c | 55 ++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/tests/check/elements/videofilter.c b/tests/check/elements/videofilter.c index 2b5ae565c4..17b67f8809 100644 --- a/tests/check/elements/videofilter.c +++ b/tests/check/elements/videofilter.c @@ -75,8 +75,8 @@ cleanup_filter (GstElement * filter) } static void -check_filter_caps (const gchar * name, GstCaps * caps, gint size, - gint num_buffers, const gchar * prop, va_list varargs) +check_filter_caps (const gchar * name, GstEvent * event, GstCaps * caps, + gint size, gint num_buffers, const gchar * prop, va_list varargs) { GstElement *filter; GstBuffer *inbuffer, *outbuffer; @@ -94,6 +94,9 @@ check_filter_caps (const gchar * name, GstCaps * caps, gint size, gst_segment_init (&segment, GST_FORMAT_TIME); fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))); + if (event) + fail_unless (gst_pad_push_event (mysrcpad, event)); + for (i = 0; i < num_buffers; ++i) { inbuffer = gst_buffer_new_and_alloc (size); /* makes valgrind's memcheck happier */ @@ -131,7 +134,8 @@ check_filter_caps (const gchar * name, GstCaps * caps, gint size, } static void -check_filter (const gchar * name, gint num_buffers, const gchar * prop, ...) +check_filter_varargs (const gchar * name, GstEvent * event, gint num_buffers, + const gchar * prop, va_list varargs) { static const struct { @@ -143,7 +147,6 @@ check_filter (const gchar * name, gint num_buffers, const gchar * prop, ...) gint i, n, r; gint size; GstCaps *allcaps, *templ = gst_caps_from_string (VIDEO_CAPS_TEMPLATE_STRING); - va_list varargs; allcaps = gst_caps_normalize (templ); @@ -158,6 +161,7 @@ check_filter (const gchar * name, gint num_buffers, const gchar * prop, ...) /* try various resolutions */ for (r = 0; r < G_N_ELEMENTS (resolutions); ++r) { GstVideoInfo info; + va_list args_cp; caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "width", G_TYPE_INT, resolutions[r].width, @@ -168,15 +172,39 @@ check_filter (const gchar * name, gint num_buffers, const gchar * prop, ...) gst_video_info_from_caps (&info, caps); size = GST_VIDEO_INFO_SIZE (&info); - va_start (varargs, prop); - check_filter_caps (name, caps, size, num_buffers, prop, varargs); - va_end (varargs); + if (event) + gst_event_ref (event); + + va_copy (args_cp, varargs); + check_filter_caps (name, event, caps, size, num_buffers, prop, args_cp); + va_end (args_cp); } gst_caps_unref (caps); } gst_caps_unref (allcaps); + if (event) + gst_event_unref (event); +} + +static void +check_filter (const gchar * name, gint num_buffers, const gchar * prop, ...) +{ + va_list varargs; + va_start (varargs, prop); + check_filter_varargs (name, NULL, num_buffers, prop, varargs); + va_end (varargs); +} + +static void +check_filter_with_event (const gchar * name, GstEvent * event, + gint num_buffers, const gchar * prop, ...) +{ + va_list varargs; + va_start (varargs, prop); + check_filter_varargs (name, event, num_buffers, prop, varargs); + va_end (varargs); } GST_START_TEST (test_videobalance) @@ -190,11 +218,24 @@ GST_END_TEST; GST_START_TEST (test_videoflip) { + GstEvent *event; + /* these we can handle with the caps */ check_filter ("videoflip", 2, "method", 0, NULL); check_filter ("videoflip", 2, "method", 2, NULL); check_filter ("videoflip", 2, "method", 4, NULL); check_filter ("videoflip", 2, "method", 5, NULL); + + event = gst_event_new_tag (gst_tag_list_new_empty ()); + check_filter_with_event ("videoflip", event, 2, "method", 8, NULL); + + event = gst_event_new_tag (gst_tag_list_new (GST_TAG_IMAGE_ORIENTATION, + "rotate-180", NULL)); + check_filter_with_event ("videoflip", event, 2, "method", 8, NULL); + + event = gst_event_new_tag (gst_tag_list_new (GST_TAG_IMAGE_ORIENTATION, + "invalid", NULL)); + check_filter_with_event ("videoflip", event, 2, "method", 8, NULL); } GST_END_TEST;