[pitivi] test_clipproperties.py: Added unit tests for alignment editor.
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] test_clipproperties.py: Added unit tests for alignment editor.
- Date: Sun, 10 May 2020 19:32:19 +0000 (UTC)
commit 9c20b41eb5076834e05d3d3f41bbf08b64fca291
Author: Jackson Eickhoff <jacksoneick gmail com>
Date: Sat May 9 14:44:39 2020 -0500
test_clipproperties.py: Added unit tests for alignment editor.
Previously, there was no regression testing set up for the alignment editor.
To fix this, a test was made and placed in the ClipPropertiesTest class. This tests aligning a clip, and
undoing an action as well as re-doing the action.
Related to issue https://gitlab.gnome.org/GNOME/pitivi/issues/2279
pitivi/clipproperties.py | 6 ++---
tests/test_clipproperties.py | 54 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 56 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index f493b7f0..3c65ce1a 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -87,9 +87,9 @@ class ClipProperties(Gtk.ScrolledWindow, Loggable):
self.clips_box.show()
vbox.pack_start(self.clips_box, False, False, 0)
- transformation_expander = TransformationProperties(app)
- transformation_expander.set_vexpand(False)
- vbox.pack_start(transformation_expander, False, False, 0)
+ self.transformation_expander = TransformationProperties(app)
+ self.transformation_expander.set_vexpand(False)
+ vbox.pack_start(self.transformation_expander, False, False, 0)
self.title_expander = TitleProperties(app)
self.title_expander.set_vexpand(False)
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index 472b6885..f62c92e5 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -328,7 +328,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
self.assertEqual(value, source.ui.default_position[prop])
-class ClipPropertiesTest(BaseTestUndoTimeline):
+class ClipPropertiesTest(BaseTestUndoTimeline, BaseTestTimeline):
"""Tests for the TitleProperties class."""
def _get_title_source_child_props(self):
@@ -367,3 +367,55 @@ class ClipPropertiesTest(BaseTestUndoTimeline):
self.action_log.redo()
ps2 = self._get_title_source_child_props()
self.assertListEqual(ps1, ps2)
+
+ def test_alignment_editor(self):
+ """Exercise aligning a clip using the alignment editor."""
+ # Wait until the project creates a layer in the timeline.
+ common.create_main_loop().run(until_empty=True)
+
+ from pitivi.timeline.timeline import TimelineContainer
+ timeline_container = TimelineContainer(self.app)
+ timeline_container.set_project(self.project)
+ self.app.gui.editor.timeline_ui = timeline_container
+
+ clipproperties = ClipProperties(self.app)
+ clipproperties.new_project_loaded_cb(None, self.project)
+ self.project.pipeline.get_position = mock.Mock(return_value=0)
+
+ transformation_box = TransformationProperties(self.app)
+ transformation_box._new_project_loaded_cb(self.app, self.project)
+
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
+ clip = self.add_clips_simple(timeline, 1)[0]
+ timeline.selection.select([clip])
+ source = transformation_box.source
+ self.assertIsNotNone(source)
+
+ x = source.get_child_property("posx").value
+ y = source.get_child_property("posy").value
+
+ self.assertEqual(x, 0)
+ self.assertEqual(x, 0)
+
+ alignment_editor = transformation_box.alignment_editor
+ alignment_editor._hovered_box = [0, 0]
+ alignment_editor._button_release_event_cb(alignment_editor, None)
+
+ x = source.get_child_property("posx").value
+ y = source.get_child_property("posy").value
+ self.assertEqual(x, -source.get_child_property("width").value)
+ self.assertEqual(y, -source.get_child_property("height").value)
+
+ self.action_log.undo()
+
+ x = source.get_child_property("posx").value
+ y = source.get_child_property("posy").value
+ self.assertEqual(x, 0)
+ self.assertEqual(y, 0)
+
+ self.action_log.redo()
+
+ x = source.get_child_property("posx").value
+ y = source.get_child_property("posy").value
+ self.assertEqual(x, -source.get_child_property("width").value)
+ self.assertEqual(y, -source.get_child_property("height").value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]