summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorShenghua Liu <EXT-Liu.shenghua@nokia.com>2009-10-14 14:01:05 +0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-04-13 12:00:31 -0300
commit3b6faa6404d4d004e0d627b3f9a1512437c35647 (patch)
tree5574f824a2eb093b9d593b817efce4c65224acb6 /tests
parent2c05df08b2daf3979efe94eb221511ccd21ef0c9 (diff)
downloadgstreamer-plugins-bad-3b6faa6404d4d004e0d627b3f9a1512437c35647.tar.gz
camerabin: update unit test to have test on recording snapshot preview
Adds a small check to verify that the preview image message is being sent on video recording.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/camerabin.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/check/elements/camerabin.c b/tests/check/elements/camerabin.c
index 624dda40c..75f09d199 100644
--- a/tests/check/elements/camerabin.c
+++ b/tests/check/elements/camerabin.c
@@ -25,6 +25,7 @@
#endif
#include <unistd.h>
+#include <glib.h>
#include <gst/gst.h>
#include <gst/check/gstcheck.h>
#include <gst/interfaces/photography.h>
@@ -40,6 +41,7 @@
static GstElement *camera;
static GMainLoop *main_loop;
static guint cycle_count = 0;
+static gboolean received_preview_msg = FALSE;
/* helper function for filenames */
static const gchar *
@@ -201,6 +203,23 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
return TRUE;
}
+static GstBusSyncReply
+bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data)
+{
+ const GstStructure *st;
+ st = gst_message_get_structure (message);
+ if (st) {
+ if (gst_structure_has_name (st, "preview-image")) {
+ GST_DEBUG ("get preview-image message");
+ received_preview_msg = TRUE;
+ }
+ }
+
+
+ return GST_BUS_PASS;
+
+}
+
static void
setup (void)
{
@@ -221,6 +240,7 @@ setup (void)
bus = gst_pipeline_get_bus (GST_PIPELINE (camera));
gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop);
+ gst_bus_set_sync_handler (bus, bus_sync_callback, main_loop);
gst_object_unref (bus);
filter_caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420");
@@ -429,6 +449,9 @@ GST_END_TEST;
GST_START_TEST (test_video_recording)
{
+ GstCaps *preview_caps;
+ preview_caps = gst_caps_from_string ("video/x-raw-rgb,width=320,height=240");
+
if (!camera)
return;
@@ -436,11 +459,19 @@ GST_START_TEST (test_video_recording)
g_object_set (camera, "mode", 1,
"filename", make_test_file_name (VIDEO_FILENAME), NULL);
+ /*Set preview-caps */
+ g_object_set (camera, "preview-caps", preview_caps, NULL);
+
GST_INFO ("starting capture");
g_signal_emit_by_name (camera, "capture-start", NULL);
/* Record for one seconds */
g_usleep (G_USEC_PER_SEC);
g_signal_emit_by_name (camera, "capture-stop", NULL);
+
+ /*check if receiving the preview-image message */
+ fail_if (!received_preview_msg,
+ "creating video recording preview image failed");
+
gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);
}