mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 12:10:37 +00:00
test: project: Fix various leaks
This commit is contained in:
parent
0ec78ea70b
commit
b8400f7900
1 changed files with 37 additions and 16 deletions
|
@ -22,24 +22,42 @@
|
||||||
#include <ges/ges.h>
|
#include <ges/ges.h>
|
||||||
#include <gst/check/gstcheck.h>
|
#include <gst/check/gstcheck.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
project_loaded_cb (GESProject * project, GESTimeline * timeline,
|
||||||
|
GMainLoop * mainloop)
|
||||||
|
{
|
||||||
|
g_main_loop_quit (mainloop);
|
||||||
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_project_simple)
|
GST_START_TEST (test_project_simple)
|
||||||
{
|
{
|
||||||
gchar *id;
|
gchar *id;
|
||||||
GESProject *project;
|
GESProject *project;
|
||||||
GESTimeline *timeline;
|
GESTimeline *timeline;
|
||||||
|
GMainLoop *mainloop;
|
||||||
|
|
||||||
ges_init ();
|
ges_init ();
|
||||||
|
|
||||||
|
mainloop = g_main_loop_new (NULL, FALSE);
|
||||||
project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, NULL, NULL));
|
project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, NULL, NULL));
|
||||||
fail_unless (GES_IS_PROJECT (project));
|
fail_unless (GES_IS_PROJECT (project));
|
||||||
assert_equals_string (ges_asset_get_id (GES_ASSET (project)), "project-0");
|
assert_equals_string (ges_asset_get_id (GES_ASSET (project)), "project-0");
|
||||||
|
g_signal_connect (project, "loaded", (GCallback) project_loaded_cb, mainloop);
|
||||||
|
|
||||||
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
||||||
|
g_main_loop_run (mainloop);
|
||||||
|
|
||||||
fail_unless (GES_IS_TIMELINE (timeline));
|
fail_unless (GES_IS_TIMELINE (timeline));
|
||||||
id = ges_extractable_get_id (GES_EXTRACTABLE (timeline));
|
id = ges_extractable_get_id (GES_EXTRACTABLE (timeline));
|
||||||
assert_equals_string (id, "project-0");
|
assert_equals_string (id, "project-0");
|
||||||
|
ASSERT_OBJECT_REFCOUNT (timeline, "We own the only ref", 1);
|
||||||
|
|
||||||
g_free (id);
|
g_free (id);
|
||||||
|
gst_object_unref (project);
|
||||||
|
gst_object_unref (timeline);
|
||||||
|
g_main_loop_unref (mainloop);
|
||||||
|
g_signal_handlers_disconnect_by_func (project, (GCallback) project_loaded_cb,
|
||||||
|
mainloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
@ -82,6 +100,11 @@ GST_START_TEST (test_project_add_assets)
|
||||||
gst_object_unref (asset);
|
gst_object_unref (asset);
|
||||||
gst_object_unref (project);
|
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);
|
||||||
|
|
||||||
ASSERT_OBJECT_REFCOUNT (asset, "The asset (1 ref in cache)", 1);
|
ASSERT_OBJECT_REFCOUNT (asset, "The asset (1 ref in cache)", 1);
|
||||||
ASSERT_OBJECT_REFCOUNT (project, "The project (1 ref in cache)", 1);
|
ASSERT_OBJECT_REFCOUNT (project, "The project (1 ref in cache)", 1);
|
||||||
|
|
||||||
|
@ -141,8 +164,6 @@ GST_START_TEST (test_project_unexistant_effect)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
static GMainLoop *mainloop;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
asset_added_cb (GESProject * project, GESAsset * asset)
|
asset_added_cb (GESProject * project, GESAsset * asset)
|
||||||
{
|
{
|
||||||
|
@ -161,12 +182,6 @@ asset_added_cb (GESProject * project, GESAsset * asset)
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
project_loaded_cb (GESProject * project, GESTimeline * timeline)
|
|
||||||
{
|
|
||||||
g_main_loop_quit (mainloop);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
_set_new_uri (GESProject * project, GError * error, GESAsset * wrong_asset)
|
_set_new_uri (GESProject * project, GError * error, GESAsset * wrong_asset)
|
||||||
{
|
{
|
||||||
|
@ -192,16 +207,17 @@ _test_project (GESProject * project, GESTimeline * timeline)
|
||||||
assert_equals_string (ges_meta_container_get_string (GES_META_CONTAINER
|
assert_equals_string (ges_meta_container_get_string (GES_META_CONTAINER
|
||||||
(project), "name"), "Example project");
|
(project), "name"), "Example project");
|
||||||
tlobjs =
|
tlobjs =
|
||||||
ges_timeline_layer_get_objects (GES_TIMELINE_LAYER (timeline->layers->
|
ges_timeline_layer_get_objects (GES_TIMELINE_LAYER (timeline->
|
||||||
data));
|
layers->data));
|
||||||
fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER (timeline->
|
fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER
|
||||||
layers->data), "a", &a_meta));
|
(timeline->layers->data), "a", &a_meta));
|
||||||
assert_equals_int (a_meta, 3);
|
assert_equals_int (a_meta, 3);
|
||||||
assert_equals_int (g_list_length (tlobjs), 1);
|
assert_equals_int (g_list_length (tlobjs), 1);
|
||||||
media_uri = ges_test_file_uri ("audio_video.ogg");
|
media_uri = ges_test_file_uri ("audio_video.ogg");
|
||||||
assert_equals_string (ges_asset_get_id (ges_extractable_get_asset
|
assert_equals_string (ges_asset_get_id (ges_extractable_get_asset
|
||||||
(GES_EXTRACTABLE (tlobjs->data))), media_uri);
|
(GES_EXTRACTABLE (tlobjs->data))), media_uri);
|
||||||
g_free (media_uri);
|
g_free (media_uri);
|
||||||
|
g_list_free_full (tlobjs, gst_object_unref);
|
||||||
|
|
||||||
/* Check tracks and the objects they contain */
|
/* Check tracks and the objects they contain */
|
||||||
tracks = ges_timeline_get_tracks (timeline);
|
tracks = ges_timeline_get_tracks (timeline);
|
||||||
|
@ -211,9 +227,9 @@ _test_project (GESProject * project, GESTimeline * timeline)
|
||||||
track = GES_TRACK (tmp->data);
|
track = GES_TRACK (tmp->data);
|
||||||
|
|
||||||
trackobjs = ges_track_get_objects (track);
|
trackobjs = ges_track_get_objects (track);
|
||||||
|
GST_DEBUG_OBJECT (track, "Testing track");
|
||||||
switch (track->type) {
|
switch (track->type) {
|
||||||
case GES_TRACK_TYPE_VIDEO:
|
case GES_TRACK_TYPE_VIDEO:
|
||||||
GST_DEBUG_OBJECT (track, "Testing track");
|
|
||||||
assert_equals_int (g_list_length (trackobjs), 2);
|
assert_equals_int (g_list_length (trackobjs), 2);
|
||||||
for (tmptckobj = trackobjs; tmptckobj; tmptckobj = tmptckobj->next) {
|
for (tmptckobj = trackobjs; tmptckobj; tmptckobj = tmptckobj->next) {
|
||||||
GESTrackObject *tckobj = GES_TRACK_OBJECT (tmptckobj->data);
|
GESTrackObject *tckobj = GES_TRACK_OBJECT (tmptckobj->data);
|
||||||
|
@ -257,17 +273,19 @@ _test_project (GESProject * project, GESTimeline * timeline)
|
||||||
GST_START_TEST (test_project_load_xges)
|
GST_START_TEST (test_project_load_xges)
|
||||||
{
|
{
|
||||||
gboolean saved;
|
gboolean saved;
|
||||||
|
GMainLoop *mainloop;
|
||||||
GESProject *project;
|
GESProject *project;
|
||||||
GESTimeline *timeline;
|
GESTimeline *timeline;
|
||||||
GESAsset *formatter_asset;
|
GESAsset *formatter_asset;
|
||||||
gchar *tmpuri, *uri = ges_test_file_uri ("test-project.xges");
|
gchar *tmpuri, *uri = ges_test_file_uri ("test-project.xges");
|
||||||
|
|
||||||
project = ges_project_new (uri);
|
project = ges_project_new (uri);
|
||||||
|
mainloop = g_main_loop_new (NULL, FALSE);
|
||||||
fail_unless (GES_IS_PROJECT (project));
|
fail_unless (GES_IS_PROJECT (project));
|
||||||
|
|
||||||
/* Connect the signals */
|
/* Connect the signals */
|
||||||
g_signal_connect (project, "asset-added", (GCallback) asset_added_cb, NULL);
|
g_signal_connect (project, "asset-added", (GCallback) asset_added_cb, NULL);
|
||||||
g_signal_connect (project, "loaded", (GCallback) project_loaded_cb, NULL);
|
g_signal_connect (project, "loaded", (GCallback) project_loaded_cb, mainloop);
|
||||||
|
|
||||||
/* Make sure we update the project's dummy URL to some actual URL */
|
/* Make sure we update the project's dummy URL to some actual URL */
|
||||||
g_signal_connect (project, "missing-uri", (GCallback) _set_new_uri, NULL);
|
g_signal_connect (project, "missing-uri", (GCallback) _set_new_uri, NULL);
|
||||||
|
@ -277,7 +295,6 @@ GST_START_TEST (test_project_load_xges)
|
||||||
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
||||||
fail_unless (GES_IS_TIMELINE (timeline));
|
fail_unless (GES_IS_TIMELINE (timeline));
|
||||||
|
|
||||||
mainloop = g_main_loop_new (NULL, FALSE);
|
|
||||||
g_main_loop_run (mainloop);
|
g_main_loop_run (mainloop);
|
||||||
GST_LOG ("Test first loading");
|
GST_LOG ("Test first loading");
|
||||||
_test_project (project, timeline);
|
_test_project (project, timeline);
|
||||||
|
@ -297,7 +314,7 @@ GST_START_TEST (test_project_load_xges)
|
||||||
project = ges_project_new (uri);
|
project = ges_project_new (uri);
|
||||||
ASSERT_OBJECT_REFCOUNT (project, "Our + cache", 2);
|
ASSERT_OBJECT_REFCOUNT (project, "Our + cache", 2);
|
||||||
g_signal_connect (project, "asset-added", (GCallback) asset_added_cb, NULL);
|
g_signal_connect (project, "asset-added", (GCallback) asset_added_cb, NULL);
|
||||||
g_signal_connect (project, "loaded", (GCallback) project_loaded_cb, NULL);
|
g_signal_connect (project, "loaded", (GCallback) project_loaded_cb, mainloop);
|
||||||
|
|
||||||
GST_LOG ("Loading saved project");
|
GST_LOG ("Loading saved project");
|
||||||
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
timeline = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), NULL));
|
||||||
|
@ -311,6 +328,10 @@ GST_START_TEST (test_project_load_xges)
|
||||||
ASSERT_OBJECT_REFCOUNT (project, "Still 1 ref for asset cache", 1);
|
ASSERT_OBJECT_REFCOUNT (project, "Still 1 ref for asset cache", 1);
|
||||||
|
|
||||||
g_main_loop_unref (mainloop);
|
g_main_loop_unref (mainloop);
|
||||||
|
g_signal_handlers_disconnect_by_func (project, (GCallback) project_loaded_cb,
|
||||||
|
mainloop);
|
||||||
|
g_signal_handlers_disconnect_by_func (project, (GCallback) asset_added_cb,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue