[pitivi/1.0] tests: Add a test for EditingContext.with_video
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/1.0] tests: Add a test for EditingContext.with_video
- Date: Wed, 13 Jun 2018 14:40:39 +0000 (UTC)
commit a48ee895f3dfb135f2d162b9b8547ed892009dc8
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Wed Jun 13 01:34:18 2018 +0200
tests: Add a test for EditingContext.with_video
tests/common.py | 8 ++++++++
tests/test_utils_timeline.py | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
---
diff --git a/tests/common.py b/tests/common.py
index 4cb0a91e..4a98d03c 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -28,6 +28,7 @@ import unittest
from unittest import mock
from gi.repository import Gdk
+from gi.repository import GES
from gi.repository import GLib
from gi.repository import Gst
from gi.repository import Gtk
@@ -285,6 +286,13 @@ def get_sample_uri(sample, samples_dir=None):
return Gst.filename_to_uri(os.path.join(samples_dir, sample))
+def get_sample_clip(sample):
+ uri = get_sample_uri(sample)
+ asset = GES.UriClipAsset.request_sync(uri)
+ clip = asset.extract()
+ return clip
+
+
@contextlib.contextmanager
def cloned_sample(*samples):
"""Gets a context manager which commits the transaction at the end."""
diff --git a/tests/test_utils_timeline.py b/tests/test_utils_timeline.py
index 88897d58..9d3a9288 100644
--- a/tests/test_utils_timeline.py
+++ b/tests/test_utils_timeline.py
@@ -20,6 +20,7 @@ from unittest import mock
from gi.repository import GES
+from pitivi.utils.timeline import EditingContext
from pitivi.utils.timeline import SELECT
from pitivi.utils.timeline import SELECT_ADD
from pitivi.utils.timeline import Selected
@@ -96,3 +97,45 @@ class TestSelection(common.TestCase):
selection.setSelection([], SELECT)
self.assertFalse(selection.can_group)
self.assertFalse(selection.can_ungroup)
+
+
+class TestEditingContext(common.TestCase):
+ """Tests for the EditingContext class."""
+
+ def test_with_video(self):
+ """Checks the value of the with_video field."""
+ audio_clip = common.get_sample_clip("mp3_sample.mp3")
+ video_clip = common.get_sample_clip("one_fps_numeroted_blue.mkv")
+ audio_video_clip = common.get_sample_clip("tears_of_steel.webm")
+
+ # Add the clips to a layer so they have TrackElements.
+ project = common.create_project()
+ layer = project.ges_timeline.append_layer()
+ layer.add_clip(audio_clip)
+ layer.add_clip(video_clip)
+ layer.add_clip(audio_video_clip)
+
+ self.__check_with_video(audio_clip, False)
+ self.__check_with_video(video_clip, True)
+ self.__check_with_video(audio_video_clip, True)
+
+ # Check the track elements of a clip with audio only.
+ audio_track_element = audio_clip.find_track_element(None, GES.AudioSource)
+ self.__check_with_video(audio_track_element, False)
+
+ # Check the track elements of a clip with video only.
+ video_track_element = video_clip.find_track_element(None, GES.VideoSource)
+ self.__check_with_video(video_track_element, True)
+
+ # Check the track elements of a clip with both audio and video.
+ audio_track_element = audio_video_clip.find_track_element(None, GES.AudioSource)
+ video_track_element = audio_video_clip.find_track_element(None, GES.VideoSource)
+ self.__check_with_video(audio_track_element, True)
+ self.__check_with_video(video_track_element, True)
+
+ def __check_with_video(self, clip, expected):
+ context = EditingContext(clip, None, None, None, None, None)
+ if expected:
+ self.assertTrue(context.with_video)
+ else:
+ self.assertFalse(context.with_video)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]