tests: camerabin: add test for capture with different caps
authorThiago Santos <thiagoss@osg.samsung.com>
Mon, 20 Apr 2015 11:20:37 +0000 (08:20 -0300)
committerThiago Santos <thiagoss@osg.samsung.com>
Tue, 21 Apr 2015 13:00:44 +0000 (10:00 -0300)
Adds a test to verify that viewfinder and image capture caps
can be set to non-intersecting caps and still work.

https://bugzilla.gnome.org/show_bug.cgi?id=724868

tests/check/elements/camerabin.c

index 0061606..b5ef62d 100644 (file)
@@ -707,7 +707,8 @@ wait_for_idle_state (void)
   fail_unless (idle);
 }
 
-GST_START_TEST (test_single_image_capture)
+static void
+run_single_image_capture_test (GstCaps * viewfinder_caps, GstCaps * image_caps)
 {
   gboolean idle;
   GstMessage *msg;
@@ -717,6 +718,11 @@ GST_START_TEST (test_single_image_capture)
   /* set still image mode */
   g_object_set (camera, "mode", 1, "location", image_filename, NULL);
 
+  if (viewfinder_caps)
+    g_object_set (camera, "viewfinder-caps", viewfinder_caps, NULL);
+  if (image_caps)
+    g_object_set (camera, "image-capture-caps", image_caps, NULL);
+
   if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
       GST_STATE_CHANGE_FAILURE) {
     GST_WARNING ("setting camerabin to PLAYING failed");
@@ -743,6 +749,27 @@ GST_START_TEST (test_single_image_capture)
   remove_file (image_filename, 0);
 }
 
+GST_START_TEST (test_single_image_capture)
+{
+  run_single_image_capture_test (NULL, NULL);
+}
+
+GST_END_TEST;
+
+
+/* Verify that incompatible caps can be used in viewfinder and image capture
+ * at the same time */
+GST_START_TEST (test_single_image_capture_with_different_caps)
+{
+  GstCaps *vf_caps =
+      gst_caps_from_string ("video/x-raw, width=480, height=320");
+  GstCaps *img_caps =
+      gst_caps_from_string ("video/x-raw, width=800, height=600");
+  run_single_image_capture_test (vf_caps, img_caps);
+  gst_caps_unref (vf_caps);
+  gst_caps_unref (img_caps);
+}
+
 GST_END_TEST;
 
 
@@ -1604,6 +1631,7 @@ camerabin_suite (void)
     tcase_add_checked_fixture (tc_basic, tests[i].setup_func, teardown);
 
     tcase_add_test (tc_basic, test_single_image_capture);
+    tcase_add_test (tc_basic, test_single_image_capture_with_different_caps);
     tcase_add_test (tc_basic, test_single_video_recording);
     tcase_add_test (tc_basic, test_image_video_cycle);
     if (gst_plugin_feature_check_version ((GstPluginFeature *) jpegenc_factory,