From bc5b68845666e8373527825d813cd79d4c603139 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Wed, 24 Jan 2018 10:21:00 +0100 Subject: mock: add a custom enum type for test purposes --- plugins/mock/uca-mock-camera.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/mock/uca-mock-camera.c b/plugins/mock/uca-mock-camera.c index 49e1dcd..b829e37 100644 --- a/plugins/mock/uca-mock-camera.c +++ b/plugins/mock/uca-mock-camera.c @@ -33,6 +33,7 @@ G_DEFINE_TYPE_WITH_CODE (UcaMockCamera, uca_mock_camera, UCA_TYPE_CAMERA, enum { PROP_FILL_DATA = N_BASE_PROPERTIES, PROP_DEGREE_VALUE, + PROP_TEST_ENUM, N_PROPERTIES }; @@ -528,12 +529,21 @@ uca_mock_initable_iface_init (GInitableIface *iface) static void uca_mock_camera_class_init(UcaMockCameraClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS(klass); + GObjectClass *gobject_class; + UcaCameraClass *camera_class; + + static GEnumValue enum_values[] = { + { 0, "UCA_MOCK_CAMERA_TEST_ENUM_FOO", "foo" }, + { 1, "UCA_MOCK_CAMERA_TEST_ENUM_BAR", "bar" }, + { 0, } + }; + + gobject_class = G_OBJECT_CLASS(klass); gobject_class->set_property = uca_mock_camera_set_property; gobject_class->get_property = uca_mock_camera_get_property; gobject_class->finalize = uca_mock_camera_finalize; - UcaCameraClass *camera_class = UCA_CAMERA_CLASS(klass); + camera_class = UCA_CAMERA_CLASS(klass); camera_class->start_recording = uca_mock_camera_start_recording; camera_class->stop_recording = uca_mock_camera_stop_recording; camera_class->grab = uca_mock_camera_grab; @@ -557,6 +567,14 @@ uca_mock_camera_class_init(UcaMockCameraClass *klass) -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE); + mock_properties[PROP_TEST_ENUM] = + g_param_spec_enum ("test-enum", + "Test enum", + "Test enum", + g_enum_register_static ("UcaMockCameraTestEnum", enum_values), + 0, + G_PARAM_READWRITE); + for (guint id = N_BASE_PROPERTIES; id < N_PROPERTIES; id++) g_object_class_install_property(gobject_class, id, mock_properties[id]); -- cgit v1.2.3