From 98bce3088c6a5ee7a0fd35f104ec62b61d3aca13 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 15 Sep 2014 17:51:25 +0200 Subject: Add test for buffered recording --- test/test-mock.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/test-mock.c b/test/test-mock.c index c0acc9c..8edcf8f 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -146,6 +146,44 @@ test_recording_property (Fixture *fixture, gconstpointer data) g_assert (!uca_camera_is_recording (camera)); } +static void +test_recording_buffered (Fixture *fixture, gconstpointer data) +{ + UcaCamera *camera = UCA_CAMERA (fixture->camera); + GError *error = NULL; + guint width, height, bitdepth; + gsize buffer_size; + gchar *buffer; + + g_object_get (G_OBJECT (camera), + "roi-width", &width, + "roi-height", &height, + "sensor-bitdepth", &bitdepth, + NULL); + + buffer_size = width * height * (bitdepth <= 8 ? 1 : 2); + buffer = g_malloc0 (buffer_size); + + g_object_set (G_OBJECT (camera), + "buffered", TRUE, + "num-buffers", 5, + NULL); + + uca_camera_start_recording (camera, &error); + g_assert_no_error (error); + + for (int i = 0; i < 10; i++) { + g_assert (uca_camera_grab (camera, (gpointer) buffer, &error)); + g_assert_no_error (error); + } + + uca_camera_stop_recording (camera, &error); + g_assert_no_error (error); + + g_free (buffer); +} + + static void test_base_properties (Fixture *fixture, gconstpointer data) { @@ -274,6 +312,7 @@ int main (int argc, char *argv[]) {"/recording", test_recording}, {"/recording/signal", test_recording_signal}, {"/recording/asynchronous", test_recording_async}, + {"/recording/buffered", test_recording_buffered}, {"/properties/base", test_base_properties}, {"/properties/recording", test_recording_property}, {"/properties/binnings", test_binnings_properties}, -- cgit v1.2.3