[pitivi] tests: Add unittests for Selected and Selection
- From: Mathieu Duponchelle <mathieudu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] tests: Add unittests for Selected and Selection
- Date: Fri, 28 Feb 2014 03:13:35 +0000 (UTC)
commit 637506bbff1130e8a1a74c7057343b169f057ec1
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Mon Feb 17 12:38:34 2014 +0100
tests: Add unittests for Selected and Selection
pitivi/timeline/elements.py | 15 ++++++-----
pitivi/utils/timeline.py | 1 -
tests/Makefile.am | 1 +
tests/test_preset.py | 2 +-
tests/test_utils_timeline.py | 51 ++++++++++++++++++++++++++++++++++++++++++
tests/test_widgets.py | 2 +-
6 files changed, 62 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 77b291e..38de53c 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -1029,13 +1029,14 @@ class URISourceElement(TimelineElement):
def _clickedCb(self, unused_action, unused_actor):
#TODO : Let's be more specific, masks etc ..
mode = SELECT
- if self.timeline._container._controlMask and not self.bElement.selected:
- mode = SELECT_ADD
- self.timeline.current_group.add(self.bElement.get_toplevel_parent())
- elif self.timeline._container._controlMask:
- self.timeline.current_group.remove(self.bElement.get_toplevel_parent())
- mode = UNSELECT
- elif not self.bElement.selected.selected:
+ if self.timeline._container._controlMask:
+ if not self.bElement.selected:
+ mode = SELECT_ADD
+ self.timeline.current_group.add(self.bElement.get_toplevel_parent())
+ else:
+ self.timeline.current_group.remove(self.bElement.get_toplevel_parent())
+ mode = UNSELECT
+ elif not self.bElement.selected:
GES.Container.ungroup(self.timeline.current_group, False)
self.timeline.current_group = GES.Group()
self.timeline.current_group.add(self.bElement.get_toplevel_parent())
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index a5d6f93..316f497 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -76,7 +76,6 @@ class Selected(Signallable):
def __init__(self):
self._selected = False
- self.movable = True
def __nonzero__(self):
"""
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef94386..69a1cfb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,6 +19,7 @@ tests = \
test_timeline_undo.py \
test_undo.py \
test_utils.py \
+ test_utils_timeline.py \
test_widgets.py
# Keep the list sorted!
diff --git a/tests/test_preset.py b/tests/test_preset.py
index 7a52cbb..29f9eb7 100644
--- a/tests/test_preset.py
+++ b/tests/test_preset.py
@@ -3,7 +3,7 @@
#
# tests/test_preset.py
#
-# Copyright (c) 2011, Alex Balut <alexandru balut gmail com>
+# Copyright (c) 2011, Alex Băluț <alexandru balut gmail com>
# Copyright (c) 2011, Jean-François Fortin Tam <nekohayo gmail com>
#
# This program is free software; you can redistribute it and/or
diff --git a/tests/test_utils_timeline.py b/tests/test_utils_timeline.py
new file mode 100644
index 0000000..b9657eb
--- /dev/null
+++ b/tests/test_utils_timeline.py
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2013, Alex Băluț <alexandru balut gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+import mock
+from unittest import TestCase
+
+from pitivi.utils.timeline import Selected, Selection, SELECT, SELECT_ADD, \
+ UNSELECT
+
+
+class TestSelected(TestCase):
+
+ def testBoolEvaluation(self):
+ selected = Selected()
+ self.assertFalse(selected)
+
+ selected.selected = True
+ self.assertTrue(selected)
+
+ selected.selected = False
+ self.assertFalse(selected)
+
+
+class TestSelection(TestCase):
+
+ def testBoolEvaluation(self):
+ clip1 = mock.MagicMock()
+ selection = Selection()
+ self.assertFalse(selection)
+ selection.setSelection([clip1], SELECT)
+ self.assertTrue(selection)
+ selection.setSelection([clip1], SELECT_ADD)
+ self.assertTrue(selection)
+ selection.setSelection([clip1], UNSELECT)
+ self.assertFalse(selection)
diff --git a/tests/test_widgets.py b/tests/test_widgets.py
index cd3c062..3e36c8b 100644
--- a/tests/test_widgets.py
+++ b/tests/test_widgets.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (c) 2013, Alexandru Băluț <alexandru balut gmail com>
+# Copyright (c) 2013, Alex Băluț <alexandru balut gmail com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]