[pitivi] [test_]timeline.py: check in Timeline.split() method and unit tests
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pitivi] [test_]timeline.py: check in Timeline.split() method and unit tests
- Date: Thu, 26 Nov 2009 13:12:24 +0000 (UTC)
commit 92f680b2e0864cd0ede26323652504e6ad7b99ca
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date: Mon Nov 23 10:45:55 2009 -0800
[test_]timeline.py: check in Timeline.split() method and unit tests
pitivi/timeline/timeline.py | 11 ++++++++
tests/test_timeline.py | 56 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f0f0573..3f6f1ed 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1771,6 +1771,17 @@ class Timeline(Signallable, Loggable):
self.removeTimelineObject(timeline_object, deep=True)
self.selection.setTo(set([]), SELECT)
+ def split(self, time):
+ """
+ Splits objects under the playehad. If the selection is not empty, the
+ split only applies to selected clips. Otherwise it applies to all
+ clips"""
+ objs = set(self.getObjsAtTime(time))
+ if len(self.selection):
+ objs = self.selection.selected.intersection(objs)
+ for obj in objs:
+ obj.split(time)
+
def rebuildEdges(self):
self.edges = TimelineEdges()
for timeline_object in self.timeline_objects:
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index c94f134..fad4d4b 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -485,6 +485,62 @@ class TestTimeline(TestCase):
result = set(self.timeline.getObjsAtTime(time4))
self.failUnlessEqual(result, set())
+ def testSplitSelection(self):
+ # we're going use this time as our test time
+ noclips = 7 * gst.SECOND
+ oneclip = long(6.5 * gst.SECOND)
+ threeclips = long(4.5 * gst.SECOND)
+ fourclipsoneselected = long(2.5 * gst.SECOND)
+
+ clip1 = self.makeTimelineObject()
+ clip1.start = 2 * gst.SECOND
+ clip1.duration = 5 * gst.SECOND
+
+ clip2 = self.makeTimelineObject()
+ clip2.start = 2 * gst.SECOND
+ clip2.duration = 4 * gst.SECOND
+
+ clip3 = self.makeTimelineObject()
+ clip3.start = 2 * gst.SECOND
+ clip3.duration = 3 * gst.SECOND
+
+ clip4 = self.makeTimelineObject()
+ clip4.start = 2 * gst.SECOND
+ clip4.duration = 2 * gst.SECOND
+
+ # test split no clips
+ self.timeline.split(noclips)
+ for i, clip in enumerate([clip1,clip2,clip3,clip4]):
+ self.failUnlessEqual(clip.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip.duration,
+ (5 - i) * gst.SECOND)
+
+ # test split one clip
+ self.timeline.split(oneclip)
+ self.failUnlessEqual(clip1.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip1.duration, oneclip - 2 * gst.SECOND)
+ for i, clip in enumerate([clip2,clip3,clip4]):
+ self.failUnlessEqual(clip.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip.duration,
+ (5 - (i + 1)) * gst.SECOND)
+
+ # test split three clips
+ self.timeline.split(threeclips)
+ for i, clip in enumerate([clip1,clip2,clip3]):
+ self.failUnlessEqual(clip.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip.start + clip.duration, threeclips)
+ self.failUnlessEqual(clip4.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip4.duration, 2 * gst.SECOND)
+
+ # test split three clips, one selected
+ self.timeline.selection.selected = set((clip4,))
+ self.timeline.split(fourclipsoneselected)
+ for i, clip in enumerate([clip1,clip2,clip3]):
+ self.failUnlessEqual(clip.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip.start + clip.duration, threeclips)
+ self.failUnlessEqual(clip4.start, 2 * gst.SECOND)
+ self.failUnlessEqual(clip4.duration + clip4.start,
+ fourclipsoneselected)
class TestLink(TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]