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

Fixes: https://launchpad.net/bugs/1419300
This commit is contained in:
Raoul Snyman 2015-03-07 00:18:51 +02:00
parent 9d2db2416c
commit 54c23cc7bd
5 changed files with 104 additions and 17 deletions

View File

@ -345,7 +345,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties):
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 @@ s
"""
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):

View File

@ -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')

View File

@ -36,12 +36,7 @@ class TestListPreviewWidget(TestCase):
"""
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):
"""

View File

@ -33,9 +33,6 @@ from tests.helpers.testmixin import TestMixin
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)

View File

@ -39,12 +39,6 @@ class TestServiceManager(TestCase):
"""
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.