SimpleTimelineLayer: Remove bogus check and extend unit test to validate it
authorThibault Saunier <thibault.saunier@collabora.co.uk>
Wed, 1 Dec 2010 11:16:37 +0000 (12:16 +0100)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Thu, 2 Dec 2010 10:55:44 +0000 (11:55 +0100)
ges/ges-simple-timeline-layer.c
tests/check/ges/simplelayer.c

index e5c9bda..4139b76 100644 (file)
@@ -390,9 +390,6 @@ ges_simple_timeline_layer_move_object (GESSimpleTimelineLayer * layer,
   /* pop it off the list */
   layer->objects = g_list_remove (layer->objects, object);
 
-  newposition = (newposition >= 0 && newposition < idx) ? newposition :
-      newposition - 1;
-
   /* re-add it at the proper position */
   layer->objects = g_list_insert (layer->objects, object, newposition);
 
index 1912692..f87fe29 100644 (file)
@@ -157,13 +157,21 @@ GST_START_TEST (test_gsl_move_simple)
   fail_unless_equals_int (info.new, 0);
   fail_unless_equals_int (info.old, 1);
 
-  /* Move source2 to end (newpos:-1) */
+  /* Move source2 after source 1 (newpos:0) */
   fail_unless (ges_simple_timeline_layer_move_object (GES_SIMPLE_TIMELINE_LAYER
-          (layer), GES_TIMELINE_OBJECT (source2), -1));
+          (layer), GES_TIMELINE_OBJECT (source2), 1));
   fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source1), 0);
   fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), GST_SECOND);
+  fail_unless_equals_int (info.new, 1);
+  fail_unless_equals_int (info.old, 0);
+
+  /* Move source1 to end (newpos:-1) */
+  fail_unless (ges_simple_timeline_layer_move_object (GES_SIMPLE_TIMELINE_LAYER
+          (layer), GES_TIMELINE_OBJECT (source1), -1));
+  fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source1), GST_SECOND);
+  fail_unless_equals_uint64 (GES_TIMELINE_OBJECT_START (source2), 0);
   /* position will be decremented, this is expected */
-  fail_unless_equals_int (info.new, -2);
+  fail_unless_equals_int (info.new, -1);
   fail_unless_equals_int (info.old, 0);
 
   /* remove source1, source2 should be moved to the beginning */