forked from openlp/openlp
Make the fix for bug 1473632 work on more linux distros.
Make sure presentations is closed correctly. Fixes bug 1490996. Test included. Fix crash with VLC on windows with unicode chars in filename. Fixes bug 1491998. bzr-revno: 2553 Fixes: https://launchpad.net/bugs/1473632, https://launchpad.net/bugs/1490996, https://launchpad.net/bugs/1491998
This commit is contained in:
commit
c9c1826977
2
openlp/core/ui/media/vendor/vlc.py
vendored
2
openlp/core/ui/media/vendor/vlc.py
vendored
@ -60,7 +60,7 @@ if sys.version_info[0] > 2:
|
||||
"""Translate string or bytes to bytes.
|
||||
"""
|
||||
if isinstance(s, str):
|
||||
return bytes(s, sys.getfilesystemencoding())
|
||||
return s.encode()
|
||||
else:
|
||||
return s
|
||||
|
||||
|
@ -104,6 +104,10 @@ def get_vlc():
|
||||
if is_linux() and 'nose' not in sys.argv[0] and get_vlc():
|
||||
import ctypes
|
||||
try:
|
||||
try:
|
||||
x11 = ctypes.cdll.LoadLibrary('libX11.so.6')
|
||||
except OSError:
|
||||
# If libx11.so.6 was not found, fallback to more generic libx11.so
|
||||
x11 = ctypes.cdll.LoadLibrary('libX11.so')
|
||||
x11.XInitThreads()
|
||||
except:
|
||||
|
@ -902,7 +902,8 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
# This avoids the service theme/desktop flashing on screen
|
||||
# However opening a new item of the same type will automatically
|
||||
# close the previous, so make sure we don't close the new one.
|
||||
if old_item.is_command() and not service_item.is_command():
|
||||
if old_item.is_command() and not service_item.is_command() or \
|
||||
old_item.is_command() and not old_item.is_media() and service_item.is_media():
|
||||
Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
|
||||
if old_item.is_media() and not service_item.is_media():
|
||||
self.on_media_close()
|
||||
|
@ -640,6 +640,51 @@ class TestSlideController(TestCase):
|
||||
mocked_preview_widget.change_slide.assert_called_once_with(7)
|
||||
mocked_slide_selected.assert_called_once_with()
|
||||
|
||||
@patch.object(Registry, 'execute')
|
||||
def process_item_test(self, mocked_execute):
|
||||
"""
|
||||
Test that presentation service-items is closed when followed by a media service-item
|
||||
"""
|
||||
# GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
|
||||
# and a slide controller with many mocks.
|
||||
mocked_pres_item = MagicMock()
|
||||
mocked_pres_item.name = 'mocked_presentation_item'
|
||||
mocked_pres_item.is_command.return_value = True
|
||||
mocked_pres_item.is_media.return_value = False
|
||||
mocked_pres_item.is_image.return_value = False
|
||||
mocked_pres_item.from_service = False
|
||||
mocked_pres_item.get_frames.return_value = []
|
||||
mocked_media_item = MagicMock()
|
||||
mocked_media_item.name = 'mocked_media_item'
|
||||
mocked_media_item.is_command.return_value = True
|
||||
mocked_media_item.is_media.return_value = True
|
||||
mocked_media_item.is_image.return_value = False
|
||||
mocked_media_item.from_service = False
|
||||
mocked_media_item.get_frames.return_value = []
|
||||
Registry.create()
|
||||
mocked_main_window = MagicMock()
|
||||
Registry().register('main_window', mocked_main_window)
|
||||
slide_controller = SlideController(None)
|
||||
slide_controller.service_item = mocked_pres_item
|
||||
slide_controller.is_live = False
|
||||
slide_controller.preview_widget = MagicMock()
|
||||
slide_controller.enable_tool_bar = MagicMock()
|
||||
slide_controller.on_media_start = MagicMock()
|
||||
slide_controller.slide_selected = MagicMock()
|
||||
slide_controller.on_stop_loop = MagicMock()
|
||||
slide_controller.info_label = MagicMock()
|
||||
slide_controller.display = MagicMock()
|
||||
slide_controller.split = 0
|
||||
slide_controller.type_prefix = 'test'
|
||||
|
||||
# WHEN: _process_item is called
|
||||
slide_controller._process_item(mocked_media_item, 0)
|
||||
|
||||
# THEN: Registry.execute should have been called to stop the presentation
|
||||
self.assertEqual(3, mocked_execute.call_count, 'Execute should have been called 3 times')
|
||||
self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0],
|
||||
'The presentation should have been stopped.')
|
||||
|
||||
|
||||
class TestInfoLabel(TestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user