2009-08-06 17:51:29 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ges/ges.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_init)
|
|
|
|
{
|
|
|
|
/* Yes, I know.. minimalistic... */
|
|
|
|
ges_init ();
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-08-07 14:47:18 +00:00
|
|
|
static gboolean
|
|
|
|
my_fill_track_func (GESTimelineObject * object,
|
2009-08-07 18:31:11 +00:00
|
|
|
GESTrackObject * trobject, GstElement * gnlobj, gpointer user_data)
|
2009-08-07 14:47:18 +00:00
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
GST_DEBUG ("timelineobj:%p, trackobject:%p, gnlobj:%p",
|
2009-08-07 14:47:18 +00:00
|
|
|
object, trobject, gnlobj);
|
|
|
|
|
|
|
|
/* Let's just put a fakesource in for the time being */
|
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
2010-12-09 16:43:08 +00:00
|
|
|
|
|
|
|
/* If this fails... that means that there already was something
|
|
|
|
* in it */
|
|
|
|
fail_unless (gst_bin_add (GST_BIN (gnlobj), src));
|
|
|
|
|
|
|
|
return TRUE;
|
2009-08-07 14:47:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 18:04:59 +00:00
|
|
|
GST_START_TEST (test_ges_scenario)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2009-08-06 18:04:59 +00:00
|
|
|
GESTrack *track;
|
2009-08-07 14:47:18 +00:00
|
|
|
GESCustomTimelineSource *source;
|
2010-03-12 18:05:36 +00:00
|
|
|
GESTrackObject *trackobject;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers, *tracks;
|
2009-08-06 18:04:59 +00:00
|
|
|
|
2009-08-07 14:47:18 +00:00
|
|
|
ges_init ();
|
2009-08-06 18:04:59 +00:00
|
|
|
/* This is the simplest scenario ever */
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Create a layer");
|
2009-08-06 18:04:59 +00:00
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
2009-09-14 17:45:43 +00:00
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
|
|
|
/* Give the Timeline a Track */
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Create a Track");
|
2009-09-08 17:46:26 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY);
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
2010-12-15 18:05:48 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
/* The timeline steals the reference to the track */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2009-09-14 17:45:43 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Creating a source");
|
2009-08-07 18:31:11 +00:00
|
|
|
source = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (source != NULL);
|
|
|
|
|
2010-12-20 11:01:04 +00:00
|
|
|
/* The source will be floating before added to the layer... */
|
|
|
|
fail_unless (g_object_is_floating (source));
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Adding the source to the timeline layer");
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer,
|
|
|
|
GES_TIMELINE_OBJECT (source)));
|
2010-12-20 11:01:04 +00:00
|
|
|
fail_if (g_object_is_floating (source));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (source));
|
|
|
|
fail_unless (tmp_layer == layer);
|
2010-12-20 11:01:04 +00:00
|
|
|
/* The timeline stole our reference */
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (tmp_layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
/* Make sure the associated TrackObject is in the Track */
|
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (source));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 2 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 2);
|
2010-03-12 18:05:36 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Remove the TimelineObject from the layer");
|
2010-12-20 10:56:37 +00:00
|
|
|
|
2009-08-07 14:47:18 +00:00
|
|
|
/* Now remove the timelineobject */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (source);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-07 14:47:18 +00:00
|
|
|
fail_unless (ges_timeline_layer_remove_object (layer,
|
|
|
|
GES_TIMELINE_OBJECT (source)));
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (source));
|
|
|
|
fail_unless (tmp_layer == NULL);
|
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (source));
|
|
|
|
fail_unless (trackobjects == NULL); /* No unreffing then */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_unref (source);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Removing track from the timeline");
|
2009-08-07 14:47:18 +00:00
|
|
|
/* Remove the track from the timeline */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (track);
|
2009-08-07 14:47:18 +00:00
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == NULL);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
fail_unless (tracks == NULL);
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
|
|
|
g_object_unref (track);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Removing layer from the timeline");
|
2009-08-07 14:47:18 +00:00
|
|
|
/* Remove the layer from the timeline */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (layer);
|
2009-08-07 14:47:18 +00:00
|
|
|
fail_unless (ges_timeline_remove_layer (timeline, layer));
|
|
|
|
fail_unless (layer->timeline == NULL);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (layers == NULL);
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
g_object_unref (layer);
|
|
|
|
|
|
|
|
/* Finally clean up our object */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
|
|
|
g_object_unref (timeline);
|
2009-08-06 18:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-19 16:56:37 +00:00
|
|
|
/* very similar to the above, except we add the timeline object to the layer
|
|
|
|
* and then add it to the timeline.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_add_layer)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-19 16:56:37 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-19 16:56:37 +00:00
|
|
|
GESTrackObject *trackobject;
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY);
|
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
/* The timeline steals the reference to the track */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s1)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s2)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s2));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s3)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s3));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the trackobject
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 2 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the trackobject */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 2);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s2));
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 2 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the trackobject */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (trackobject), "trackobject", 2);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s3));
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 2 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the trackobject */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 2);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-20 15:23:22 +00:00
|
|
|
/* this time we add the layer before we add the track. */
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_add_layer_first)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-20 15:23:22 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY);
|
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s1)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s2)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s2));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s3)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s3));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* Each object has 3 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by _get_track_object() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
|
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s2));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* Each object has 3 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by _get_track_object() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
|
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s3));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* Each object has 3 references:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by _get_track_object() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-22 13:01:34 +00:00
|
|
|
GST_START_TEST (test_ges_timeline_remove_track)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-22 13:01:34 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
|
|
|
GESTrackObject *t1, *t2, *t3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, GST_CAPS_ANY);
|
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s1)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s2)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s2));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_TIMELINE_OBJECT (s3)));
|
2010-11-28 12:24:07 +00:00
|
|
|
tmp_layer = ges_timeline_object_get_layer (GES_TIMELINE_OBJECT (s3));
|
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s1));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t1 = GES_TRACK_OBJECT ((trackobjects)->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t1);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackobject", 3);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s2));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t2 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t2);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "t2", 3);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobjects =
|
|
|
|
ges_timeline_object_get_track_objects (GES_TIMELINE_OBJECT (s3));
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t3 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelineobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 3);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t3);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2010-12-20 10:56:37 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "t3", 3);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
/* remove the track and check that the track objects have been released */
|
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
|
|
|
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackobject", 1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "trackobject", 1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "trackobject", 1);
|
|
|
|
|
|
|
|
g_object_unref (t1);
|
|
|
|
g_object_unref (t2);
|
|
|
|
g_object_unref (t3);
|
|
|
|
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
2009-08-06 17:51:29 +00:00
|
|
|
static Suite *
|
|
|
|
ges_suite (void)
|
|
|
|
{
|
2010-12-20 10:38:31 +00:00
|
|
|
Suite *s = suite_create ("ges-basic");
|
2009-08-06 17:51:29 +00:00
|
|
|
TCase *tc_chain = tcase_create ("basic");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_ges_init);
|
2009-08-06 18:04:59 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_scenario);
|
2010-10-19 16:56:37 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_add_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_add_layer_first);
|
2010-10-22 13:01:34 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_remove_track);
|
2009-08-06 17:51:29 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int nf;
|
|
|
|
|
|
|
|
Suite *s = ges_suite ();
|
|
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
|
|
nf = srunner_ntests_failed (sr);
|
|
|
|
srunner_free (sr);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|