diff options
author | Thibault Saunier <tsaunier@gnome.org> | 2016-08-13 21:09:53 -0400 |
---|---|---|
committer | Thibault Saunier <thibault.saunier@osg.samsung.com> | 2016-09-26 13:33:25 -0300 |
commit | 3a0598120e54e09a027e4757fe5543ea4836eedc (patch) | |
tree | d67289dc75e374a476773b24d65e4b7e46ef424f | |
parent | b80e006caf61826ee26b3a90b158a928dad2cadd (diff) |
tests_:python: Factor out common code
Differential Revision: https://phabricator.freedesktop.org/D1328
-rw-r--r-- | tests/check/python/__init__.py | 0 | ||||
-rw-r--r-- | tests/check/python/common.py | 66 | ||||
-rw-r--r-- | tests/check/python/test_clip.py | 5 | ||||
-rw-r--r-- | tests/check/python/test_group.py | 13 | ||||
-rw-r--r-- | tests/check/python/test_timeline.py | 2 |
5 files changed, 73 insertions, 13 deletions
diff --git a/tests/check/python/__init__.py b/tests/check/python/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/check/python/__init__.py diff --git a/tests/check/python/common.py b/tests/check/python/common.py index e0e9d702..23d81e99 100644 --- a/tests/check/python/common.py +++ b/tests/check/python/common.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (c) 2016 Alexandru Băluț <alexandru.balut@gmail.com> +# Copyright (c) 2016, Thibault Saunier # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,9 +18,19 @@ # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301, USA. -from gi.repository import GES -from gi.repository import GLib -import tempfile +import gi + +gi.require_version("Gst", "1.0") +gi.require_version("GES", "1.0") + +from gi.repository import Gst # noqa +from gi.repository import GES # noqa +from gi.repository import GLib # noqa +import unittest # noqa +import tempfile # noqa + +Gst.init(None) +GES.init() def create_main_loop(): @@ -67,3 +78,52 @@ def create_project(with_group=False, saved=False): return timeline +class GESTest(unittest.TestCase): + def _log(self, func, format, *args): + string = format + if args: + string = string % args[0] + func(string) + + def log(self, format, *args): + self._log(Gst.log, format, *args) + + def debug(self, format, *args): + self._log(Gst.debug, format, *args) + + def info(self, format, *args): + self._log(Gst.info, format, *args) + + def fixme(self, format, *args): + self._log(Gst.fixme, format, *args) + + def warning(self, format, *args): + self._log(Gst.warning, format, *args) + + def error(self, format, *args): + self._log(Gst.error, format, *args) + + +class GESSimpleTimelineTest(GESTest): + def setUp(self): + self.timeline = GES.Timeline.new_audio_video() + self.assertEqual(len(self.timeline.get_tracks()), 2) + self.layer = self.timeline.append_layer() + + def add_clip(self, start, in_point, duration): + clip = GES.TestClip() + clip.props.start = start + clip.props.in_point = in_point + clip.props.duration = duration + self.layer.add_clip(clip) + + return clip + + def check_clip_values(self, clip, start, in_point, duration): + for elem in [clip] + clip.get_children(False): + self.check_element_values(elem, start, in_point, duration) + + def check_element_values(self, element, start, in_point, duration): + self.assertEqual(element.props.start, start, element) + self.assertEqual(element.props.in_point, in_point, element) + self.assertEqual(element.props.duration, duration, element) diff --git a/tests/check/python/test_clip.py b/tests/check/python/test_clip.py index 83c7a8dc..6df4f265 100644 --- a/tests/check/python/test_clip.py +++ b/tests/check/python/test_clip.py @@ -24,8 +24,13 @@ gi.require_version("GES", "1.0") from gi.repository import Gst # noqa from gi.repository import GES # noqa + +from .common import GESSimpleTimelineTest # noqa + import unittest # noqa + + Gst.init(None) GES.init() diff --git a/tests/check/python/test_group.py b/tests/check/python/test_group.py index ef2d3a97..1d220b0c 100644 --- a/tests/check/python/test_group.py +++ b/tests/check/python/test_group.py @@ -24,22 +24,17 @@ gi.require_version("GES", "1.0") from gi.repository import Gst # noqa from gi.repository import GES # noqa + +from . import common # noqa + import unittest # noqa from unittest import mock -import common - Gst.init(None) GES.init() -class TestGroup(unittest.TestCase): - - def setUp(self): - self.timeline = GES.Timeline.new_audio_video() - self.assertEqual(len(self.timeline.get_tracks()), 2) - self.layer = self.timeline.append_layer() - +class TestGroup(common.GESSimpleTimelineTest): def testCopyGroup(self): clip1 = GES.TestClip.new() clip1.props.duration = 10 diff --git a/tests/check/python/test_timeline.py b/tests/check/python/test_timeline.py index 9aad8d60..ba3f0f5a 100644 --- a/tests/check/python/test_timeline.py +++ b/tests/check/python/test_timeline.py @@ -27,7 +27,7 @@ from gi.repository import GES # noqa import unittest # noqa from unittest import mock -import common +from . import common Gst.init(None) GES.init() |