[pitivi] tests: Add testRemoveEffectFromClip and testChangeEffectProperty



commit de5020ac5649dd5b65f1e6452a57a138ec4af23b
Author: Thibault Saunier <tsaunier gnome org>
Date:   Sun May 4 11:58:16 2014 +0200

    tests: Add testRemoveEffectFromClip and testChangeEffectProperty
    
    +minor fix on the usage of the GES.Effect() API as the converters are added
    automatically by GES

 tests/test_undo_timeline.py |   81 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 80 insertions(+), 1 deletions(-)
---
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 11893c2..55e45be 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -30,6 +30,7 @@ from tests import common
 from pitivi.undo.timeline import TimelineLogObserver, \
     ClipAdded, ClipRemoved, \
     ClipPropertyChanged, EffectAdded
+from pitivi.undo.effect import EffectPropertyChanged
 from pitivi.undo.undo import UndoableActionLog
 
 
@@ -170,7 +171,7 @@ class TestTimelineUndo(TestCase):
         clip1 = GES.TitleClip()
         self.layer.add_clip(clip1)
 
-        effect1 = GES.Effect.new("videoconvert ! agingtv ! videoconvert")
+        effect1 = GES.Effect.new("agingtv")
         self.action_log.begin("add effect")
         clip1.add(effect1)
         self.action_log.commit()
@@ -194,6 +195,84 @@ class TestTimelineUndo(TestCase):
                                  clip1.get_children(True)
                                  if isinstance(effect, GES.Effect)]))
 
+    def testRemoveEffectFromClip(self):
+        stacks = []
+        self.action_log.connect("commit", TestTimelineUndo.commitCb, stacks)
+
+        clip1 = GES.TitleClip()
+        self.layer.add_clip(clip1)
+
+        effect1 = GES.Effect.new("agingtv")
+        self.action_log.begin("add effect")
+        clip1.add(effect1)
+        self.action_log.commit()
+
+        self.assertEqual(1, len(stacks))
+        stack = stacks[0]
+        self.assertEqual(1, len(stack.done_actions), stack.done_actions)
+        action = stack.done_actions[0]
+        self.assertTrue(isinstance(action, EffectAdded))
+
+        self.assertTrue(effect1 in clip1.get_children(True))
+        self.assertEqual(1, len([effect for effect in
+                                 clip1.get_children(True)
+                                 if isinstance(effect, GES.Effect)]))
+
+        self.action_log.begin("remove effect")
+        clip1.remove(effect1)
+        self.action_log.commit()
+
+        self.assertEqual(0, len([effect for effect in
+                                 clip1.get_children(True)
+                                 if isinstance(effect, GES.Effect)]))
+
+        self.action_log.undo()
+        self.assertEqual(1, len([effect for effect in
+                                 clip1.get_children(True)
+                                 if isinstance(effect, GES.Effect)]))
+
+        self.action_log.redo()
+        self.assertEqual(0, len([effect for effect in
+                                 clip1.get_children(True)
+                                 if isinstance(effect, GES.Effect)]))
+
+    def testChangeEffectProperty(self):
+        stacks = []
+        self.action_log.connect("commit", TestTimelineUndo.commitCb, stacks)
+
+        clip1 = GES.TitleClip()
+        self.layer.add_clip(clip1)
+
+        effect1 = GES.Effect.new("agingtv")
+        self.action_log.begin("add effect")
+        clip1.add(effect1)
+        self.action_log.commit()
+
+        self.assertEqual(1, len(stacks))
+        stack = stacks[0]
+        self.assertEqual(1, len(stack.done_actions), stack.done_actions)
+        action = stack.done_actions[0]
+        self.assertTrue(isinstance(action, EffectAdded))
+
+        self.assertTrue(effect1 in clip1.get_children(True))
+        self.assertEqual(1, len([effect for effect in
+                                 clip1.get_children(True)
+                                 if isinstance(effect, GES.Effect)]))
+
+        self.action_log.begin("change child property")
+        effect1.set_child_property("scratch-lines", 0)
+        self.action_log.commit()
+
+        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
+        self.action_log.undo()
+        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 7)
+        self.action_log.redo()
+        self.assertEqual(effect1.get_child_property("scratch-lines")[1], 0)
+        self.action_log.undo()
+        self.assertTrue(effect1 in clip1.get_children(True))
+        self.action_log.undo()
+        self.assertFalse(effect1 in clip1.get_children(True))
+
     def testClipPropertyChange(self):
         stacks = []
         self.action_log.connect("commit", TestTimelineUndo.commitCb, stacks)


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