summaryrefslogtreecommitdiff
path: root/tests/check
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>2016-01-12 14:51:55 +0000
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-11-17 07:52:02 -0300
commitd4184da6e3198f2aceaae7f8238084f26108f485 (patch)
treee29b8253485f810baa026fecf53860baab134790 /tests/check
parent85a7fd0782e10fbd0872d7a1cf949c56978f55c0 (diff)
timeline: reimplement snap_to_position a bit more appropriately.
It could yet be made be simpler, but it would require touching the rest of the timeline editing code. Fixes https://phabricator.freedesktop.org/T7587 Reviewed-by: Thibault Saunier <thibault.saunier@collabora.com> Differential Revision: https://phabricator.freedesktop.org/D657
Diffstat (limited to 'tests/check')
-rw-r--r--tests/check/ges/timelineedition.c11
-rw-r--r--tests/check/python/test_clip.py2
-rw-r--r--tests/check/python/test_timeline.py31
3 files changed, 31 insertions, 13 deletions
diff --git a/tests/check/ges/timelineedition.c b/tests/check/ges/timelineedition.c
index 68d0e211..c827afca 100644
--- a/tests/check/ges/timelineedition.c
+++ b/tests/check/ges/timelineedition.c
@@ -393,9 +393,8 @@ GST_START_TEST (test_snapping)
* time 26-------- 62 --------122
*/
ges_timeline_element_set_start (GES_TIMELINE_ELEMENT (clip1), 26);
- ges_timeline_element_set_duration (GES_TIMELINE_ELEMENT (clip1), 37);
CHECK_OBJECT_PROPS (trackelement, 25, 0, 37);
- CHECK_OBJECT_PROPS (trackelement1, 26, 5, 36);
+ CHECK_OBJECT_PROPS (trackelement1, 26, 5, 37);
CHECK_OBJECT_PROPS (trackelement2, 62, 0, 60);
/**
@@ -409,7 +408,7 @@ GST_START_TEST (test_snapping)
fail_unless (ges_timeline_element_ripple (GES_TIMELINE_ELEMENT (clip1),
58) == TRUE);
CHECK_OBJECT_PROPS (trackelement, 25, 0, 37);
- CHECK_OBJECT_PROPS (trackelement1, 62, 5, 36);
+ CHECK_OBJECT_PROPS (trackelement1, 62, 5, 37);
CHECK_OBJECT_PROPS (trackelement2, 98, 0, 60);
/**
@@ -419,7 +418,7 @@ GST_START_TEST (test_snapping)
*/
ges_timeline_element_set_start (GES_TIMELINE_ELEMENT (clip2), 110);
CHECK_OBJECT_PROPS (trackelement, 25, 0, 37);
- CHECK_OBJECT_PROPS (trackelement1, 62, 5, 36);
+ CHECK_OBJECT_PROPS (trackelement1, 62, 5, 37);
CHECK_OBJECT_PROPS (trackelement2, 110, 0, 60);
/**
@@ -430,7 +429,7 @@ GST_START_TEST (test_snapping)
fail_unless (ges_container_edit (clip1, NULL, -1, GES_EDIT_MODE_NORMAL,
GES_EDGE_NONE, 72) == TRUE);
CHECK_OBJECT_PROPS (trackelement, 25, 0, 37);
- CHECK_OBJECT_PROPS (trackelement1, 73, 5, 36);
+ CHECK_OBJECT_PROPS (trackelement1, 73, 5, 37);
CHECK_OBJECT_PROPS (trackelement2, 110, 0, 60);
/**
@@ -441,7 +440,7 @@ GST_START_TEST (test_snapping)
fail_unless (ges_container_edit (clip1, NULL, -1, GES_EDIT_MODE_NORMAL,
GES_EDGE_NONE, 58) == TRUE);
CHECK_OBJECT_PROPS (trackelement, 25, 0, 37);
- CHECK_OBJECT_PROPS (trackelement1, 62, 5, 36);
+ CHECK_OBJECT_PROPS (trackelement1, 62, 5, 37);
CHECK_OBJECT_PROPS (trackelement2, 110, 0, 60);
diff --git a/tests/check/python/test_clip.py b/tests/check/python/test_clip.py
index 6df4f265..7f6929a2 100644
--- a/tests/check/python/test_clip.py
+++ b/tests/check/python/test_clip.py
@@ -25,8 +25,6 @@ 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
diff --git a/tests/check/python/test_timeline.py b/tests/check/python/test_timeline.py
index 68bc5a3d..d83cdae9 100644
--- a/tests/check/python/test_timeline.py
+++ b/tests/check/python/test_timeline.py
@@ -27,7 +27,9 @@ from gi.repository import GES # noqa
import unittest # noqa
from unittest import mock
-from . import common
+from .common import create_main_loop
+from .common import create_project
+from .common import GESSimpleTimelineTest # noqa
Gst.init(None)
GES.init()
@@ -36,8 +38,8 @@ GES.init()
class TestTimeline(unittest.TestCase):
def test_signals_not_emitted_when_loading(self):
- mainloop = common.create_main_loop()
- timeline = common.create_project(with_group=True, saved=True)
+ mainloop = create_main_loop()
+ timeline = create_project(with_group=True, saved=True)
# Reload the project, check the group.
project = GES.Project.new(uri=timeline.get_asset().props.uri)
@@ -52,7 +54,6 @@ class TestTimeline(unittest.TestCase):
timeline = project.extract()
signals = ["layer-added", "group-added", "track-added"]
- called = []
handle = mock.Mock()
for signal in signals:
timeline.connect(signal, handle)
@@ -62,7 +63,7 @@ class TestTimeline(unittest.TestCase):
handle.assert_not_called()
-class TestEditing(common.GESSimpleTimelineTest):
+class TestEditing(GESSimpleTimelineTest):
def test_transition_disappears_when_moving_to_another_layer(self):
self.timeline.props.auto_transition = True
@@ -112,3 +113,23 @@ class TestEditing(common.GESSimpleTimelineTest):
self.assertEquals(len(self.layer.get_clips()), 4)
clip1.edit([], self.layer.get_priority(), GES.EditMode.EDIT_RIPPLE, GES.Edge.EDGE_NONE, 35 * Gst.SECOND)
self.assertEquals(len(self.layer.get_clips()), 4)
+
+
+class TestSnapping(GESSimpleTimelineTest):
+
+ def test_snapping(self):
+ self.timeline.props.auto_transition = True
+ self.timeline.set_snapping_distance(1)
+ clip1 = self.add_clip(0, 0, 100)
+
+ # Split clip1.
+ split_position = 50
+ clip2 = clip1.split(split_position)
+ self.assertEquals(len(self.layer.get_clips()), 2)
+ self.assertEqual(clip1.props.duration, split_position)
+ self.assertEqual(clip2.props.start, split_position)
+
+ # Make sure snapping prevents clip2 to be moved to the left.
+ clip2.edit([], self.layer.get_priority(), GES.EditMode.EDIT_NORMAL, GES.Edge.EDGE_NONE,
+ clip2.props.start - 1)
+ self.assertEqual(clip2.props.start, split_position)