[pitivi] timeline: Fix undo split clip



commit 6743d1d0a613d09dd5fdbc76bf3f1c51207212c4
Author: Fabián Orccón <Fabian Orccon>
Date:   Tue Jan 5 18:48:13 2016 -0500

    timeline: Fix undo split clip
    
    Differential Revision: https://phabricator.freedesktop.org/D621

 pitivi/timeline/timeline.py |    2 ++
 tests/test_undo_timeline.py |   27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 3a64146..8946cf9 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1631,7 +1631,9 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         If clips are selected, split them at the current playhead position.
         Otherwise, split all clips at the playhead position.
         """
+        self.app.action_log.begin("split clip")
         self._splitElements(self.timeline.selection.selected)
+        self.app.action_log.commit()
 
         self.timeline.hideSnapBar()
         self._project.pipeline.commit_timeline()
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index aa50489..900b601 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -343,3 +343,30 @@ class TestTimelineUndo(TestCase):
         self.assertEqual(1, len(timeline_clips))
         self.assertEqual(5 * Gst.SECOND, timeline_clips[0].get_start())
         self.assertEqual(0.5 * Gst.SECOND, timeline_clips[0].get_duration())
+
+    def testSplitClip(self):
+        clip = GES.TitleClip()
+        clip.set_start(0 * Gst.SECOND)
+        clip.set_duration(20 * Gst.SECOND)
+
+        self.layer.add_clip(clip)
+
+        self.action_log.begin("split clip")
+        clip1 = clip.split(10 * Gst.SECOND)
+        self.assertEqual(2, len(self.layer.get_clips()))
+        self.action_log.commit()
+
+        self.action_log.begin("split clip")
+        clip2 = clip1.split(15 * Gst.SECOND)
+        self.assertEqual(3, len(self.layer.get_clips()))
+        self.action_log.commit()
+
+        self.action_log.undo()
+        self.assertEqual(2, len(self.layer.get_clips()))
+        self.action_log.undo()
+        self.assertEqual(1, len(self.layer.get_clips()))
+
+        self.action_log.redo()
+        self.assertEqual(2, len(self.layer.get_clips()))
+        self.action_log.redo()
+        self.assertEqual(3, len(self.layer.get_clips()))


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