[pitivi] tests: check selection and selected when undo/redo takes place.



commit b5be87cc38e59c7266e015be7199739393d3ae4c
Author: AsociTon <asociton outlook com>
Date:   Mon Mar 16 14:47:56 2020 +0530

    tests: check selection and selected when undo/redo takes place.
    
    Add a method check_selection to keep a check on selected attribute
    of clips and selection.

 tests/test_undo_timeline.py | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 63cec187..bbc51580 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -114,13 +114,21 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
             with self.action_log.started("add clip {}".format(i)):
                 self.layer.add_clip(clip)
 
+    def check_selection(self, *expected_selected_clips):
+        self.assertSetEqual(set(self.timeline_container.timeline.selection), set(expected_selected_clips))
+        for clip in self.get_timeline_clips():
+            if clip in expected_selected_clips:
+                self.assertTrue(clip.selected.selected)
+            else:
+                self.assertFalse(clip.selected.selected)
+
     def test_redo_delete_when_selected(self):
         clip1, clip2, clip3 = self.get_timeline_clips()
 
         # Delete clip1.
         self.timeline_container.timeline.selection.select([clip1])
         self.timeline_container.delete_action.activate(None)
-        self.assertSetEqual(set(self.timeline_container.timeline.selection), set())
+        self.check_selection()
 
         # Undo clip1 deletion.
         self.action_log.undo()
@@ -128,7 +136,7 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
         # Redo clip1 deletion when selected.
         self.timeline_container.timeline.selection.select([clip1, clip2, clip3])
         self.action_log.redo()
-        self.assertSetEqual(set(self.timeline_container.timeline.selection), set())
+        self.check_selection()
 
     def test_redo_delete_when_unselected(self):
         clip1, clip2, clip3 = self.get_timeline_clips()
@@ -136,7 +144,7 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
         # Delete clip1.
         self.timeline_container.timeline.selection.select([clip1])
         self.timeline_container.delete_action.activate(None)
-        self.assertSetEqual(set(self.timeline_container.timeline.selection), set())
+        self.check_selection()
 
         # Undo clip1 deletion.
         self.action_log.undo()
@@ -144,7 +152,7 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
         # Redo clip1 deletion when unselected.
         self.timeline_container.timeline.selection.select([clip2, clip3])
         self.action_log.redo()
-        self.assertEqual(set(self.timeline_container.timeline.selection), {clip2, clip3})
+        self.check_selection(clip2, clip3)
 
     def test_undo_add_when_selected(self):
         clip1, clip2, clip3 = self.get_timeline_clips()
@@ -152,7 +160,7 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
         # Undo clip3 creation when selected.
         self.timeline_container.timeline.selection.select([clip1, clip2, clip3])
         self.action_log.undo()
-        self.assertSetEqual(set(self.timeline_container.timeline.selection), set())
+        self.check_selection()
 
     def test_undo_add_when_unselected(self):
         clip1, clip2, _ = self.get_timeline_clips()
@@ -160,7 +168,7 @@ class TestSelectionResetWhenRemovingClip(BaseTestUndoTimeline):
         # Undo clip3 creation when unselected.
         self.timeline_container.timeline.selection.select([clip1, clip2])
         self.action_log.undo()
-        self.assertSetEqual(set(self.timeline_container.timeline.selection), {clip1, clip2})
+        self.check_selection(clip1, clip2)
 
 
 class TestTimelineObserver(BaseTestUndoTimeline):


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