From 034204d3d8d1a32b1a20e50697c5f81db6fb20cf Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 31 Aug 2012 23:14:16 +0200 Subject: Initial plugin manager --- test/test-mock.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index 7594a3a..625a3fe 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -1,6 +1,7 @@ #include #include "uca-camera.h" +#include "uca-plugin-manager.h" #include "cameras/uca-mock-camera.h" typedef struct { @@ -160,6 +161,14 @@ static void test_signal(Fixture *fixture, gconstpointer data) int main(int argc, char *argv[]) { g_type_init(); + + UcaPluginManager *manager = uca_plugin_manager_new (); + GList *list = uca_plugin_manager_get_available_cameras (manager); + + g_list_free (list); + + g_object_unref (manager); + g_test_init(&argc, &argv, NULL); g_test_bug_base("http://ufo.kit.edu/ufo/ticket"); -- cgit v1.2.3 From ec0e31d89baf7cb6c2fb30ead081655886478609 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 21 Sep 2012 11:59:06 +0200 Subject: Port the unit tests to the plugin manager --- test/test-mock.c | 182 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 86 deletions(-) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index 625a3fe..ca16c59 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -2,184 +2,194 @@ #include #include "uca-camera.h" #include "uca-plugin-manager.h" -#include "cameras/uca-mock-camera.h" typedef struct { - UcaMockCamera *camera; + UcaPluginManager *manager; + UcaCamera *camera; } Fixture; -static void fixture_setup(Fixture *fixture, gconstpointer data) +static void +fixture_setup (Fixture *fixture, gconstpointer data) { GError *error = NULL; - fixture->camera = uca_mock_camera_new(&error); - g_assert(error == NULL); - g_assert(fixture->camera); + + fixture->manager = uca_plugin_manager_new (); + uca_plugin_manager_add_path (fixture->manager, "./src"); + + fixture->camera = uca_plugin_manager_new_camera (fixture->manager, "mock", &error); + g_assert (error == NULL); + g_assert (fixture->camera); } -static void fixture_teardown(Fixture *fixture, gconstpointer data) +static void +fixture_teardown (Fixture *fixture, gconstpointer data) { - g_object_unref(fixture->camera); + g_object_unref (fixture->camera); + g_object_unref (fixture->manager); } -static void on_property_change(gpointer instance, GParamSpec *pspec, gpointer user_data) +static void +on_property_change (gpointer instance, GParamSpec *pspec, gpointer user_data) { gboolean *success = (gboolean *) user_data; *success = TRUE; } -static void test_factory() +static void +test_factory (Fixture *fixture, gconstpointer data) { GError *error = NULL; - UcaCamera *camera = uca_camera_new("fox994m3a0yxmy", &error); - g_assert_error(error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_FOUND); - g_assert(camera == NULL); + UcaCamera *camera = uca_plugin_manager_new_camera (fixture->manager, "fox994m3a0yxmy", &error); + g_assert_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND); + g_assert (camera == NULL); } -static void test_recording(Fixture *fixture, gconstpointer data) +static void +test_recording (Fixture *fixture, gconstpointer data) { GError *error = NULL; - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); - uca_camera_stop_recording(camera, &error); - g_assert_error(error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING); - g_error_free(error); + uca_camera_stop_recording (camera, &error); + g_assert_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING); + g_error_free (error); error = NULL; - uca_camera_start_recording(camera, &error); - g_assert_no_error(error); - uca_camera_stop_recording(camera, &error); - g_assert_no_error(error); + uca_camera_start_recording (camera, &error); + g_assert_no_error (error); + uca_camera_stop_recording (camera, &error); + g_assert_no_error (error); } -static void test_recording_signal(Fixture *fixture, gconstpointer data) +static void +test_recording_signal (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); gboolean success = FALSE; - g_signal_connect(G_OBJECT(camera), "notify::is-recording", + g_signal_connect (G_OBJECT (camera), "notify::is-recording", (GCallback) on_property_change, &success); - uca_camera_start_recording(camera, NULL); - g_assert(success == TRUE); + uca_camera_start_recording (camera, NULL); + g_assert (success == TRUE); success = FALSE; - uca_camera_stop_recording(camera, NULL); - g_assert(success == TRUE); + uca_camera_stop_recording (camera, NULL); + g_assert (success == TRUE); } -static void grab_func(gpointer data, gpointer user_data) +static void +grab_func (gpointer data, gpointer user_data) { guint *count = (guint *) user_data; *count += 1; } -static void test_recording_async(Fixture *fixture, gconstpointer data) +static void +test_recording_async (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); guint count = 0; - uca_camera_set_grab_func(camera, grab_func, &count); + uca_camera_set_grab_func (camera, grab_func, &count); - g_object_set(G_OBJECT(camera), + g_object_set (G_OBJECT (camera), "frame-rate", 10.0, "transfer-asynchronously", TRUE, NULL); GError *error = NULL; - uca_camera_start_recording(camera, &error); - g_assert_no_error(error); + uca_camera_start_recording (camera, &error); + g_assert_no_error (error); /* * We sleep for an 1/8 of a second at 10 frames per second, thus we should * record 2 frames. */ - g_usleep(G_USEC_PER_SEC / 8); + g_usleep (G_USEC_PER_SEC / 8); - uca_camera_stop_recording(camera, &error); - g_assert_no_error(error); - g_assert_cmpint(count, ==, 2); + uca_camera_stop_recording (camera, &error); + g_assert_no_error (error); + g_assert_cmpint (count, ==, 2); } -static void test_recording_property(Fixture *fixture, gconstpointer data) +static void +test_recording_property (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); gboolean is_recording = FALSE; - uca_camera_start_recording(camera, NULL); - g_object_get(G_OBJECT(camera), + uca_camera_start_recording (camera, NULL); + g_object_get (G_OBJECT (camera), "is-recording", &is_recording, NULL); - g_assert(is_recording == TRUE); + g_assert (is_recording == TRUE); - uca_camera_stop_recording(camera, NULL); - g_object_get(G_OBJECT(camera), + uca_camera_stop_recording (camera, NULL); + g_object_get (G_OBJECT (camera), "is-recording", &is_recording, NULL); - g_assert(is_recording == FALSE); + g_assert (is_recording == FALSE); } -static void test_base_properties(Fixture *fixture, gconstpointer data) +static void +test_base_properties (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); guint n_properties = 0; - GParamSpec **properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(camera), &n_properties); + GParamSpec **properties = g_object_class_list_properties (G_OBJECT_GET_CLASS (camera), &n_properties); GValue val = {0}; for (guint i = 0; i < n_properties; i++) { - g_value_init(&val, properties[i]->value_type); - g_object_get_property(G_OBJECT(camera), properties[i]->name, &val); - g_value_unset(&val); + g_value_init (&val, properties[i]->value_type); + g_object_get_property (G_OBJECT (camera), properties[i]->name, &val); + g_value_unset (&val); } - g_free(properties); + g_free (properties); } -static void test_binnings_properties(Fixture *fixture, gconstpointer data) +static void +test_binnings_properties (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); GValueArray *array = NULL; - g_object_get(G_OBJECT(camera), + g_object_get (G_OBJECT (camera), "sensor-horizontal-binnings", &array, NULL); - GValue *value = g_value_array_get_nth(array, 0); - g_assert(value != NULL); - g_assert(g_value_get_uint(value) == 1); + GValue *value = g_value_array_get_nth (array, 0); + g_assert (value != NULL); + g_assert (g_value_get_uint (value) == 1); } -static void test_signal(Fixture *fixture, gconstpointer data) +static void +test_signal (Fixture *fixture, gconstpointer data) { - UcaCamera *camera = UCA_CAMERA(fixture->camera); + UcaCamera *camera = UCA_CAMERA (fixture->camera); gboolean success = FALSE; - g_signal_connect(camera, "notify::frame-rate", (GCallback) on_property_change, &success); - g_object_set(G_OBJECT(camera), + g_signal_connect (camera, "notify::frame-rate", (GCallback) on_property_change, &success); + g_object_set (G_OBJECT (camera), "frame-rate", 30.0, NULL); - g_assert(success == TRUE); + g_assert (success == TRUE); } -int main(int argc, char *argv[]) +int main (int argc, char *argv[]) { - g_type_init(); - - UcaPluginManager *manager = uca_plugin_manager_new (); - GList *list = uca_plugin_manager_get_available_cameras (manager); - - g_list_free (list); - - g_object_unref (manager); + g_type_init (); - g_test_init(&argc, &argv, NULL); - g_test_bug_base("http://ufo.kit.edu/ufo/ticket"); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://ufo.kit.edu/ufo/ticket"); - g_test_add_func("/factory", test_factory); - g_test_add("/recording", Fixture, NULL, fixture_setup, test_recording, fixture_teardown); - g_test_add("/recording/signal", Fixture, NULL, fixture_setup, test_recording_signal, fixture_teardown); - g_test_add("/recording/asynchronous", Fixture, NULL, fixture_setup, test_recording_async, fixture_teardown); - g_test_add("/properties/base", Fixture, NULL, fixture_setup, test_base_properties, fixture_teardown); - g_test_add("/properties/recording", Fixture, NULL, fixture_setup, test_recording_property, fixture_teardown); - g_test_add("/properties/binnings", Fixture, NULL, fixture_setup, test_binnings_properties, fixture_teardown); - g_test_add("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown); + g_test_add ("/factory", Fixture, NULL, fixture_setup, test_factory, fixture_teardown); + g_test_add ("/recording", Fixture, NULL, fixture_setup, test_recording, fixture_teardown); + g_test_add ("/recording/signal", Fixture, NULL, fixture_setup, test_recording_signal, fixture_teardown); + g_test_add ("/recording/asynchronous", Fixture, NULL, fixture_setup, test_recording_async, fixture_teardown); + g_test_add ("/properties/base", Fixture, NULL, fixture_setup, test_base_properties, fixture_teardown); + g_test_add ("/properties/recording", Fixture, NULL, fixture_setup, test_recording_property, fixture_teardown); + g_test_add ("/properties/binnings", Fixture, NULL, fixture_setup, test_binnings_properties, fixture_teardown); + g_test_add ("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown); - return g_test_run(); + return g_test_run (); } -- cgit v1.2.3 From b3dbedeec78a55802565a3824ab52188e8b9bd4d Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 8 Oct 2012 14:38:16 +0200 Subject: Generate introspection files Unfortunately, the gir tools recognize anything with $PREFIX_new_$SUFFIX as some kind of constructor. This means that we have to rename uca_plugin_manager_new_camera() to uca_plugin_manager_get_camera(). --- test/test-mock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index ca16c59..711364d 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -16,7 +16,7 @@ fixture_setup (Fixture *fixture, gconstpointer data) fixture->manager = uca_plugin_manager_new (); uca_plugin_manager_add_path (fixture->manager, "./src"); - fixture->camera = uca_plugin_manager_new_camera (fixture->manager, "mock", &error); + fixture->camera = uca_plugin_manager_get_camera (fixture->manager, "mock", &error); g_assert (error == NULL); g_assert (fixture->camera); } @@ -39,7 +39,7 @@ static void test_factory (Fixture *fixture, gconstpointer data) { GError *error = NULL; - UcaCamera *camera = uca_plugin_manager_new_camera (fixture->manager, "fox994m3a0yxmy", &error); + UcaCamera *camera = uca_plugin_manager_get_camera (fixture->manager, "fox994m3a0yxmy", &error); g_assert_error (error, UCA_PLUGIN_MANAGER_ERROR, UCA_PLUGIN_MANAGER_ERROR_MODULE_NOT_FOUND); g_assert (camera == NULL); } -- cgit v1.2.3 From 4a27a2e95aa1a2312ad17404d7ab236b2fa6f1b7 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 9 Oct 2012 15:43:10 +0200 Subject: Fix #150: Add "frames-per-second" property Right now, there is only information for the DIMAX camera about the actual inherent system delay. For all other cameras fps = 1. / t_exp. --- test/test-mock.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index 711364d..17af329 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -148,6 +148,26 @@ test_base_properties (Fixture *fixture, gconstpointer data) g_free (properties); } +static void +test_fps_property (Fixture *fixture, gconstpointer data) +{ + gdouble frames_per_second; + gdouble exposure_time = 0.5; + + g_object_set (G_OBJECT (fixture->camera), + "exposure-time", exposure_time, + NULL); + g_object_get (G_OBJECT (fixture->camera), + "frames-per-second", &frames_per_second, + NULL); + + /* + * The mock camera does not override the "frames-per-second" property, so we + * check the implementation from the base camera. + */ + g_assert_cmpfloat (frames_per_second, ==, 1.0 / exposure_time); +} + static void test_binnings_properties (Fixture *fixture, gconstpointer data) { @@ -189,6 +209,7 @@ int main (int argc, char *argv[]) g_test_add ("/properties/base", Fixture, NULL, fixture_setup, test_base_properties, fixture_teardown); g_test_add ("/properties/recording", Fixture, NULL, fixture_setup, test_recording_property, fixture_teardown); g_test_add ("/properties/binnings", Fixture, NULL, fixture_setup, test_binnings_properties, fixture_teardown); + g_test_add ("/properties/frames-per-second", Fixture, NULL, fixture_setup, test_fps_property, fixture_teardown); g_test_add ("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown); return g_test_run (); -- cgit v1.2.3 From d8743d20b93d34497183d05ccb17519194ec5abb Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 16 Oct 2012 12:27:47 +0200 Subject: Integrate initial unit facility --- test/test-mock.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index 17af329..08f24b8 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -168,6 +168,13 @@ test_fps_property (Fixture *fixture, gconstpointer data) g_assert_cmpfloat (frames_per_second, ==, 1.0 / exposure_time); } +static void +test_property_units (Fixture *fixture, gconstpointer data) +{ + g_assert (uca_camera_get_unit (fixture->camera, "sensor-width") == UCA_UNIT_PIXEL); + g_assert (uca_camera_get_unit (fixture->camera, "name") == UCA_UNIT_NA); +} + static void test_binnings_properties (Fixture *fixture, gconstpointer data) { @@ -210,6 +217,7 @@ int main (int argc, char *argv[]) g_test_add ("/properties/recording", Fixture, NULL, fixture_setup, test_recording_property, fixture_teardown); g_test_add ("/properties/binnings", Fixture, NULL, fixture_setup, test_binnings_properties, fixture_teardown); g_test_add ("/properties/frames-per-second", Fixture, NULL, fixture_setup, test_fps_property, fixture_teardown); + g_test_add ("/properties/units", Fixture, NULL, fixture_setup, test_property_units, fixture_teardown); g_test_add ("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown); return g_test_run (); -- cgit v1.2.3 From de2e8e3191eae37b91f672a03e028a35c8863c9d Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 16 Oct 2012 12:40:18 +0200 Subject: Add temperature unit and descriptions for pco --- test/test-mock.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/test-mock.c') diff --git a/test/test-mock.c b/test/test-mock.c index 08f24b8..85c1ba4 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -171,8 +171,12 @@ test_fps_property (Fixture *fixture, gconstpointer data) static void test_property_units (Fixture *fixture, gconstpointer data) { + /* Default camera properties */ g_assert (uca_camera_get_unit (fixture->camera, "sensor-width") == UCA_UNIT_PIXEL); g_assert (uca_camera_get_unit (fixture->camera, "name") == UCA_UNIT_NA); + + /* Mock-specific properties */ + g_assert (uca_camera_get_unit (fixture->camera, "frame-rate") == UCA_UNIT_COUNT); } static void -- cgit v1.2.3