diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 11:47:40 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 11:47:40 +0200 |
commit | 762f09301dbe4aa425efde86989a81d99e28dedd (patch) | |
tree | 4454d5ef8146a153c201665dbdaa619d3c9c3240 /test | |
parent | 0a9c6f047db1f5244f1569d7bb9a0a6097f5620f (diff) | |
download | libuca-762f09301dbe4aa425efde86989a81d99e28dedd.tar.gz libuca-762f09301dbe4aa425efde86989a81d99e28dedd.tar.bz2 libuca-762f09301dbe4aa425efde86989a81d99e28dedd.tar.xz libuca-762f09301dbe4aa425efde86989a81d99e28dedd.zip |
More meaningful async test
Before we just checked that the callback was called. Now we check that it is
called as often as expected.
Diffstat (limited to 'test')
-rw-r--r-- | test/test-mock.c | 13 |
1 files changed, 9 insertions, 4 deletions
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) |