[pitivi] tests: Check title clip creation
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] tests: Check title clip creation
- Date: Fri, 5 Jul 2019 01:05:24 +0000 (UTC)
commit c1a94d28b1a56a16c68bfe9c6a6718adbc339ecf
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Jul 5 02:46:44 2019 +0200
tests: Check title clip creation
pitivi/titleeditor.py | 2 +-
tests/common.py | 6 +++---
tests/test_clipproperties.py | 14 ++++++-------
tests/test_titleeditor.py | 50 ++++++++++++++++++++++++++++++++++++++++++++
tests/test_undo_timeline.py | 2 +-
5 files changed, 62 insertions(+), 12 deletions(-)
---
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 4696e96f..dadbf0d2 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -307,7 +307,7 @@ class TitleEditor(Loggable):
self._project.pipeline.commit_timeline()
- def _newProjectLoadedCb(self, app, project):
+ def _newProjectLoadedCb(self, unused_project_manager, project):
if self._selection is not None:
self._selection.disconnect_by_func(self._selectionChangedCb)
self._selection = None
diff --git a/tests/common.py b/tests/common.py
index a1b58cce..9bbfb1fa 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -119,8 +119,8 @@ def create_pitivi(**settings):
return app
-def create_timeline_container():
- app = create_pitivi_mock(leftClickAlsoSeeks=False)
+def create_timeline_container(**settings):
+ app = create_pitivi_mock(leftClickAlsoSeeks=False, **settings)
app.project_manager = ProjectManager(app)
project = app.project_manager.new_blank_project()
@@ -130,7 +130,7 @@ def create_timeline_container():
timeline = timeline_container.timeline
timeline.get_parent = mock.MagicMock(return_value=timeline_container)
- app.gui.timeline_ui = timeline_container
+ app.gui.editor.timeline_ui = timeline_container
return timeline_container
diff --git a/tests/test_clipproperties.py b/tests/test_clipproperties.py
index 9e665163..03b683a2 100644
--- a/tests/test_clipproperties.py
+++ b/tests/test_clipproperties.py
@@ -85,7 +85,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks the spin buttons update when the source properties change."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
spin_buttons = transformation_box.spin_buttons
# Add a clip and select it
@@ -114,7 +114,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks the spin buttons changing updates the source properties."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
spin_buttons = transformation_box.spin_buttons
# Add a clip and select it
@@ -148,7 +148,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks the spin buttons update when the selected clip changes."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
spin_buttons = transformation_box.spin_buttons
# Add two clips and select the first one
@@ -181,7 +181,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks transformation properties keyframes activation."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
# Add a clip and select it
clip = self.addClipsSimple(timeline, 1)[0]
@@ -216,7 +216,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks keyframe creation."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
pipeline = timeline._project.pipeline
spin_buttons = transformation_box.spin_buttons
@@ -249,7 +249,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks keyframe navigation."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
pipeline = timeline._project.pipeline
# Add a clip and select it
@@ -298,7 +298,7 @@ class TransformationPropertiesTest(BaseTestTimeline):
"""Checks "reset to default" button."""
# Create transformation box
transformation_box = self.setup_transformation_box()
- timeline = transformation_box.app.gui.timeline_ui.timeline
+ timeline = transformation_box.app.gui.editor.timeline_ui.timeline
# Add a clip and select it
clip = self.addClipsSimple(timeline, 1)[0]
diff --git a/tests/test_titleeditor.py b/tests/test_titleeditor.py
new file mode 100644
index 00000000..05afdd87
--- /dev/null
+++ b/tests/test_titleeditor.py
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+# Pitivi video editor
+# Copyright (c) 2019, Alex Băluț <alexandru balut gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+"""Tests for the titleeditor module."""
+# pylint: disable=protected-access
+from unittest import mock
+
+from gi.repository import GES
+
+from pitivi.titleeditor import TitleEditor
+from tests import common
+
+
+class TitleEditorTest(common.TestCase):
+ """Tests for the TitleEditor class."""
+
+ def test_create(self):
+ """Exercise creating a title clip."""
+ timeline_container = common.create_timeline_container(titleClipLength=1)
+ project = timeline_container._project
+ app = timeline_container.app
+
+ # Wait until the project creates a layer in the timeline.
+ common.create_main_loop().run(until_empty=True)
+
+ title_editor = TitleEditor(app)
+ title_editor._newProjectLoadedCb(None, project)
+ project.pipeline.getPosition = mock.Mock(return_value=0)
+
+ title_editor._createCb(None)
+ layers = timeline_container.ges_timeline.get_layers()
+ self.assertEqual(len(layers), 1, layers)
+ clips = layers[0].get_clips()
+ self.assertEqual(len(clips), 1, clips)
+ self.assertIsInstance(clips[0], GES.TitleClip)
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index a695bcda..2c2fe4bf 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -936,7 +936,7 @@ class TestGObjectObserver(BaseTestUndoTimeline):
self.action_log.connect("commit", BaseTestUndoTimeline.commit_cb, stacks)
# We are not dropping clips here...
- self.app.gui.timeline_ui.timeline.dropping_clips = False
+ self.app.gui.editor.timeline_ui.timeline.dropping_clips = False
clip1 = GES.TitleClip()
clip1.set_start(5 * Gst.SECOND)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]