Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-base.git] / tests / check / elements / videoscale.c
index 0cf0812..e428dc0 100644 (file)
 #define LINK_CHECK_FLAGS GST_PAD_LINK_CHECK_NOTHING
 
 static GstCaps **
-videoscale_get_allowed_caps (void)
+videoscale_get_allowed_caps_for_method (int method)
 {
-  GstElement *scale = gst_element_factory_make ("videoscale", "scale");
-  GstPadTemplate *templ;
-  GstCaps *tmp, *caps, **ret;
+  GstElement *scale;
+  GstCaps *caps, **ret;
+  GstPad *pad;
   GstStructure *s;
   gint i, n;
 
-  templ =
-      gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (scale),
-      "sink");
-  fail_unless (templ != NULL);
-
-  tmp = gst_pad_template_get_caps (templ);
-  caps = gst_caps_normalize (tmp);
-  gst_caps_unref (tmp);
+  scale = gst_element_factory_make ("videoscale", "vscale");
+  g_object_set (scale, "method", method, NULL);
+  pad = gst_element_get_static_pad (scale, "sink");
+  caps = gst_pad_query_caps (pad, NULL);
+  gst_object_unref (pad);
+  gst_object_unref (scale);
 
   n = gst_caps_get_size (caps);
   ret = g_new0 (GstCaps *, n + 1);
@@ -54,10 +52,10 @@ videoscale_get_allowed_caps (void)
     s = gst_caps_get_structure (caps, i);
     ret[i] = gst_caps_new_empty ();
     gst_caps_append_structure (ret[i], gst_structure_copy (s));
+    GST_LOG ("method %d supports: %" GST_PTR_FORMAT, method, s);
   }
 
   gst_caps_unref (caps);
-  gst_object_unref (scale);
 
   return ret;
 }
@@ -212,15 +210,15 @@ on_src_handoff_passthrough (GstElement * element, GstBuffer * buffer,
   *list = g_list_prepend (*list, gst_buffer_ref (buffer));
 }
 
-GST_START_TEST (test_passthrough)
+static void
+test_passthrough (int method)
 {
   GList *l1, *l2, *src_buffers = NULL, *sink_buffers = NULL;
   GstCaps **allowed_caps = NULL, **p;
-  gint method;
   static const gint src_width = 640, src_height = 480;
   static const gint dest_width = 640, dest_height = 480;
 
-  p = allowed_caps = videoscale_get_allowed_caps ();
+  p = allowed_caps = videoscale_get_allowed_caps_for_method (method);
 
   while (*p) {
     GstCaps *caps = *p;
@@ -263,13 +261,38 @@ GST_START_TEST (test_passthrough)
       g_list_free (sink_buffers);
       sink_buffers = NULL;
     }
-
     gst_caps_unref (caps);
     p++;
   }
   g_free (allowed_caps);
 }
 
+GST_START_TEST (test_passthrough_method_0)
+{
+  test_passthrough (0);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_1)
+{
+  test_passthrough (1);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_2)
+{
+  test_passthrough (2);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_passthrough_method_3)
+{
+  test_passthrough (3);
+}
+
 GST_END_TEST;
 
 #define CREATE_TEST(name,method,src_width,src_height,dest_width,dest_height) \
@@ -277,7 +300,7 @@ GST_START_TEST (name) \
 { \
   GstCaps **allowed_caps = NULL, **p; \
   \
-  p = allowed_caps = videoscale_get_allowed_caps (); \
+  p = allowed_caps = videoscale_get_allowed_caps_for_method (method); \
   \
   while (*p) { \
     GstCaps *caps = *p; \
@@ -299,39 +322,51 @@ GST_END_TEST;
 CREATE_TEST (test_downscale_640x480_320x240_method_0, 0, 640, 480, 320, 240);
 CREATE_TEST (test_downscale_640x480_320x240_method_1, 1, 640, 480, 320, 240);
 CREATE_TEST (test_downscale_640x480_320x240_method_2, 2, 640, 480, 320, 240);
+CREATE_TEST (test_downscale_640x480_320x240_method_3, 3, 640, 480, 320, 240);
 CREATE_TEST (test_upscale_320x240_640x480_method_0, 0, 320, 240, 640, 480);
 CREATE_TEST (test_upscale_320x240_640x480_method_1, 1, 320, 240, 640, 480);
 CREATE_TEST (test_upscale_320x240_640x480_method_2, 2, 320, 240, 640, 480);
+CREATE_TEST (test_upscale_320x240_640x480_method_3, 3, 320, 240, 640, 480);
 CREATE_TEST (test_downscale_640x480_1x1_method_0, 0, 640, 480, 1, 1);
 CREATE_TEST (test_downscale_640x480_1x1_method_1, 1, 640, 480, 1, 1);
 CREATE_TEST (test_downscale_640x480_1x1_method_2, 2, 640, 480, 1, 1);
+CREATE_TEST (test_downscale_640x480_1x1_method_3, 3, 640, 480, 1, 1);
 CREATE_TEST (test_upscale_1x1_640x480_method_0, 0, 1, 1, 640, 480);
 CREATE_TEST (test_upscale_1x1_640x480_method_1, 1, 1, 1, 640, 480);
 CREATE_TEST (test_upscale_1x1_640x480_method_2, 2, 1, 1, 640, 480);
+CREATE_TEST (test_upscale_1x1_640x480_method_3, 3, 1, 1, 640, 480);
 CREATE_TEST (test_downscale_641x481_111x30_method_0, 0, 641, 481, 111, 30);
 CREATE_TEST (test_downscale_641x481_111x30_method_1, 1, 641, 481, 111, 30);
 CREATE_TEST (test_downscale_641x481_111x30_method_2, 2, 641, 481, 111, 30);
+CREATE_TEST (test_downscale_641x481_111x30_method_3, 3, 641, 481, 111, 30);
 CREATE_TEST (test_upscale_111x30_641x481_method_0, 0, 111, 30, 641, 481);
 CREATE_TEST (test_upscale_111x30_641x481_method_1, 1, 111, 30, 641, 481);
 CREATE_TEST (test_upscale_111x30_641x481_method_2, 2, 111, 30, 641, 481);
+CREATE_TEST (test_upscale_111x30_641x481_method_3, 2, 111, 30, 641, 481);
 CREATE_TEST (test_downscale_641x481_30x111_method_0, 0, 641, 481, 30, 111);
 CREATE_TEST (test_downscale_641x481_30x111_method_1, 1, 641, 481, 30, 111);
 CREATE_TEST (test_downscale_641x481_30x111_method_2, 2, 641, 481, 30, 111);
+CREATE_TEST (test_downscale_641x481_30x111_method_3, 3, 641, 481, 30, 111);
 CREATE_TEST (test_upscale_30x111_641x481_method_0, 0, 30, 111, 641, 481);
 CREATE_TEST (test_upscale_30x111_641x481_method_1, 1, 30, 111, 641, 481);
 CREATE_TEST (test_upscale_30x111_641x481_method_2, 2, 30, 111, 641, 481);
+CREATE_TEST (test_upscale_30x111_641x481_method_3, 3, 30, 111, 641, 481);
 CREATE_TEST (test_downscale_640x480_320x1_method_0, 0, 640, 480, 320, 1);
 CREATE_TEST (test_downscale_640x480_320x1_method_1, 1, 640, 480, 320, 1);
 CREATE_TEST (test_downscale_640x480_320x1_method_2, 2, 640, 480, 320, 1);
+CREATE_TEST (test_downscale_640x480_320x1_method_3, 3, 640, 480, 320, 1);
 CREATE_TEST (test_upscale_320x1_640x480_method_0, 0, 320, 1, 640, 480);
 CREATE_TEST (test_upscale_320x1_640x480_method_1, 1, 320, 1, 640, 480);
 CREATE_TEST (test_upscale_320x1_640x480_method_2, 2, 320, 1, 640, 480);
+CREATE_TEST (test_upscale_320x1_640x480_method_3, 3, 320, 1, 640, 480);
 CREATE_TEST (test_downscale_640x480_1x240_method_0, 0, 640, 480, 1, 240);
 CREATE_TEST (test_downscale_640x480_1x240_method_1, 1, 640, 480, 1, 240);
 CREATE_TEST (test_downscale_640x480_1x240_method_2, 2, 640, 480, 1, 240);
+CREATE_TEST (test_downscale_640x480_1x240_method_3, 3, 640, 480, 1, 240);
 CREATE_TEST (test_upscale_1x240_640x480_method_0, 0, 1, 240, 640, 480);
 CREATE_TEST (test_upscale_1x240_640x480_method_1, 1, 1, 240, 640, 480);
 CREATE_TEST (test_upscale_1x240_640x480_method_2, 2, 1, 240, 640, 480);
+CREATE_TEST (test_upscale_1x240_640x480_method_3, 3, 1, 240, 640, 480);
 
 typedef struct
 {
@@ -823,6 +858,13 @@ GST_START_TEST (test_basetransform_negotiation)
 
 GST_END_TEST;
 
+#ifndef tcase_skip_broken_test
+#define tcase_skip_broken_test(chain,test_func) \
+  if (0) { tcase_add_test(chain,test_func); } else { \
+    GST_ERROR ("FIXME: skipping test %s because it's broken.", G_STRINGIFY (test_func)); \
+  }
+#endif
+
 static Suite *
 videoscale_suite (void)
 {
@@ -831,43 +873,58 @@ videoscale_suite (void)
 
   suite_add_tcase (s, tc_chain);
   tcase_set_timeout (tc_chain, 180);
-  tcase_add_test (tc_chain, test_passthrough);
+  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);
+  tcase_add_test (tc_chain, test_passthrough_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_2);
+  tcase_add_test (tc_chain, test_downscale_640x480_320x240_method_3);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_320x240_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_1x1_method_2);
+  tcase_skip_broken_test (tc_chain, test_downscale_640x480_1x1_method_3);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_1x1_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_0);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_1);
   tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_2);
+  tcase_add_test (tc_chain, test_downscale_641x481_111x30_method_3);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_0);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_1);
   tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_2);
+  tcase_add_test (tc_chain, test_upscale_111x30_641x481_method_3);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_0);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_1);
   tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_2);
+  tcase_add_test (tc_chain, test_downscale_641x481_30x111_method_3);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_0);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_1);
   tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_2);
+  tcase_add_test (tc_chain, test_upscale_30x111_641x481_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_320x1_method_2);
+  tcase_skip_broken_test (tc_chain, test_downscale_640x480_320x1_method_3);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_320x1_640x480_method_2);
+  tcase_skip_broken_test (tc_chain, test_upscale_320x1_640x480_method_3);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_0);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_1);
   tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_2);
+  tcase_add_test (tc_chain, test_downscale_640x480_1x240_method_3);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_0);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_1);
   tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_2);
+  tcase_add_test (tc_chain, test_upscale_1x240_640x480_method_3);
   tcase_add_test (tc_chain, test_negotiation);
 #if 0
   tcase_add_test (tc_chain, test_reverse_negotiation);