[pitivi] undo: Keep track only of UriClipAssets



commit 8fcaa6fd45f8b2a742360805288895d90e5121c5
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Oct 11 13:33:03 2016 +0200

    undo: Keep track only of UriClipAssets
    
    Transition, title and effect assets are now ignored as they are added
    automatically and there is no benefit tracking them.
    
    Fixes https://phabricator.freedesktop.org/T7585
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D1377

 pitivi/undo/project.py      |    5 +++++
 tests/test_undo_timeline.py |   19 ++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/undo/project.py b/pitivi/undo/project.py
index 5989cc4..6296e04 100644
--- a/pitivi/undo/project.py
+++ b/pitivi/undo/project.py
@@ -16,6 +16,7 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
+from gi.repository import GES
 from gi.repository import GObject
 from gi.repository import Gst
 
@@ -81,9 +82,13 @@ class ProjectObserver(MetaContainerObserver):
                                                   action_log)
 
     def _assetAddedCb(self, project, asset):
+        if not isinstance(asset, GES.UriClipAsset):
+            return
         action = AssetAddedAction(project, asset)
         self.action_log.push(action)
 
     def _assetRemovedCb(self, project, asset):
+        if not isinstance(asset, GES.UriClipAsset):
+            return
         action = AssetRemovedAction(project, asset)
         self.action_log.push(action)
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 91e41c2..830762f 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -203,19 +203,14 @@ class TestLayerObserver(BaseTestUndoTimeline):
         self.action_log.redo()
         self.assertEqual(layer._nameIfSet(), "Beautiful name")
 
-    def testAddClip(self):
-        stacks = []
-        self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
-
+    def test_add_clip(self):
         clip1 = GES.TitleClip()
         with self.action_log.started("add clip"):
             self.layer.add_clip(clip1)
 
-        self.assertEqual(1, len(stacks))
-        stack = stacks[0]
-        self.assertEqual(2, len(stack.done_actions), stack.done_actions)
+        stack, = self.action_log.undo_stacks
+        self.assertEqual(len(stack.done_actions), 1, stack.done_actions)
         self.assertTrue(isinstance(stack.done_actions[0], ClipAdded))
-        self.assertTrue(isinstance(stack.done_actions[1], AssetAddedAction))
         self.assertTrue(clip1 in self.getTimelineClips())
 
         self.action_log.undo()
@@ -422,8 +417,14 @@ class TestLayerObserver(BaseTestUndoTimeline):
         with self.action_log.started("add second clip"):
             self.layer.add_clip(clip2)
 
+        # Make sure the transition asset is ignored.
+        stack, = self.action_log.undo_stacks
+        for action in stack.done_actions:
+            self.assertNotIsInstance(action, AssetAddedAction,
+                                     stack.done_actions)
+
         def get_transition_element(ges_layer):
-            for clip in self.layer.get_clips():
+            for clip in ges_layer.get_clips():
                 if isinstance(clip, GES.TransitionClip):
                     for element in clip.get_children(False):
                         if isinstance(element, GES.VideoTransition):


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