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
=== modified file 'openlp/core/ui/media/mediacontroller.py'
--- openlp/core/ui/media/mediacontroller.py 2015-01-18 13:39:21 +0000
+++ openlp/core/ui/media/mediacontroller.py 2015-02-21 13:32:10 +0000
@@ -517,6 +517,9 @@
517 used_players = get_media_players()[0]517 used_players = get_media_players()[0]
518 if service_item.processor != UiStrings().Automatic:518 if service_item.processor != UiStrings().Automatic:
519 used_players = [service_item.processor.lower()]519 used_players = [service_item.processor.lower()]
520 # If no player, we can't play
521 if not used_players:
522 return False
520 if controller.media_info.file_info.isFile():523 if controller.media_info.file_info.isFile():
521 suffix = '*.%s' % controller.media_info.file_info.suffix().lower()524 suffix = '*.%s' % controller.media_info.file_info.suffix().lower()
522 for title in used_players:525 for title in used_players:
523526
=== modified file 'openlp/plugins/alerts/lib/alertsmanager.py'
--- openlp/plugins/alerts/lib/alertsmanager.py 2015-01-18 13:39:21 +0000
+++ openlp/plugins/alerts/lib/alertsmanager.py 2015-02-21 13:32:10 +0000
@@ -26,7 +26,7 @@
2626
27from PyQt4 import QtCore27from PyQt4 import QtCore
2828
29from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, translate29from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, Settings, translate
3030
3131
32class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties):32class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties):
@@ -70,7 +70,8 @@
70 """70 """
71 Format and request the Alert and start the timer.71 Format and request the Alert and start the timer.
72 """72 """
73 if not self.alert_list:73 if not self.alert_list or (self.live_controller.display.screens.display_count == 1
74 and not Settings().value('core/display on monitor')):
74 return75 return
75 text = self.alert_list.pop(0)76 text = self.alert_list.pop(0)
76 alert_tab = self.parent().settings_tab77 alert_tab = self.parent().settings_tab
7778
=== modified file 'tests/functional/openlp_core_ui_media/test_mediacontroller.py'
--- tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_ui_media/test_mediacontroller.py 2015-02-21 13:32:10 +0000
@@ -28,7 +28,7 @@
28from openlp.core.ui.media.mediaplayer import MediaPlayer28from openlp.core.ui.media.mediaplayer import MediaPlayer
29from openlp.core.common import Registry29from openlp.core.common import Registry
3030
31from tests.functional import MagicMock31from tests.functional import MagicMock, patch
32from tests.helpers.testmixin import TestMixin32from tests.helpers.testmixin import TestMixin
3333
3434
@@ -58,3 +58,26 @@
58 'Video extensions should be the same')58 'Video extensions should be the same')
59 self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,59 self.assertListEqual(media_player.audio_extensions_list, media_controller.audio_extensions_list,
60 'Audio extensions should be the same')60 'Audio extensions should be the same')
61
62 def check_file_type_no_players_test(self):
63 """
64 Test that we don't try to play media when no players available
65 """
66 # GIVEN: A mocked UiStrings, get_media_players, controller, display and service_item
67 with patch('openlp.core.ui.media.mediacontroller.get_media_players') as mocked_get_media_players,\
68 patch('openlp.core.ui.media.mediacontroller.UiStrings') as mocked_uistrings:
69 mocked_get_media_players.return_value = ([], '')
70 mocked_ret_uistrings = MagicMock()
71 mocked_ret_uistrings.Automatic = 1
72 mocked_uistrings.return_value = mocked_ret_uistrings
73 media_controller = MediaController()
74 mocked_controller = MagicMock()
75 mocked_display = MagicMock()
76 mocked_service_item = MagicMock()
77 mocked_service_item.processor = 1
78
79 # WHEN: calling _check_file_type when no players exists
80 ret = media_controller._check_file_type(mocked_controller, mocked_display, mocked_service_item)
81
82 # THEN: it should return False
83 self.assertFalse(ret, '_check_file_type should return False when no mediaplayers are available.')