[pitivi] timeline.py, test_timeline.py: add getObjsAtTime() method and tests
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pitivi] timeline.py, test_timeline.py: add getObjsAtTime() method and tests
- Date: Thu, 26 Nov 2009 13:12:19 +0000 (UTC)
commit ebeda0ce4e02e36ca13fe2e074f3d5568c9757ce
Author: Brandon Lewis <brandon_lewis alum berkeley edu>
Date: Fri Nov 20 19:23:01 2009 -0800
timeline.py,test_timeline.py: add getObjsAtTime() method and tests
pitivi/timeline/timeline.py | 6 ++++++
tests/test_timeline.py | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index cf6761e..f0f0573 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1815,6 +1815,12 @@ class Timeline(Signallable, Loggable):
self.emit("disable-updates", False)
+ def getObjsAtTime(self, time_):
+ objects = self.timeline_objects
+ return [obj for obj in objects if
+ (obj.start < time_) and
+ ((obj.start + obj.duration) > time_)]
+
def getObjsAfterObj(self, obj):
return self.getObjsAfterTime(obj.start + obj.duration)
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index 795f8b5..c94f134 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -447,6 +447,45 @@ class TestTimeline(TestCase):
prev = timeline.getNextTimelineObject(timeline_object3, priority=None)
self.failUnlessEqual(prev, timeline_object4)
+ def testGetObjsAtTime(self):
+ # we're going use this time as our test time
+ time1 = 0
+ time2 = 3 * gst.SECOND
+ time3 = 6 * gst.SECOND
+ time4 = 10 * gst.SECOND
+
+ clip1 = self.makeTimelineObject()
+ clip1.start = 2 * gst.SECOND
+ clip1.duration = 5 * gst.SECOND
+
+ # clip2 -- overlaps left edge of clip1
+ clip2 = self.makeTimelineObject()
+ clip2.start = 1 * gst.SECOND
+ clip2.duration = 4 * gst.SECOND
+
+ # clip 3 -- overlaps right edge of clip1
+ clip3 = self.makeTimelineObject()
+ clip3.start = long(2.5 * gst.SECOND)
+ clip3.duration = 5 * gst.SECOND
+
+ # clip 4 -- doesn't overlap at all
+ clip4 = self.makeTimelineObject()
+ clip4.start = 10 * gst.SECOND
+ clip4.duration = 4 * gst.SECOND
+
+ result = set(self.timeline.getObjsAtTime(time1))
+ self.failUnlessEqual(result, set())
+
+ result = set(self.timeline.getObjsAtTime(time2))
+ self.failUnlessEqual(result, set((clip1, clip2, clip3)))
+
+ result = set(self.timeline.getObjsAtTime(time3))
+ self.failUnlessEqual(result, set((clip1, clip3)))
+
+ result = set(self.timeline.getObjsAtTime(time4))
+ self.failUnlessEqual(result, set())
+
+
class TestLink(TestCase):
def test(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]