← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-1419300 into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-1419300 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1419300 in OpenLP: "OpenLP freezes when double clicking an image in media manager"
  https://bugs.launchpad.net/openlp/+bug/1419300

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-1419300/+merge/252180

Fix bug #1419300 by checking if we are doing single-click previewing and not engaging preview on double-click

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/bug-1419300 (revision 2520)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/989/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/912/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/854/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/743/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/342/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/479/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/350/
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-1419300 into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2015-01-30 21:15:03 +0000
+++ openlp/core/lib/mediamanageritem.py	2015-03-06 22:36:46 +0000
@@ -345,7 +345,7 @@
     def dnd_move_internal(self, target):
         """
         Handle internal moving of media manager items
-s
+
         :param target: The target of the DnD action
         """
         pass
@@ -460,7 +460,8 @@
         """
         if Settings().value('advanced/double click live'):
             self.on_live_click()
-        else:
+        elif not Settings().value('advanced/single click preview'):
+            # NOTE: The above check is necessary to prevent bug #1419300
             self.on_preview_click()
 
     def on_selection_change(self):

=== added file 'tests/functional/openlp_core_lib/test_mediamanageritem.py'
--- tests/functional/openlp_core_lib/test_mediamanageritem.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_lib/test_mediamanageritem.py	2015-03-06 22:36:46 +0000
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# 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 General Public License for    #
+# more details.                                                               #
+#                                                                             #
+# You should have received a copy of the GNU General Public License along     #
+# with this program; if not, write to the Free Software Foundation, Inc., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+"""
+Package to test the openlp.core.lib.mediamanageritem package.
+"""
+from unittest import TestCase
+
+from openlp.core.lib import MediaManagerItem
+
+from tests.functional import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
+
+
+class TestMediaManagerItem(TestCase, TestMixin):
+    """
+    Test the MediaManagerItem class
+    """
+    def setUp(self):
+        """
+        Mock out stuff for all the tests
+        """
+        self.setup_patcher = patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup')
+        self.mocked_setup = self.setup_patcher.start()
+        self.addCleanup(self.setup_patcher.stop)
+
+    @patch(u'openlp.core.lib.mediamanageritem.Settings')
+    @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
+    def on_double_clicked_test(self, mocked_on_preview_click, MockedSettings):
+        """
+        Test that when an item is double-clicked then the item is previewed
+        """
+        # GIVEN: A setting to enable "Double-click to go live" and a media manager item
+        mocked_settings = MagicMock()
+        mocked_settings.value.return_value = False
+        MockedSettings.return_value = mocked_settings
+        mmi = MediaManagerItem(None)
+
+        # WHEN: on_double_clicked() is called
+        mmi.on_double_clicked()
+
+        # THEN: on_preview_click() should have been called
+        mocked_on_preview_click.assert_called_with()
+
+    @patch(u'openlp.core.lib.mediamanageritem.Settings')
+    @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
+    def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings):
+        """
+        Test that when "Double-click to go live" is enabled that the item goes live
+        """
+        # GIVEN: A setting to enable "Double-click to go live" and a media manager item
+        mocked_settings = MagicMock()
+        mocked_settings.value.side_effect = lambda x: x == 'advanced/double click live'
+        MockedSettings.return_value = mocked_settings
+        mmi = MediaManagerItem(None)
+
+        # WHEN: on_double_clicked() is called
+        mmi.on_double_clicked()
+
+        # THEN: on_live_click() should have been called
+        mocked_on_live_click.assert_called_with()
+
+    @patch(u'openlp.core.lib.mediamanageritem.Settings')
+    @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
+    @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
+    def on_double_clicked_single_click_preview_test(self, mocked_on_preview_click, mocked_on_live_click,
+                                                    MockedSettings):
+        """
+        Test that when "Single-click preview" is enabled then nothing happens on double-click
+        """
+        # GIVEN: A setting to enable "Double-click to go live" and a media manager item
+        mocked_settings = MagicMock()
+        mocked_settings.value.side_effect = lambda x: x == 'advanced/single click preview'
+        MockedSettings.return_value = mocked_settings
+        mmi = MediaManagerItem(None)
+
+        # WHEN: on_double_clicked() is called
+        mmi.on_double_clicked()
+
+        # THEN: on_live_click() should have been called
+        self.assertEqual(0, mocked_on_live_click.call_count, u'on_live_click() should not have been called')
+        self.assertEqual(0, mocked_on_preview_click.call_count, u'on_preview_click() should not have been called')

=== modified file 'tests/functional/openlp_core_ui/test_listpreviewwidget.py'
--- tests/functional/openlp_core_ui/test_listpreviewwidget.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_ui/test_listpreviewwidget.py	2015-03-06 22:36:46 +0000
@@ -36,12 +36,7 @@
         """
         self.setup_patcher = patch('openlp.core.ui.listpreviewwidget.ListPreviewWidget._setup')
         self.mocked_setup = self.setup_patcher.start()
-
-    def tearDown(self):
-        """
-        Remove the mocks
-        """
-        self.setup_patcher.stop()
+        self.addCleanup(self.setup_patcher.stop)
 
     def new_list_preview_widget_test(self):
         """

=== modified file 'tests/functional/openlp_core_ui/test_media.py'
--- tests/functional/openlp_core_ui/test_media.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_ui/test_media.py	2015-03-06 22:36:46 +0000
@@ -33,9 +33,6 @@
 
 class TestMedia(TestCase, TestMixin):
 
-    def setUp(self):
-        pass
-
     def test_get_media_players_no_config(self):
         """
         Test that when there's no config, get_media_players() returns an empty list of players (not a string)

=== modified file 'tests/functional/openlp_core_ui/test_servicemanager.py'
--- tests/functional/openlp_core_ui/test_servicemanager.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_ui/test_servicemanager.py	2015-03-06 22:36:46 +0000
@@ -39,12 +39,6 @@
         """
         Registry.create()
 
-    def tearDown(self):
-        """
-        Delete all the C++ objects at the end so that we don't have a segfault
-        """
-        pass
-
     def initial_service_manager_test(self):
         """
         Test the initial of service manager.


Follow ups