1 /* GStreamer Editing Services
2 * Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
4 * Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #include "test-utils.h"
25 #include <gst/check/gstcheck.h>
28 GST_START_TEST (test_ges_scenario)
30 GESTimeline *timeline;
31 GESLayer *layer, *tmp_layer;
34 GESTrackElement *trackelement;
35 GList *trackelements, *layers, *tracks;
38 /* This is the simplest scenario ever */
40 /* Timeline and 1 Layer */
41 GST_DEBUG ("Create a timeline");
42 timeline = ges_timeline_new ();
43 fail_unless (timeline != NULL);
45 GST_DEBUG ("Create a layer");
46 layer = ges_layer_new ();
47 fail_unless (layer != NULL);
49 GST_DEBUG ("Add the layer to the timeline");
50 fail_unless (ges_timeline_add_layer (timeline, layer));
51 /* The timeline steals our reference to the layer */
52 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
53 fail_unless (layer->timeline == timeline);
55 layers = ges_timeline_get_layers (timeline);
56 fail_unless (g_list_find (layers, layer) != NULL);
57 g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
60 /* Give the Timeline a Track */
61 GST_DEBUG ("Create a Track");
62 track = GES_TRACK (ges_video_track_new ());
63 fail_unless (track != NULL);
65 GST_DEBUG ("Add the track to the timeline");
66 fail_unless (ges_timeline_add_track (timeline, track));
68 /* The timeline steals the reference to the track */
69 ASSERT_OBJECT_REFCOUNT (track, "track", 1);
70 fail_unless (ges_track_get_timeline (track) == timeline);
71 fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
73 /* Create a source and add it to the Layer */
74 GST_DEBUG ("Creating a source");
75 source = ges_test_clip_new ();
76 fail_unless (source != NULL);
78 /* The source will be floating before added to the layer... */
79 fail_unless (g_object_is_floating (source));
80 GST_DEBUG ("Adding the source to the timeline layer");
81 fail_unless (ges_layer_add_clip (layer, GES_CLIP (source)));
82 fail_if (g_object_is_floating (source));
83 tmp_layer = ges_clip_get_layer (GES_CLIP (source));
84 fail_unless (tmp_layer == layer);
85 /* The timeline stole our reference */
86 ASSERT_OBJECT_REFCOUNT (source, "source + 1 timeline", 2);
87 gst_object_unref (tmp_layer);
88 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
90 /* Make sure the associated TrackElement is in the Track */
91 trackelements = GES_CONTAINER_CHILDREN (source);
92 fail_unless (trackelements != NULL);
93 trackelement = GES_TRACK_ELEMENT (trackelements->data);
94 /* There are 3 references:
97 * 1 by the timeline */
98 ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 3);
99 /* There are 3 references:
103 ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 3);
105 GST_DEBUG ("Remove the Clip from the layer");
107 /* Now remove the clip */
108 gst_object_ref (source);
109 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
110 fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source)));
111 ASSERT_OBJECT_REFCOUNT (source, "source", 1);
112 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
113 tmp_layer = ges_clip_get_layer (GES_CLIP (source));
114 fail_unless (tmp_layer == NULL);
115 gst_object_unref (source);
117 GST_DEBUG ("Removing track from the timeline");
118 /* Remove the track from the timeline */
119 gst_object_ref (track);
120 fail_unless (ges_timeline_remove_track (timeline, track));
121 fail_unless (ges_track_get_timeline (track) == NULL);
123 tracks = ges_timeline_get_tracks (timeline);
124 fail_unless (tracks == NULL);
125 ASSERT_OBJECT_REFCOUNT (track, "track", 1);
126 gst_object_unref (track);
128 GST_DEBUG ("Removing layer from the timeline");
129 /* Remove the layer from the timeline */
130 gst_object_ref (layer);
131 fail_unless (ges_timeline_remove_layer (timeline, layer));
132 fail_unless (layer->timeline == NULL);
134 layers = ges_timeline_get_layers (timeline);
135 fail_unless (layers == NULL);
136 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
137 gst_object_unref (layer);
139 /* Finally clean up our object */
140 ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
141 gst_object_unref (timeline);
148 /* very similar to the above, except we add the clip to the layer
149 * and then add it to the timeline.
152 GST_START_TEST (test_ges_timeline_add_layer)
154 GESTimeline *timeline;
155 GESLayer *layer, *tmp_layer;
157 GESTestClip *s1, *s2, *s3;
158 GList *trackelements, *layers;
159 GESTrackElement *trackelement;
163 /* Timeline and 1 Layer */
164 GST_DEBUG ("Create a timeline");
165 timeline = ges_timeline_new ();
166 fail_unless (timeline != NULL);
168 GST_DEBUG ("Create a layer");
169 layer = ges_layer_new ();
170 fail_unless (layer != NULL);
171 /* Give the Timeline a Track */
172 GST_DEBUG ("Create a Track");
173 track = GES_TRACK (ges_video_track_new ());
174 fail_unless (track != NULL);
176 GST_DEBUG ("Add the track to the timeline");
177 fail_unless (ges_timeline_add_track (timeline, track));
178 /* The timeline steals the reference to the track */
179 ASSERT_OBJECT_REFCOUNT (track, "track", 1);
180 fail_unless (ges_track_get_timeline (track) == timeline);
181 fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
183 /* Create a source and add it to the Layer */
184 GST_DEBUG ("Creating a source");
185 s1 = ges_test_clip_new ();
186 fail_unless (s1 != NULL);
187 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
188 tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
189 fail_unless (tmp_layer == layer);
190 ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
191 gst_object_unref (tmp_layer);
193 GST_DEBUG ("Creating a source");
194 s2 = ges_test_clip_new ();
195 fail_unless (s2 != NULL);
196 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
197 tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
198 fail_unless (tmp_layer == layer);
199 ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
200 gst_object_unref (tmp_layer);
202 GST_DEBUG ("Creating a source");
203 s3 = ges_test_clip_new ();
204 fail_unless (s3 != NULL);
205 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
206 tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
207 fail_unless (tmp_layer == layer);
208 ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
209 gst_object_unref (tmp_layer);
211 GST_DEBUG ("Add the layer to the timeline");
212 fail_unless (ges_timeline_add_layer (timeline, layer));
213 /* The timeline steals our reference to the layer */
214 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
215 fail_unless (layer->timeline == timeline);
216 layers = ges_timeline_get_layers (timeline);
217 fail_unless (g_list_find (layers, layer) != NULL);
218 g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
219 g_list_free (layers);
221 /* Make sure the associated TrackElements are in the Track */
222 trackelements = GES_CONTAINER_CHILDREN (s1);
223 fail_unless (trackelements != NULL);
224 trackelement = GES_TRACK_ELEMENT (trackelements->data);
225 /* There are 3 references:
227 * 1 by the trackelement
228 * 1 by the timeline */
229 ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 3);
230 /* There are 3 references:
233 * 1 by the trackelement */
234 ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 3);
236 trackelements = GES_CONTAINER_CHILDREN (s2);
237 trackelement = GES_TRACK_ELEMENT (trackelements->data);
238 fail_unless (trackelements != NULL);
240 /* There are 3 references:
243 * 1 by the trackelement */
244 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (trackelement), "trackelement", 3);
246 trackelements = GES_CONTAINER_CHILDREN (s3);
247 trackelement = GES_TRACK_ELEMENT (trackelements->data);
248 fail_unless (trackelements != NULL);
250 /* There are 3 references:
253 * 2 by the trackelement */
254 ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 3);
256 /* theoretically this is all we need to do to ensure cleanup */
257 gst_object_unref (timeline);
264 /* this time we add the layer before we add the track. */
266 GST_START_TEST (test_ges_timeline_add_layer_first)
268 GESTimeline *timeline;
269 GESLayer *layer, *tmp_layer;
271 GESTestClip *s1, *s2, *s3;
272 GList *trackelements, *tmp, *layers;
276 /* Timeline and 1 Layer */
277 GST_DEBUG ("Create a timeline");
278 timeline = ges_timeline_new ();
279 fail_unless (timeline != NULL);
281 GST_DEBUG ("Create a layer");
282 layer = ges_layer_new ();
283 fail_unless (layer != NULL);
284 /* Give the Timeline a Track */
285 GST_DEBUG ("Create a Track");
286 track = GES_TRACK (ges_video_track_new ());
287 fail_unless (track != NULL);
289 /* Create a source and add it to the Layer */
290 GST_DEBUG ("Creating a source");
291 s1 = ges_test_clip_new ();
292 fail_unless (s1 != NULL);
293 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
294 tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
295 fail_unless (tmp_layer == layer);
296 gst_object_unref (tmp_layer);
298 GST_DEBUG ("Creating a source");
299 s2 = ges_test_clip_new ();
300 fail_unless (s2 != NULL);
301 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
302 tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
303 fail_unless (tmp_layer == layer);
304 gst_object_unref (tmp_layer);
306 GST_DEBUG ("Creating a source");
307 s3 = ges_test_clip_new ();
308 fail_unless (s3 != NULL);
309 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
310 tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
311 fail_unless (tmp_layer == layer);
312 gst_object_unref (tmp_layer);
314 GST_DEBUG ("Add the layer to the timeline");
315 fail_unless (ges_timeline_add_layer (timeline, layer));
316 /* The timeline steals our reference to the layer */
317 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
318 fail_unless (layer->timeline == timeline);
319 layers = ges_timeline_get_layers (timeline);
320 fail_unless (g_list_find (layers, layer) != NULL);
321 g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
322 g_list_free (layers);
324 GST_DEBUG ("Add the track to the timeline");
325 fail_unless (ges_timeline_add_track (timeline, track));
326 ASSERT_OBJECT_REFCOUNT (track, "track", 1);
327 fail_unless (ges_track_get_timeline (track) == timeline);
328 fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
330 /* Make sure the associated TrackElements are in the Track */
331 trackelements = GES_CONTAINER_CHILDREN (s1);
332 fail_unless (trackelements != NULL);
333 for (tmp = trackelements; tmp; tmp = tmp->next) {
334 /* Each object has 3 references:
337 * 1 by the timeline */
338 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
341 trackelements = GES_CONTAINER_CHILDREN (s2);
342 fail_unless (trackelements != NULL);
343 for (tmp = trackelements; tmp; tmp = tmp->next) {
344 /* Each object has 3 references:
347 * 1 by the timeline */
348 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
351 trackelements = GES_CONTAINER_CHILDREN (s3);
352 fail_unless (trackelements != NULL);
353 for (tmp = trackelements; tmp; tmp = tmp->next) {
354 /* Each object has 3 references:
357 * 1 by the timeline */
358 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
361 /* theoretically this is all we need to do to ensure cleanup */
362 gst_object_unref (timeline);
369 GST_START_TEST (test_ges_timeline_remove_track)
371 GESTimeline *timeline;
372 GESLayer *layer, *tmp_layer;
374 GESTestClip *s1, *s2, *s3;
375 GESTrackElement *t1, *t2, *t3;
376 GList *trackelements, *tmp, *layers;
380 /* Timeline and 1 Layer */
381 GST_DEBUG ("Create a timeline");
382 timeline = ges_timeline_new ();
383 fail_unless (timeline != NULL);
385 GST_DEBUG ("Create a layer");
386 layer = ges_layer_new ();
387 fail_unless (layer != NULL);
388 /* Give the Timeline a Track */
389 GST_DEBUG ("Create a Track");
390 track = GES_TRACK (ges_video_track_new ());
391 fail_unless (track != NULL);
393 /* Create a source and add it to the Layer */
394 GST_DEBUG ("Creating a source");
395 s1 = ges_test_clip_new ();
396 fail_unless (s1 != NULL);
397 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
398 tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
399 fail_unless (tmp_layer == layer);
400 gst_object_unref (tmp_layer);
401 ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
403 GST_DEBUG ("Creating a source");
404 s2 = ges_test_clip_new ();
405 fail_unless (s2 != NULL);
406 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
407 tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
408 fail_unless (tmp_layer == layer);
409 gst_object_unref (tmp_layer);
410 ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
412 GST_DEBUG ("Creating a source");
413 s3 = ges_test_clip_new ();
414 fail_unless (s3 != NULL);
415 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
416 tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
417 fail_unless (tmp_layer == layer);
418 gst_object_unref (tmp_layer);
419 ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
421 GST_DEBUG ("Add the layer to the timeline");
422 fail_unless (ges_timeline_add_layer (timeline, layer));
423 /* The timeline steals our reference to the layer */
424 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
425 fail_unless (layer->timeline == timeline);
427 layers = ges_timeline_get_layers (timeline);
428 fail_unless (g_list_find (layers, layer) != NULL);
429 g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
430 g_list_free (layers);
431 ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
433 GST_DEBUG ("Add the track to the timeline");
434 fail_unless (ges_timeline_add_track (timeline, track));
435 ASSERT_OBJECT_REFCOUNT (track, "track", 1);
436 fail_unless (ges_track_get_timeline (track) == timeline);
437 fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
439 /* Make sure the associated TrackElements are in the Track */
440 trackelements = GES_CONTAINER_CHILDREN (s1);
441 fail_unless (trackelements != NULL);
442 t1 = GES_TRACK_ELEMENT ((trackelements)->data);
443 for (tmp = trackelements; tmp; tmp = tmp->next) {
444 /* There are 3 references held:
447 * 1 by the timeline */
448 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
450 /* There are 3 references held:
453 * 1 by the timeline */
454 ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 3);
456 trackelements = GES_CONTAINER_CHILDREN (s2);
457 fail_unless (trackelements != NULL);
458 t2 = GES_TRACK_ELEMENT (trackelements->data);
459 for (tmp = trackelements; tmp; tmp = tmp->next) {
460 /* There are 3 references held:
463 * 1 by the timeline */
464 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
466 /* There are 3 references held:
469 * 1 by the timeline */
470 ASSERT_OBJECT_REFCOUNT (t2, "t2", 3);
472 trackelements = GES_CONTAINER_CHILDREN (s3);
473 fail_unless (trackelements != NULL);
474 t3 = GES_TRACK_ELEMENT (trackelements->data);
475 for (tmp = trackelements; tmp; tmp = tmp->next) {
476 /* There are 3 references held:
479 * 1 by the timeline */
480 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
482 /* There are 3 references held:
485 * 1 by the timeline */
486 ASSERT_OBJECT_REFCOUNT (t3, "t3", 3);
488 /* remove the track and check that the track elements have been released */
489 fail_unless (ges_timeline_remove_track (timeline, track));
491 ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 1);
492 ASSERT_OBJECT_REFCOUNT (t2, "trackelement", 1);
493 ASSERT_OBJECT_REFCOUNT (t3, "trackelement", 1);
494 ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
495 ASSERT_OBJECT_REFCOUNT (timeline, "1 for the us", 1);
496 tmp = ges_layer_get_clips (layer);
497 assert_equals_int (g_list_length (tmp), 3);
498 g_list_free_full (tmp, (GDestroyNotify) gst_object_unref);
500 gst_check_objects_destroyed_on_unref (G_OBJECT (timeline),
501 G_OBJECT (layer), t1, t2, t3, NULL);
510 GESTestClip **o1, **o2, **o3;
511 GESTrack **tr1, **tr2;
515 select_tracks_cb (GESTimeline * timeline, GESClip * clip,
516 GESTrackElement * track_element, SelectTracksData * st_data)
520 GPtrArray *ret = g_ptr_array_new ();
521 track = (clip == (GESClip *) * st_data->o2) ? *st_data->tr2 : *st_data->tr1;
523 gst_object_ref (track);
525 g_ptr_array_add (ret, track);
530 GST_START_TEST (test_ges_timeline_multiple_tracks)
532 GESTimeline *timeline;
533 GESLayer *layer, *tmp_layer;
534 GESTrack *track1, *track2;
535 GESTestClip *s1, *s2, *s3;
536 GESTrackElement *t1, *t2, *t3;
537 GList *trackelements, *tmp, *layers;
538 SelectTracksData st_data = { &s1, &s2, &s3, &track1, &track2 };
542 /* Timeline and 1 Layer */
543 GST_DEBUG ("Create a timeline");
544 timeline = ges_timeline_new ();
545 fail_unless (timeline != NULL);
547 g_signal_connect (timeline, "select-tracks-for-object",
548 G_CALLBACK (select_tracks_cb), &st_data);
550 GST_DEBUG ("Create a layer");
551 layer = ges_layer_new ();
552 fail_unless (layer != NULL);
553 /* Give the Timeline a Track */
554 GST_DEBUG ("Create Track 1");
555 track1 = GES_TRACK (ges_video_track_new ());
556 fail_unless (track1 != NULL);
557 GST_DEBUG ("Create Track 2");
558 track2 = GES_TRACK (ges_video_track_new ());
559 fail_unless (track2 != NULL);
561 GST_DEBUG ("Add the track 1 to the timeline");
562 fail_unless (ges_timeline_add_track (timeline, track1));
563 ASSERT_OBJECT_REFCOUNT (track1, "track", 1);
564 fail_unless (ges_track_get_timeline (track1) == timeline);
565 fail_unless ((gpointer) GST_ELEMENT_PARENT (track1) == (gpointer) timeline);
567 GST_DEBUG ("Add the track 2 to the timeline");
568 fail_unless (ges_timeline_add_track (timeline, track2));
569 ASSERT_OBJECT_REFCOUNT (track2, "track", 1);
570 fail_unless (ges_track_get_timeline (track2) == timeline);
571 fail_unless ((gpointer) GST_ELEMENT_PARENT (track2) == (gpointer) timeline);
573 /* Create a source and add it to the Layer */
574 GST_DEBUG ("Creating a source");
575 s1 = ges_test_clip_new ();
576 fail_unless (s1 != NULL);
577 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
578 tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
579 fail_unless (tmp_layer == layer);
580 gst_object_unref (tmp_layer);
582 GST_DEBUG ("Creating a source");
583 s2 = ges_test_clip_new ();
584 fail_unless (s2 != NULL);
585 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
586 tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
587 fail_unless (tmp_layer == layer);
588 gst_object_unref (tmp_layer);
590 GST_DEBUG ("Creating a source");
591 s3 = ges_test_clip_new ();
592 fail_unless (s3 != NULL);
593 fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
594 tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
595 fail_unless (tmp_layer == layer);
596 gst_object_unref (tmp_layer);
598 GST_DEBUG ("Add the layer to the timeline");
599 fail_unless (ges_timeline_add_layer (timeline, layer));
600 /* The timeline steals our reference to the layer */
601 ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
602 fail_unless (layer->timeline == timeline);
604 layers = ges_timeline_get_layers (timeline);
605 fail_unless (g_list_find (layers, layer) != NULL);
606 g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
607 g_list_free (layers);
609 /* Make sure the associated TrackElements are in the Track */
610 trackelements = GES_CONTAINER_CHILDREN (s1);
611 fail_unless (trackelements != NULL);
612 t1 = GES_TRACK_ELEMENT ((trackelements)->data);
613 for (tmp = trackelements; tmp; tmp = tmp->next) {
614 /* There are 3 references held:
617 * 1 by the timeline */
618 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
619 fail_unless (ges_track_element_get_track (tmp->data) == track1);
622 /* There are 3 references held:
626 * 1 added by ourselves above (gst_object_ref (t1)) */
627 ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 4);
629 trackelements = GES_CONTAINER_CHILDREN (s2);
630 fail_unless (trackelements != NULL);
631 t2 = GES_TRACK_ELEMENT (trackelements->data);
632 for (tmp = trackelements; tmp; tmp = tmp->next) {
633 /* There are 3 references held:
636 * 1 by the timeline */
637 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
638 fail_unless (ges_track_element_get_track (tmp->data) == track2);
641 /* There are 3 references held:
645 * 1 added by ourselves above (gst_object_ref (t2)) */
646 ASSERT_OBJECT_REFCOUNT (t2, "t2", 4);
648 trackelements = GES_CONTAINER_CHILDREN (s3);
649 fail_unless (trackelements != NULL);
650 t3 = GES_TRACK_ELEMENT (trackelements->data);
651 for (tmp = trackelements; tmp; tmp = tmp->next) {
652 /* There are 3 references held:
655 * 1 by the timeline */
656 ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 3);
657 fail_unless (ges_track_element_get_track (tmp->data) == track1);
660 /* There are 3 references held:
664 * 1 added by ourselves above (gst_object_ref (t3)) */
665 ASSERT_OBJECT_REFCOUNT (t3, "t3", 4);
667 gst_object_unref (t1);
668 gst_object_unref (t2);
669 gst_object_unref (t3);
671 gst_object_unref (timeline);
678 GST_START_TEST (test_ges_pipeline_change_state)
683 GESTimeline *timeline;
684 GESPipeline *pipeline;
688 layer = ges_layer_new ();
689 timeline = ges_timeline_new_audio_video ();
690 fail_unless (ges_timeline_add_layer (timeline, layer));
692 pipeline = ges_test_create_pipeline (timeline);
694 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
695 ges_layer_add_asset (layer, asset, 0, 0, 10, GES_TRACK_TYPE_UNKNOWN);
696 gst_object_unref (asset);
698 ges_timeline_commit (timeline);
699 ASSERT_SET_STATE (GST_ELEMENT (pipeline), GST_STATE_PLAYING,
700 GST_STATE_CHANGE_ASYNC);
701 fail_unless (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL,
702 GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_SUCCESS);
703 fail_unless (state == GST_STATE_PLAYING);
704 ASSERT_SET_STATE (GST_ELEMENT (pipeline), GST_STATE_NULL,
705 GST_STATE_CHANGE_SUCCESS);
707 gst_object_unref (pipeline);
714 GST_START_TEST (test_ges_timeline_element_name)
716 GESClip *clip, *clip1, *clip2, *clip3, *clip4, *clip5;
718 GESTimeline *timeline;
723 timeline = ges_timeline_new_audio_video ();
724 layer = ges_layer_new ();
725 fail_unless (ges_timeline_add_layer (timeline, layer));
727 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
728 clip = ges_layer_add_asset (layer, asset, 0, 0, 10, GES_TRACK_TYPE_UNKNOWN);
729 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip), "testclip0");
732 clip1 = GES_CLIP (ges_test_clip_new ());
733 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip1");
735 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip1), "testclip1");
736 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip1");
738 /* Check that trying to set to a name that is already used leads to
739 * a change in the name */
740 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip), "testclip1");
741 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip), "testclip2");
743 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip1), "testclip4");
744 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip4");
746 clip2 = GES_CLIP (ges_test_clip_new ());
747 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip2), "testclip5");
748 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip2), NULL);
749 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip2), "testclip6");
751 clip3 = GES_CLIP (ges_test_clip_new ());
752 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip3), "testclip7");
753 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip3), "testclip5");
754 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip3), "testclip8");
756 clip4 = GES_CLIP (ges_test_clip_new ());
757 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip4), "testclip9");
760 clip5 = GES_CLIP (ges_test_clip_new ());
761 ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip5),
762 "Something I want!");
763 fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip5),
764 "Something I want!");
766 gst_object_unref (asset);
768 gst_object_unref (clip1);
769 gst_object_unref (clip2);
770 gst_object_unref (clip3);
771 gst_object_unref (clip4);
772 gst_object_unref (clip5);
773 gst_object_unref (timeline);
783 Suite *s = suite_create ("ges-basic");
784 TCase *tc_chain = tcase_create ("basic");
786 suite_add_tcase (s, tc_chain);
788 tcase_add_test (tc_chain, test_ges_scenario);
789 tcase_add_test (tc_chain, test_ges_timeline_add_layer);
790 tcase_add_test (tc_chain, test_ges_timeline_add_layer_first);
791 tcase_add_test (tc_chain, test_ges_timeline_remove_track);
792 tcase_add_test (tc_chain, test_ges_timeline_multiple_tracks);
793 tcase_add_test (tc_chain, test_ges_pipeline_change_state);
794 tcase_add_test (tc_chain, test_ges_timeline_element_name);
799 GST_CHECK_MAIN (ges);