[pitivi] test_timeline: add test cases for adjacency functions



commit 37665f1eaf9c4c086ac856c86bfd5b115dd85b10
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Thu May 21 15:52:42 2009 -0700

    test_timeline: add test cases for adjacency functions

 pitivi/timeline/timeline.py |   10 +++++-----
 tests/test_timeline.py      |   14 ++++++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f1853f7..cc3d60e 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -765,16 +765,16 @@ class TimelineEdges(object):
     def getObjsAdjacentToStart(self, trackobj):
         """Return a list of all track objects whose ends (start + duration)
         are equal to the given track object's start"""
-        end = trackobj.start + trackobj.duration
-        if end in self.by_end:
-            return self.by_end[end]
+        if trackobj.start in self.by_end:
+            return self.by_end[trackobj.start]
         return []
 
     def getObjsAdjacentToEnd(self, trackobj):
         """Return a list of all track objects whose start property are
         adjacent to the given track object's end (start + duration)"""
-        if trackobj.start in self.by_start:
-            return self.by_start[trackobj.start]
+        end = trackobj.start + trackobj.duration
+        if end in self.by_start:
+            return self.by_start[end]
         return []
 
 
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index 7f09905..44b6712 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -558,6 +558,20 @@ class TestTimelineEdges(TestCase):
         self.timeline_edges.addTrackObject(self.t2)
         self.testSingleEdge()
 
+    def testGetAdjacenctObjs(self):
+        self.t1.start = 500 
+        self.t1.duration = 500
+        self.t2.start = 1000
+        self.t2.duration = 500
+        self.timeline_edges.addTrackObject(self.t1)
+        self.timeline_edges.addTrackObject(self.t2)
+        self.assertEquals(set(self.timeline_edges.getObjsIncidentOnTime(1000)),
+            set([self.t1, self.t2]))
+        self.assertEquals(set(self.timeline_edges.getObjsAdjacentToStart(self.t2)),
+            set([self.t1]))
+        self.assertEquals(set(self.timeline_edges.getObjsAdjacentToEnd(self.t1)),
+            set([self.t2]))
+
 
 class TestTimelineAddFactory(TestCase):
     def setUp(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]