Merge lp:~tomasgroth/openlp/bugfixes15 into lp:openlp

Proposed by Tomas Groth
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2509
Merged at revision: 2510
Proposed branch: lp:~tomasgroth/openlp/bugfixes15
Merge into: lp:openlp
Diff against target: 76 lines (+30/-3)
3 files modified
openlp/core/ui/media/mediacontroller.py (+3/-0)
openlp/plugins/alerts/lib/alertsmanager.py (+3/-2)
tests/functional/openlp_core_ui_media/test_mediacontroller.py (+24/-1)
To merge this branch: bzr merge lp:~tomasgroth/openlp/bugfixes15
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+250532@code.launchpad.net

This proposal supersedes a proposal from 2015-02-21.

Description of the change

Don't try to play media if no players are available. Fixes bug 1422761.
Do not display alert on a single screen when 'Display on a single screen' is not checked. Fixes bug 1423956.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Tomas Groth (tomasgroth) wrote :
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/media/mediacontroller.py'
2--- openlp/core/ui/media/mediacontroller.py 2015-01-18 13:39:21 +0000
3+++ openlp/core/ui/media/mediacontroller.py 2015-02-21 13:32:10 +0000
4@@ -517,6 +517,9 @@
5 used_players = get_media_players()[0]
6 if service_item.processor != UiStrings().Automatic:
7 used_players = [service_item.processor.lower()]
8+ # If no player, we can't play
9+ if not used_players:
10+ return False
11 if controller.media_info.file_info.isFile():
12 suffix = '*.%s' % controller.media_info.file_info.suffix().lower()
13 for title in used_players:
14
15=== modified file 'openlp/plugins/alerts/lib/alertsmanager.py'
16--- openlp/plugins/alerts/lib/alertsmanager.py 2015-01-18 13:39:21 +0000
17+++ openlp/plugins/alerts/lib/alertsmanager.py 2015-02-21 13:32:10 +0000
18@@ -26,7 +26,7 @@
19
20 from PyQt4 import QtCore
21
22-from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, translate
23+from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, Settings, translate
24
25
26 class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties):
27@@ -70,7 +70,8 @@
28 """
29 Format and request the Alert and start the timer.
30 """
31- if not self.alert_list:
32+ if not self.alert_list or (self.live_controller.display.screens.display_count == 1
33+ and not Settings().value('core/display on monitor')):
34 return
35 text = self.alert_list.pop(0)
36 alert_tab = self.parent().settings_tab
37
38=== modified file 'tests/functional/openlp_core_ui_media/test_mediacontroller.py'
39--- tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-01-18 13:39:21 +0000
40+++ tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-02-21 13:32:10 +0000
41@@ -28,7 +28,7 @@
42 from openlp.core.ui.media.mediaplayer import MediaPlayer
43 from openlp.core.common import Registry
44
45-from tests.functional import MagicMock
46+from tests.functional import MagicMock, patch
47 from tests.helpers.testmixin import TestMixin
48
49
50@@ -58,3 +58,26 @@
51 'Video extensions should be the same')
52 self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
53 'Audio extensions should be the same')
54+
55+ def check_file_type_no_players_test(self):
56+ """
57+ Test that we don't try to play media when no players available
58+ """
59+ # GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
60+ with patch('openlp.core.ui.media.mediacontroller.get_media_players') as mocked_get_media_players,\
61+ patch('openlp.core.ui.media.mediacontroller.UiStrings') as mocked_uistrings:
62+ mocked_get_media_players.return_value = ([], '')
63+ mocked_ret_uistrings = MagicMock()
64+ mocked_ret_uistrings.Automatic = 1
65+ mocked_uistrings.return_value = mocked_ret_uistrings
66+ media_controller = MediaController()
67+ mocked_controller = MagicMock()
68+ mocked_display = MagicMock()
69+ mocked_service_item = MagicMock()
70+ mocked_service_item.processor = 1
71+
72+ # WHEN: calling _check_file_type when no players exists
73+ ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
74+
75+ # THEN: it should return False
76+ self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.')