summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2012-07-17 00:31:14 +0100
committerTim-Philipp Müller <tim@centricular.net>2012-07-17 00:31:14 +0100
commit73330fc5682953b050c644a4409fa4233cceb748 (patch)
tree3db587f12f50a56549013171a0a9b28c6143f97b /tests
parente29098f8f02fa082ecfdef844023f0fbafeb8339 (diff)
tests: add videoscale test to check pad template formats
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/videoscale.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/tests/check/elements/videoscale.c b/tests/check/elements/videoscale.c
index f4fb3c871..86fc3af52 100644
--- a/tests/check/elements/videoscale.c
+++ b/tests/check/elements/videoscale.c
@@ -29,6 +29,122 @@
/* kids, don't do this at home, skipping checks is *BAD* */
#define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
+static guint
+get_num_formats (void)
+{
+ guint i = 2;
+
+ while (gst_video_format_to_string ((GstFormat) i) != NULL)
+ ++i;
+
+ return i;
+}
+
+static void
+check_pad_template (GstPadTemplate * tmpl)
+{
+ const GValue *list_val, *fmt_val;
+ GstStructure *s;
+ gboolean *formats_supported;
+ GstCaps *caps;
+ guint i, num_formats;
+
+ num_formats = get_num_formats ();
+ formats_supported = g_new0 (gboolean, num_formats);
+
+ caps = gst_pad_template_get_caps (tmpl);
+
+ /* If this fails, we need to update this unit test */
+ fail_unless_equals_int (gst_caps_get_size (caps), 1);
+ s = gst_caps_get_structure (caps, 0);
+
+ fail_unless (gst_structure_has_name (s, "video/x-raw"));
+
+ list_val = gst_structure_get_value (s, "format");
+ fail_unless (list_val != NULL);
+ /* If this fails, we need to update this unit test */
+ fail_unless (GST_VALUE_HOLDS_LIST (list_val));
+
+ for (i = 0; i < gst_value_list_get_size (list_val); ++i) {
+ GstVideoFormat fmt;
+ const gchar *fmt_str;
+
+ fmt_val = gst_value_list_get_value (list_val, i);
+ fail_unless (G_VALUE_HOLDS_STRING (fmt_val));
+ fmt_str = g_value_get_string (fmt_val);
+ GST_LOG ("format string: '%s'", fmt_str);
+ fmt = gst_video_format_from_string (fmt_str);
+ if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
+ g_error ("Unknown raw format '%s' in pad template caps", fmt_str);
+ formats_supported[(guint) fmt] = TRUE;
+ }
+
+ gst_caps_unref (caps);
+
+ for (i = 2; i < num_formats; ++i) {
+ if (!formats_supported[i]) {
+ const gchar *fmt_str = gst_video_format_to_string ((GstVideoFormat) i);
+
+ switch (i) {
+ case GST_VIDEO_FORMAT_v210:
+ case GST_VIDEO_FORMAT_v216:
+ case GST_VIDEO_FORMAT_NV12:
+ case GST_VIDEO_FORMAT_NV21:
+ case GST_VIDEO_FORMAT_UYVP:
+ case GST_VIDEO_FORMAT_A420:
+ case GST_VIDEO_FORMAT_YUV9:
+ case GST_VIDEO_FORMAT_YVU9:
+ case GST_VIDEO_FORMAT_IYU1:
+ case GST_VIDEO_FORMAT_r210:{
+ static gboolean shown_fixme[100] = { FALSE, };
+
+ if (!shown_fixme[i]) {
+ GST_ERROR ("FIXME: add %s support to videoscale", fmt_str);
+ shown_fixme[i] = TRUE;
+ }
+ break;
+ }
+ case GST_VIDEO_FORMAT_BGR16:
+ case GST_VIDEO_FORMAT_BGR15:
+ case GST_VIDEO_FORMAT_RGB8P:
+ case GST_VIDEO_FORMAT_I420_10BE:
+ case GST_VIDEO_FORMAT_I420_10LE:
+ GST_LOG ("Ignoring lack of support for format %s", fmt_str);
+ break;
+ default:
+ g_error ("videoconvert doesn't support format '%s'", fmt_str);
+ break;
+ }
+ }
+ }
+
+ g_free (formats_supported);
+}
+
+GST_START_TEST (test_template_formats)
+{
+ GstElementFactory *f;
+ GstPadTemplate *t;
+ const GList *pad_templates;
+
+ f = gst_element_factory_find ("videoscale");
+ fail_unless (f != NULL);
+
+ pad_templates = gst_element_factory_get_static_pad_templates (f);
+ fail_unless_equals_int (g_list_length ((GList *) pad_templates), 2);
+
+ t = gst_static_pad_template_get (pad_templates->data);
+ check_pad_template (GST_PAD_TEMPLATE (t));
+ gst_object_unref (t);
+ t = gst_static_pad_template_get (pad_templates->next->data);
+ check_pad_template (GST_PAD_TEMPLATE (t));
+ gst_object_unref (t);
+
+ gst_object_unref (f);
+}
+
+GST_END_TEST;
+
static GstCaps **
videoscale_get_allowed_caps_for_method (int method)
{
@@ -875,6 +991,7 @@ videoscale_suite (void)
suite_add_tcase (s, tc_chain);
tcase_set_timeout (tc_chain, 180);
+ tcase_add_test (tc_chain, test_template_formats);
tcase_add_test (tc_chain, test_passthrough_method_0);
tcase_add_test (tc_chain, test_passthrough_method_1);
tcase_add_test (tc_chain, test_passthrough_method_2);