[pitivi] tests: Check dragging clip on a separator
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] tests: Check dragging clip on a separator
- Date: Sun, 12 Jun 2016 23:45:48 +0000 (UTC)
commit 6fec493353a9ef6dc82e33ef728bb1d91f91b438
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Jun 2 03:16:00 2016 +0200
tests: Check dragging clip on a separator
Differential Revision: https://phabricator.freedesktop.org/D1055
pitivi/timeline/timeline.py | 9 ++++---
tests/test_undo_timeline.py | 49 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 6a751e0..3bb7a32 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -965,7 +965,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
return GES.EditMode.EDIT_TRIM
return GES.EditMode.EDIT_NORMAL
- def __layerGetSeps(self, ges_layer, sep_name):
+ def _get_separators(self, ges_layer, sep_name):
return [getattr(ges_layer.ui, sep_name), getattr(ges_layer.control_ui, sep_name)]
def _get_layer_at(self, y, prefer_ges_layer=None, past_middle_when_adjacent=False):
@@ -975,7 +975,8 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
# The cursor is at the top, above the first layer.
self.debug("Returning very first layer")
ges_layer = ges_layers[0]
- return ges_layer, self.__layerGetSeps(ges_layer, "before_sep")
+ separators = self._get_separators(ges_layer, "before_sep")
+ return ges_layer, separators
# This means if an asset is dragged directly on a separator,
# it will prefer the layer below the separator, if any.
@@ -1003,7 +1004,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
return prefer_ges_layer, []
return ges_layer, []
- separators = self.__layerGetSeps(ges_layer, "after_sep")
+ separators = self._get_separators(ges_layer, "after_sep")
try:
next_ges_layer = ges_layers[i + 1]
except IndexError:
@@ -1017,7 +1018,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
if layer_y + layer_height <= y < next_ges_layer.ui.get_allocation().y:
# The cursor is between this layer and the one below.
- separators.extend(self.__layerGetSeps(next_ges_layer, "before_sep"))
+ separators.extend(self._get_separators(next_ges_layer, "before_sep"))
if prefer_after:
ges_layer = next_ges_layer
self.debug("Returning layer %s, separators: %s", ges_layer, separators)
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 52bbb20..08864ae 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -20,6 +20,7 @@
from unittest import mock
from unittest import TestCase
+from gi.repository import Gdk
from gi.repository import GES
from gi.repository import Gst
from gi.repository import GstController
@@ -270,6 +271,54 @@ class TestTimelineUndo(TestCase):
self.action_log.redo()
self.assertTrue(clip1 in self.getTimelineClips())
+ def test_clip_dragged_to_create_layer(self):
+ layers = self.timeline.get_layers()
+ self.assertEqual(len(layers), 1)
+
+ clip = GES.TitleClip()
+ self.layer.add_clip(clip)
+
+ timeline_ui = Timeline(None, self.app)
+ timeline_ui.setProject(self.app.project_manager.current_project)
+ timeline_ui.get_parent = mock.MagicMock()
+
+ # Drag a clip on a separator to create a layer.
+ timeline_ui.get_event_widget = mock.Mock(return_value=clip.ui)
+ event = mock.Mock()
+ event.x = 0
+ event.get_button.return_value = True, 1
+ timeline_ui._button_press_event_cb(None, event)
+
+ def translate_coordinates(widget, x, y):
+ return x, y
+ clip.ui.translate_coordinates = translate_coordinates
+ event.get_state.return_value = Gdk.ModifierType.BUTTON1_MASK
+ event.x = 1
+ event.y = LAYER_HEIGHT * 2
+ timeline_ui._motion_notify_event_cb(None, event)
+
+ timeline_ui._button_release_event_cb(None, event)
+
+ layers = self.timeline.get_layers()
+ self.assertEqual(len(layers), 2)
+ self.assertEqual(layers[0], self.layer)
+ self.assertEqual(layers[0].get_clips(), [])
+ self.assertEqual(layers[1].get_clips(), [clip])
+
+ self.action_log.undo()
+ layers = self.timeline.get_layers()
+ self.assertEqual(len(layers), 1)
+ layers = self.timeline.get_layers()
+ self.assertEqual(layers[0], self.layer)
+ self.assertEqual(layers[0].get_clips(), [clip])
+
+ self.action_log.redo()
+ layers = self.timeline.get_layers()
+ self.assertEqual(len(layers), 2)
+ self.assertEqual(layers[0], self.layer)
+ self.assertEqual(layers[0].get_clips(), [])
+ self.assertEqual(layers[1].get_clips(), [clip])
+
def testTrackElementPropertyChanged(self):
clip1 = GES.TitleClip()
self.layer.add_clip(clip1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]