[pitivi] fix timelineedges unit tests
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] fix timelineedges unit tests
- Date: Fri, 10 Jul 2009 11:40:48 +0000 (UTC)
commit 554ec33f9501c98e728802070e8a1e36522c97dd
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date: Thu May 21 14:52:20 2009 -0700
fix timelineedges unit tests
pitivi/timeline/timeline.py | 27 ------------------
tests/test_timeline.py | 63 +++++++++++++++++--------------------------
2 files changed, 25 insertions(+), 65 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 4b21797..f1853f7 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -719,33 +719,6 @@ class TimelineEdges(object):
self.edges.insert(index, edge)
self.by_time[edge] = []
- def removeStartEnd(self, start, end=None):
- """
- Remove the given start/end values from the list of edges being tracked.
-
- @param start: A start position to stop tracking.
- @type start: L{long}
- @param end: A stop position to stop tracking.
- @type end: L{long}
- """
- if len(self.edges) == 0:
- raise TimelineError()
-
- val, diff, start_index = closest_item(self.edges, start)
- if val != start:
- raise TimelineError()
-
- if end is not None and len(self.edges) > 1:
- val, diff, end_index = closest_item(self.edges, end, start_index)
- if val != end:
- raise TimelineError()
- else:
- end_index = None
-
- del self.edges[start_index]
- if end_index is not None:
- del self.edges[end_index-1]
-
def snapToEdge(self, start, end=None):
"""
Returns:
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index a7b890b..7f09905 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -486,49 +486,32 @@ class TestLink(TestCase):
self.failUnlessEqual(timeline_object3.start, 8 * gst.SECOND)
class TestTimelineEdges(TestCase):
+
def setUp(self):
TestCase.setUp(self)
self.timeline_edges = TimelineEdges()
+ self.factory = StubFactory()
+ self.stream = AudioStream(gst.Caps('audio/x-raw-int'))
+ self.factory.addOutputStream(self.stream)
+ self.t1 = SourceTrackObject(self.factory, self.stream)
+ self.t2 = SourceTrackObject(self.factory, self.stream)
- def testRemove(self):
- self.timeline_edges.addStartEnd(0, 2000)
- self.timeline_edges.removeStartEnd(0, 2000)
-
- def testRemoveNotExisting(self):
- self.failUnlessRaises(TimelineError,
- self.timeline_edges.removeStartEnd, 1, 2000)
-
- self.timeline_edges.addStartEnd(0, 2000)
- self.failUnlessRaises(TimelineError,
- self.timeline_edges.removeStartEnd, 1, 2000)
- self.failUnlessRaises(TimelineError,
- self.timeline_edges.removeStartEnd, 0, 2001)
+ def tearDown(self):
+ del self.t1
+ del self.t2
+ del self.stream
+ del self.factory
+ del self.timeline_edges
+ TestCase.tearDown(self)
def testNoEdges(self):
+ # test that edges object returns (start, 0)
self.failUnlessEqual(self.timeline_edges.snapToEdge(500, 1000), (500, 0))
- def testSimple(self):
- self.timeline_edges.addStartEnd(0, 2000)
- self.failUnlessEqual(self.timeline_edges.snapToEdge(500, 1000), (0, 500))
-
- self.timeline_edges.removeStartEnd(0, 2000)
-
- def testSamePosition(self):
- self.timeline_edges.addStartEnd(0, 2000)
- self.timeline_edges.addStartEnd(0, 2000)
-
- self.failUnlessEqual(self.timeline_edges.snapToEdge(500, 1000), (0, 500))
-
- self.timeline_edges.removeStartEnd(0, 2000)
-
- self.failUnlessEqual(self.timeline_edges.snapToEdge(500, 1000), (0, 500))
-
- self.timeline_edges.removeStartEnd(0, 2000)
-
- def testSnapStart(self):
- self.timeline_edges = TimelineEdges()
-
- self.timeline_edges.addStartEnd(1000, 2000)
+ def testSingleEdge(self):
+ self.t1.start = 1000
+ self.t1.duration = 1000
+ self.timeline_edges.addTrackObject(self.t1)
# match start-left
self.failUnlessEqual(self.timeline_edges.snapToEdge(900, 1400), (1000, 100))
@@ -551,9 +534,6 @@ class TestTimelineEdges(TestCase):
# match both start and end, start is returned
self.failUnlessEqual(self.timeline_edges.snapToEdge(1000, 2000), (1000, 0))
- def testSnapDuration(self):
- self.timeline_edges.addStartEnd(1000, 2000)
-
# match start-left
self.failUnlessEqual(self.timeline_edges.snapToEdge(900), (1000, 100))
@@ -572,6 +552,13 @@ class TestTimelineEdges(TestCase):
# match end-right
self.failUnlessEqual(self.timeline_edges.snapToEdge(3000), (2000, 1000))
+ def testSamePosition(self):
+ self.t2.start = 1000
+ self.t2.duration = 1000
+ self.timeline_edges.addTrackObject(self.t2)
+ self.testSingleEdge()
+
+
class TestTimelineAddFactory(TestCase):
def setUp(self):
TestCase.setUp(self)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]