Commit 1b5f3cef authored by Alexandru Băluț's avatar Alexandru Băluț

tests: Add a test for EditingContext.with_video

parent 01877372
Pipeline #15611 passed with stage
in 44 minutes and 1 second
......@@ -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
def cloned_sample(*samples):
"""Gets a context manager which commits the transaction at the end."""
......@@ -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)
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()
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:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment