diff options
Diffstat (limited to 'test/test-mock.c')
-rw-r--r-- | test/test-mock.c | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/test/test-mock.c b/test/test-mock.c index d1dcf3a..c0acc9c 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -215,9 +215,7 @@ test_signal (Fixture *fixture, gconstpointer data) UcaCamera *camera = UCA_CAMERA (fixture->camera); gboolean success = FALSE; g_signal_connect (camera, "notify::frames-per-second", (GCallback) on_property_change, &success); - g_object_set (G_OBJECT (camera), - "frames-per-second", 30.0, - NULL); + g_object_set (G_OBJECT (camera), "frames-per-second", 30.0, NULL); g_assert (success == TRUE); } @@ -227,8 +225,38 @@ test_overwriting_units (Fixture *fixture, gconstpointer data) uca_camera_register_unit (fixture->camera, "sensor-width", UCA_UNIT_PIXEL); } +static void +test_can_be_written (Fixture *fixture, gconstpointer data) +{ + GError *error = NULL; + + /* read-only cannot ever be written */ + g_assert (!uca_camera_is_writable_during_acquisition (fixture->camera, "name")); + + /* unset properties cannot be written */ + g_assert (!uca_camera_is_writable_during_acquisition (fixture->camera, "roi-width")); + + /* check trivial cases */ + uca_camera_set_writable (fixture->camera, "roi-width", TRUE); + g_assert (uca_camera_is_writable_during_acquisition (fixture->camera, "roi-width")); + + uca_camera_set_writable (fixture->camera, "roi-height", FALSE); + g_assert (!uca_camera_is_writable_during_acquisition (fixture->camera, "roi-height")); + + /* Now, do a real test */ + uca_camera_set_writable (fixture->camera, "roi-height", TRUE); + uca_camera_start_recording (fixture->camera, &error); + g_assert_no_error (error); + + g_object_set (fixture->camera, "roi-height", 128, NULL); + uca_camera_stop_recording (fixture->camera, &error); + g_assert_no_error (error); +} + int main (int argc, char *argv[]) { + gsize n_tests; + #if !(GLIB_CHECK_VERSION (2, 36, 0)) g_type_init (); #endif @@ -236,17 +264,29 @@ int main (int argc, char *argv[]) g_test_init (&argc, &argv, NULL); g_test_bug_base ("http://ufo.kit.edu/ufo/ticket"); - 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 ("/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 ("/properties/units/overwrite", Fixture, NULL, fixture_setup, test_overwriting_units, fixture_teardown); - g_test_add ("/signal", Fixture, NULL, fixture_setup, test_signal, fixture_teardown); + struct { + const gchar *name; + void (*test_func) (Fixture *fixture, gconstpointer data); + } + tests[] = { + {"/factory", test_factory}, + {"/signal", test_signal}, + {"/recording", test_recording}, + {"/recording/signal", test_recording_signal}, + {"/recording/asynchronous", test_recording_async}, + {"/properties/base", test_base_properties}, + {"/properties/recording", test_recording_property}, + {"/properties/binnings", test_binnings_properties}, + {"/properties/frames-per-second", test_fps_property}, + {"/properties/units", test_property_units}, + {"/properties/units/overwrite", test_overwriting_units}, + {"/properties/can-be-written", test_can_be_written}, + }; + + n_tests = sizeof(tests) / sizeof(tests[0]); + + for (gsize i = 0; i < n_tests; i++) + g_test_add (tests[i].name, Fixture, NULL, fixture_setup, tests[i].test_func, fixture_teardown); return g_test_run (); } |