tests: camerabin: fix image location switching test
authorThiago Santos <thiago.sousa.santos@collabora.com>
Sun, 26 Aug 2012 19:43:37 +0000 (16:43 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.com>
Wed, 29 Aug 2012 18:45:05 +0000 (15:45 -0300)
The test should wait until the last image-done is posted so it
can correctly check that all images have been saved.

tests/check/elements/camerabin.c

index da7270981eaaef1c51a5fe43856f9588b693d8a9..ac55a8daea11becf4facb580d02c900d02990144 100644 (file)
@@ -1519,9 +1519,21 @@ GST_START_TEST (test_image_location_switching)
   g_idle_add (image_location_switch_do_capture, filenames);
   g_main_loop_run (main_loop);
 
-  msg = wait_for_element_message (camera, "image-done", GST_CLOCK_TIME_NONE);
-  fail_unless (msg != NULL);
-  gst_message_unref (msg);
+  while (1) {
+    const gchar *filename;
+
+    msg = wait_for_element_message (camera, "image-done", GST_CLOCK_TIME_NONE);
+    fail_unless (msg != NULL);
+
+    filename =
+        gst_structure_get_string (gst_message_get_structure (msg), "filename");
+    if (strcmp (filename,
+            filenames[LOCATION_SWITCHING_FILENAMES_COUNT - 1]) == 0) {
+      gst_message_unref (msg);
+      break;
+    }
+    gst_message_unref (msg);
+  }
 
   gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL);