summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-12-21 11:04:00 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-12-23 14:13:53 -0300
commit6e4efe5ad45115aa7785ea47a022f936b6b74038 (patch)
tree5ee5a2e82bf24e4bd149cd66391319cf2f583fdf
parent65c5b65d6d55b6c5fdffe66c44e572400688c456 (diff)
downloadgstreamer-plugins-bad-6e4efe5ad45115aa7785ea47a022f936b6b74038.tar.gz
camerabin2: Refactor tests
Refactor tests case so that the same tests can be run for different camera sources.
-rw-r--r--tests/check/elements/camerabin2.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/tests/check/elements/camerabin2.c b/tests/check/elements/camerabin2.c
index fe36d098e..a09bdd844 100644
--- a/tests/check/elements/camerabin2.c
+++ b/tests/check/elements/camerabin2.c
@@ -167,6 +167,7 @@ gst_test_camera_src_init (GstTestCameraSrc * self,
static GstElement *camera;
static GMainLoop *main_loop;
+guint32 test_id = 0;
/* helper function for filenames */
static const gchar *
@@ -178,10 +179,12 @@ make_test_file_name (const gchar * base_name, gint num)
* multifilesink like location */
if (num == -1) {
g_snprintf (file_name, 999, "%s" G_DIR_SEPARATOR_S
- "gstcamerabin2test_%s_%%03d.cap", g_get_tmp_dir (), base_name);
+ "gstcamerabin2test_%s_%u_%%03d.cap", g_get_tmp_dir (), base_name,
+ test_id);
} else {
g_snprintf (file_name, 999, "%s" G_DIR_SEPARATOR_S
- "gstcamerabin2test_%s_%03d.cap", g_get_tmp_dir (), base_name, num);
+ "gstcamerabin2test_%s_%u_%03d.cap", g_get_tmp_dir (), base_name,
+ test_id, num);
}
GST_INFO ("capturing to: %s", file_name);
@@ -244,7 +247,7 @@ capture_bus_cb (GstBus * bus, GstMessage * message, gpointer data)
}
static void
-setup (void)
+setup_wrappercamerabinsrc_videotestsrc (void)
{
GstBus *bus;
GstElement *vfbin;
@@ -254,6 +257,8 @@ setup (void)
GST_INFO ("init");
+ test_id = g_random_int ();
+
main_loop = g_main_loop_new (NULL, TRUE);
camera = gst_check_setup_element ("camerabin2");
@@ -579,22 +584,42 @@ GST_START_TEST (test_supported_caps)
GST_END_TEST;
+
+typedef struct _TestCaseDef
+{
+ const gchar *name;
+ gpointer setup_func;
+} TestCaseDef;
+
+TestCaseDef tests[] = {
+ {"wrappercamerabinsrc", setup_wrappercamerabinsrc_videotestsrc}
+};
+
static Suite *
camerabin_suite (void)
{
Suite *s = suite_create ("camerabin2");
- TCase *tc_basic = tcase_create ("general");
-
- /* Test that basic operations run without errors */
- suite_add_tcase (s, tc_basic);
- /* Increase timeout due to video recording */
- tcase_set_timeout (tc_basic, 60);
- tcase_add_checked_fixture (tc_basic, setup, teardown);
- tcase_add_test (tc_basic, test_single_image_capture);
- tcase_add_test (tc_basic, test_single_video_recording);
- tcase_add_test (tc_basic, test_image_video_cycle);
- tcase_add_test (tc_basic, test_multiple_image_captures);
- tcase_add_test (tc_basic, test_supported_caps);
+ gint i;
+ TCase *tc_generic = tcase_create ("generic");
+
+ suite_add_tcase (s, tc_generic);
+ tcase_add_checked_fixture (tc_generic, setup_wrappercamerabinsrc_videotestsrc,
+ teardown);
+ tcase_add_test (tc_generic, test_supported_caps);
+
+ for (i = 0; i < G_N_ELEMENTS (tests); i++) {
+ TCase *tc_basic = tcase_create (tests[i].name);
+ suite_add_tcase (s, tc_basic);
+
+ /* Increase timeout due to video recording */
+ tcase_set_timeout (tc_basic, 60);
+ tcase_add_checked_fixture (tc_basic, tests[i].setup_func, teardown);
+
+ tcase_add_test (tc_basic, test_single_image_capture);
+ tcase_add_test (tc_basic, test_single_video_recording);
+ tcase_add_test (tc_basic, test_image_video_cycle);
+ tcase_add_test (tc_basic, test_multiple_image_captures);
+ }
return s;
}