Commit 02dce7ea authored by Alexandru Băluț's avatar Alexandru Băluț

tests: Make sure the zoom is the same

If a test changes the zoom level, it can affect other tests.

This was causing test_keyframe_toggle to fail:

$ nose2 tests.test_render.TestRender.test_rendering_with_youtube_profile tests.test_timeline_elements.TestKeyframeCurve.test_keyframe_toggle  -v
parent dc565531
......@@ -41,6 +41,7 @@ from pitivi.utils.misc import path_from_uri
from pitivi.utils.proxy import ProxyingStrategy
from pitivi.utils.proxy import ProxyManager
from pitivi.utils.timeline import Selected
from pitivi.utils.timeline import Zoomable
detect_leaks = os.environ.get("PITIVI_TEST_DETECT_LEAKS", "0") not in ("0", "")
os.environ["PITIVI_USER_CACHE_DIR"] = tempfile.mkdtemp(suffix="pitiviTestsuite")
......@@ -194,6 +195,8 @@ class TestCase(unittest.TestCase, Loggable):
if detect_leaks:
self.gctrack()
self.__zoom_level = Zoomable.getCurrentZoomLevel()
def tearDown(self):
# don't barf gc info all over the console if we have already failed a
# test case
......@@ -203,6 +206,7 @@ class TestCase(unittest.TestCase, Loggable):
if detect_leaks:
self.gccollect()
self.gcverify()
Zoomable.setZoomLevel(self.__zoom_level)
# override run() to save a reference to the test result object
def run(self, result=None):
......
......@@ -45,9 +45,9 @@ class TestKeyframeCurve(BaseTestTimeline):
timeline_container.app.action_log = UndoableActionLog()
timeline = timeline_container.timeline
ges_layer = timeline.ges_timeline.append_layer()
ges_clip1 = self.add_clip(ges_layer, 0, duration=2*Gst.SECOND)
ges_clip2 = self.add_clip(ges_layer, 10, duration=2*Gst.SECOND)
ges_clip3 = self.add_clip(ges_layer, 20, inpoint=100, duration=2*Gst.SECOND)
ges_clip1 = self.add_clip(ges_layer, 0, duration=2 * Gst.SECOND)
ges_clip2 = self.add_clip(ges_layer, 10, duration=2 * Gst.SECOND)
ges_clip3 = self.add_clip(ges_layer, 20, inpoint=100, duration=2 * Gst.SECOND)
# For variety, add TitleClip to the list of clips.
ges_clip4 = create_test_clip(GES.TitleClip)
ges_clip4.props.start = 30
......@@ -59,8 +59,10 @@ class TestKeyframeCurve(BaseTestTimeline):
self.check_keyframe_toggle(ges_clip3, timeline_container)
self.check_keyframe_toggle(ges_clip4, timeline_container)
for ges_clip in [ges_clip1, ges_clip2, ges_clip3, ges_clip4]:
self.check_keyframe_ui_toggle(ges_clip, timeline_container)
self.check_keyframe_ui_toggle(ges_clip1, timeline_container)
self.check_keyframe_ui_toggle(ges_clip2, timeline_container)
self.check_keyframe_ui_toggle(ges_clip3, timeline_container)
self.check_keyframe_ui_toggle(ges_clip4, timeline_container)
def check_keyframe_toggle(self, ges_clip, timeline_container):
"""Checks keyframes toggling on the specified clip."""
......@@ -119,6 +121,7 @@ class TestKeyframeCurve(BaseTestTimeline):
values = [item.timestamp for item in control_source.get_all()]
self.assertEqual(values, [inpoint, inpoint + duration])
# pylint: disable=too-many-statements
def check_keyframe_ui_toggle(self, ges_clip, timeline_container):
"""Checks keyframes toggling by click events."""
timeline = timeline_container.timeline
......@@ -153,7 +156,7 @@ class TestKeyframeCurve(BaseTestTimeline):
button=1
)
keyframe_curve.translate_coordinates = \
mock.Mock(return_value=(start_px+offset_px, None))
mock.Mock(return_value=(start_px + offset_px, None))
with mock.patch.object(Gtk, "get_event_widget") as get_event_widget:
get_event_widget.return_value = keyframe_curve
......
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