gst-plugins-bad: tests: camerabin2: Adds another 'idle' test

Thiago Sousa Santos thiagoss at kemper.freedesktop.org
Wed Mar 23 13:16:27 PDT 2011


Module: gst-plugins-bad
Branch: master
Commit: 19429aa797db5a76a084be9377d96d2153b1e41b
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=19429aa797db5a76a084be9377d96d2153b1e41b

Author: Thiago Santos <thiago.sousa.santos at collabora.co.uk>
Date:   Tue Mar 15 15:47:21 2011 -0300

tests: camerabin2: Adds another 'idle' test

Adds another test that checks that the idle property works
correctly when bogus start-capture calls are made.

This fails currently, but should remind us of fixing it in
the future by defining a proper error reporting from camera
sources to camerabin2

---

 tests/check/elements/camerabin2.c |   51 +++++++++++++++++++++++++++++++++++++
 1 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/tests/check/elements/camerabin2.c b/tests/check/elements/camerabin2.c
index 01cdc95..0a5a7e4 100644
--- a/tests/check/elements/camerabin2.c
+++ b/tests/check/elements/camerabin2.c
@@ -1031,6 +1031,55 @@ GST_START_TEST (test_supported_caps)
 GST_END_TEST;
 
 
+GST_START_TEST (test_idle_property)
+{
+  gboolean idle;
+  if (!camera)
+    return;
+
+  /* Set video recording mode */
+  g_object_set (camera, "mode", 2,
+      "location", make_test_file_name (VIDEO_FILENAME, -1), NULL);
+
+  if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) ==
+      GST_STATE_CHANGE_FAILURE) {
+    GST_WARNING ("setting camerabin to PLAYING failed");
+    gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
+    gst_object_unref (camera);
+    camera = NULL;
+  }
+
+  GST_INFO ("starting capture");
+  fail_unless (camera != NULL);
+  g_object_get (camera, "idle", &idle, NULL);
+  fail_unless (idle);
+  g_signal_emit_by_name (camera, "start-capture", NULL);
+  g_object_get (camera, "idle", &idle, NULL);
+  fail_unless (!idle);
+
+  /* emit a second start-capture that should be ignored */
+  g_signal_emit_by_name (camera, "start-capture", NULL);
+
+  /* Record for one seconds  */
+  g_timeout_add_seconds (VIDEO_DURATION, (GSourceFunc) g_main_loop_quit,
+      main_loop);
+  g_main_loop_run (main_loop);
+
+  g_signal_emit_by_name (camera, "stop-capture", NULL);
+
+  check_preview_image ();
+
+  g_object_get (camera, "idle", &idle, NULL);
+  fail_unless (idle);
+
+  gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
+
+  check_file_validity (VIDEO_FILENAME, 0, NULL, 0, 0, WITH_AUDIO);
+}
+
+GST_END_TEST;
+
+
 GST_START_TEST (test_image_custom_filter)
 {
   GstElement *vf_filter;
@@ -1297,6 +1346,8 @@ camerabin_suite (void)
 
     tcase_add_test (tc_basic, test_video_capture_with_tags);
 
+    tcase_add_test (tc_basic, test_idle_property);
+
     tcase_add_test (tc_basic, test_image_custom_filter);
     tcase_add_test (tc_basic, test_video_custom_filter);
 



More information about the gstreamer-commits mailing list