From 94dbf20400f7aeff6e43c947cf413abf0a8ce61f Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 27 Jan 2014 15:30:40 +0100 Subject: [PATCH] ges-asset: Do not forget to give a ref to the registry + Add test in the testsuite + Fix broken tests https://bugzilla.gnome.org/show_bug.cgi?id=721111 --- ges/ges-asset.c | 2 +- tests/check/ges/project.c | 31 ++++++++++++++++++++----------- tests/check/ges/uriclip.c | 3 ++- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ges/ges-asset.c b/ges/ges-asset.c index afd6bbafac..8c584b2a62 100644 --- a/ges/ges-asset.c +++ b/ges/ges-asset.c @@ -219,7 +219,7 @@ async_initable_init_async (GAsyncInitable * initable, gint io_priority, simple = g_simple_async_result_new (G_OBJECT (asset), callback, user_data, ges_asset_request_async); - ges_asset_cache_put (asset, simple); + ges_asset_cache_put (g_object_ref (asset), simple); switch (GES_ASSET_GET_CLASS (asset)->start_loading (asset, &error)) { case GES_ASSET_LOADING_ERROR: { diff --git a/tests/check/ges/project.c b/tests/check/ges/project.c index 0fb1f8e7c6..ea496fd3f1 100644 --- a/tests/check/ges/project.c +++ b/tests/check/ges/project.c @@ -24,6 +24,8 @@ #include #include +GMainLoop *mainloop; + static void project_loaded_cb (GESProject * project, GESTimeline * timeline, GMainLoop * mainloop) @@ -50,7 +52,6 @@ GST_START_TEST (test_project_simple) gchar *id; GESProject *project; GESTimeline *timeline; - GMainLoop *mainloop; ges_init (); @@ -84,6 +85,16 @@ asset_removed_add_cb (GESProject * project, GESAsset * asset, gboolean * called) *called = TRUE; } +static void +asset_created_cb (GObject * source, GAsyncResult * res, GESAsset ** asset) +{ + GError *error = NULL; + *asset = ges_asset_request_finish (res, &error); + + fail_unless (error == NULL); + g_main_loop_quit (mainloop); +} + GST_START_TEST (test_project_add_assets) { GESProject *project; @@ -93,16 +104,20 @@ GST_START_TEST (test_project_add_assets) ges_init (); + mainloop = g_main_loop_new (NULL, FALSE); project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, NULL, NULL)); fail_unless (GES_IS_PROJECT (project)); - fail_unless (GES_IS_PROJECT (project)); g_signal_connect (project, "asset-added", (GCallback) asset_removed_add_cb, &added_cb_called); g_signal_connect (project, "asset-removed", (GCallback) asset_removed_add_cb, &removed_cb_called); - asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); + ges_asset_request_async (GES_TYPE_TEST_CLIP, NULL, NULL, + (GAsyncReadyCallback) asset_created_cb, &asset); + g_main_loop_run (mainloop); + g_main_loop_unref (mainloop); + fail_unless (GES_IS_ASSET (asset)); fail_unless (ges_project_add_asset (project, asset)); @@ -113,17 +128,16 @@ GST_START_TEST (test_project_add_assets) fail_unless (ges_project_remove_asset (project, asset)); fail_unless (removed_cb_called); - gst_object_unref (asset); - gst_object_unref (project); g_signal_handlers_disconnect_by_func (project, (GCallback) asset_removed_add_cb, &added_cb_called); g_signal_handlers_disconnect_by_func (project, (GCallback) asset_removed_add_cb, &removed_cb_called); + gst_object_unref (asset); + gst_object_unref (project); ASSERT_OBJECT_REFCOUNT (asset, "The asset (1 ref in cache)", 1); ASSERT_OBJECT_REFCOUNT (project, "The project (1 ref in cache)", 1); - } GST_END_TEST; @@ -140,7 +154,6 @@ error_loading_asset_cb (GESProject * project, GError * error, gchar * id, GST_START_TEST (test_project_unexistant_effect) { GESProject *project; - GMainLoop *mainloop; gboolean added_cb_called = FALSE; gboolean removed_cb_called = FALSE; @@ -148,7 +161,6 @@ GST_START_TEST (test_project_unexistant_effect) project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, NULL, NULL)); fail_unless (GES_IS_PROJECT (project)); - fail_unless (GES_IS_PROJECT (project)); mainloop = g_main_loop_new (NULL, FALSE); g_signal_connect (project, "asset-added", @@ -404,7 +416,6 @@ _check_keyframes (GESTimeline * timeline) GST_START_TEST (test_project_add_keyframes) { - GMainLoop *mainloop; GESProject *project; GESTimeline *timeline; GESAsset *formatter_asset; @@ -469,7 +480,6 @@ GST_END_TEST; GST_START_TEST (test_project_load_xges) { gboolean saved; - GMainLoop *mainloop; GESProject *project; GESTimeline *timeline; GESAsset *formatter_asset; @@ -534,7 +544,6 @@ GST_END_TEST; GST_START_TEST (test_project_auto_transition) { GList *layers; - GMainLoop *mainloop; GESProject *project; GESTimeline *timeline; GESLayer *layer = NULL; diff --git a/tests/check/ges/uriclip.c b/tests/check/ges/uriclip.c index 09dfb4ed80..81a7016ee4 100644 --- a/tests/check/ges/uriclip.c +++ b/tests/check/ges/uriclip.c @@ -46,7 +46,8 @@ asset_created_cb (GObject * source, GAsyncResult * res, gpointer udata) GError *error = NULL; asset = ges_asset_request_finish (res, &error); - ASSERT_OBJECT_REFCOUNT (asset, "1 for us one for the cache", 2); + ASSERT_OBJECT_REFCOUNT (asset, "1 for us + for the cache + 1 taken " + "by g_simple_async_result_complete_in_idle", 3); fail_unless (error == NULL); fail_if (asset == NULL); fail_if (g_strcmp0 (ges_asset_get_id (asset), av_uri)); -- 2.34.1