From 762f09301dbe4aa425efde86989a81d99e28dedd Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 17 Apr 2012 11:47:40 +0200 Subject: More meaningful async test Before we just checked that the callback was called. Now we check that it is called as often as expected. --- test/test-mock.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test-mock.c b/test/test-mock.c index c128bbf..31517ed 100644 --- a/test/test-mock.c +++ b/test/test-mock.c @@ -67,16 +67,16 @@ static void test_recording_signal(Fixture *fixture, gconstpointer data) static void grab_func(gpointer data, gpointer user_data) { - gboolean *success = (gboolean *) user_data; - *success = TRUE; + guint *count = (guint *) user_data; + *count += 1; } static void test_recording_async(Fixture *fixture, gconstpointer data) { UcaCamera *camera = UCA_CAMERA(fixture->camera); - gboolean success = FALSE; - uca_camera_set_grab_func(camera, grab_func, &success); + guint count = 0; + uca_camera_set_grab_func(camera, grab_func, &count); g_object_set(G_OBJECT(camera), "frame-rate", 10.0, @@ -87,10 +87,15 @@ static void test_recording_async(Fixture *fixture, gconstpointer data) 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); 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) -- cgit v1.2.3