forked from openlp/openlp
Merge branch 'fix-presentations-on-linux' into 'master'
Fix presentations on Linux (and hopefully Windows too) Closes #269 See merge request openlp/openlp!75
This commit is contained in:
commit
bf7b091db0
@ -152,7 +152,7 @@ class ImpressController(PresentationController):
|
||||
self.toggle_presentation_screen(False)
|
||||
return desktop
|
||||
except Exception:
|
||||
log.warning('Failed to get UNO desktop')
|
||||
log.exception('Failed to get UNO desktop')
|
||||
return None
|
||||
|
||||
def get_com_desktop(self):
|
||||
@ -232,7 +232,7 @@ class ImpressController(PresentationController):
|
||||
self.conf_provider = self.manager.createInstanceWithContext(
|
||||
'com.sun.star.configuration.ConfigurationProvider', uno.getComponentContext())
|
||||
# Setup lookup properties to get Impress settings
|
||||
properties = tuple(self.create_property('nodepath', 'org.openoffice.Office.Impress'))
|
||||
properties = (self.create_property('nodepath', 'org.openoffice.Office.Impress'),)
|
||||
try:
|
||||
# Get an updateable configuration view
|
||||
impress_conf_props = self.conf_provider.createInstanceWithArguments(
|
||||
@ -308,7 +308,7 @@ class ImpressDocument(PresentationDocument):
|
||||
if desktop is None:
|
||||
return False
|
||||
self.desktop = desktop
|
||||
properties = tuple(self.controller.create_property('Hidden', True))
|
||||
properties = (self.controller.create_property('Hidden', True),)
|
||||
try:
|
||||
self.document = desktop.loadComponentFromURL(url, '_blank', 0, properties)
|
||||
except Exception:
|
||||
@ -333,7 +333,7 @@ class ImpressDocument(PresentationDocument):
|
||||
return
|
||||
temp_folder_path = self.get_temp_folder()
|
||||
thumb_dir_url = temp_folder_path.as_uri()
|
||||
properties = tuple(self.controller.create_property('FilterName', 'impress_png_Export'))
|
||||
properties = (self.controller.create_property('FilterName', 'impress_png_Export'),)
|
||||
doc = self.document
|
||||
pages = doc.getDrawPages()
|
||||
if not pages:
|
||||
|
@ -144,7 +144,7 @@ class OpenOfficeImport(SongImport):
|
||||
"""
|
||||
self.file_path = file_path
|
||||
url = file_path.as_uri()
|
||||
properties = tuple(self.create_property('Hidden', True))
|
||||
properties = (self.create_property('Hidden', True),)
|
||||
try:
|
||||
self.document = self.desktop.loadComponentFromURL(url, '_blank', 0, properties)
|
||||
if not self.document.supportsService("com.sun.star.presentation.PresentationDocument") and not \
|
||||
|
@ -24,7 +24,7 @@ Functional tests to test the Impress class and related methods.
|
||||
import shutil
|
||||
from tempfile import mkdtemp
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
from openlp.core.common.settings import Settings
|
||||
from openlp.plugins.presentations.lib.impresscontroller import ImpressController, ImpressDocument, TextType
|
||||
@ -86,7 +86,7 @@ class TestImpressController(TestCase, TestMixin):
|
||||
assert result is False
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
|
||||
def test_check_available1(self, mocked_log):
|
||||
def test_check_available_on_windows(self, mocked_log):
|
||||
"""
|
||||
Test `ImpressController.check_available` on Windows
|
||||
"""
|
||||
@ -106,7 +106,7 @@ class TestImpressController(TestCase, TestMixin):
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.log')
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=False)
|
||||
def test_check_available2(self, mocked_is_win, mocked_log):
|
||||
def test_check_available_on_linux(self, mocked_is_win, mocked_log):
|
||||
"""
|
||||
Test `ImpressController.check_available` when not on Windows
|
||||
"""
|
||||
@ -122,6 +122,44 @@ class TestImpressController(TestCase, TestMixin):
|
||||
assert mocked_get_com_servicemanager.called is False
|
||||
assert result is True
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True)
|
||||
def test_start_process_on_windows(self, mocked_is_win):
|
||||
"""
|
||||
Test that start_process() on Windows starts the process
|
||||
"""
|
||||
# GIVEN: An ImpressController object
|
||||
controller = ImpressController(plugin=self.mock_plugin)
|
||||
controller.get_com_servicemanager = MagicMock(return_value=MagicMock())
|
||||
|
||||
# WHEN: start_process() is called
|
||||
controller.start_process()
|
||||
|
||||
# THEN: The correct methods should have been called
|
||||
controller.get_com_servicemanager.assert_called_once()
|
||||
assert controller.manager._FlagAsMethod.call_args_list == [call('Bridge_GetStruct'),
|
||||
call('Bridge_GetValueObject')]
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=False)
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.get_uno_command', return_value='libreoffice')
|
||||
@patch('openlp.plugins.presentations.lib.impresscontroller.QtCore.QProcess')
|
||||
def test_start_process_on_linux(self, MockQProcess, mocked_get_uno_command, mocked_is_win):
|
||||
"""
|
||||
Test that start_process() on Linux starts the process
|
||||
"""
|
||||
# GIVEN: An ImpressController object
|
||||
mocked_process = MagicMock()
|
||||
MockQProcess.return_value = mocked_process
|
||||
controller = ImpressController(plugin=self.mock_plugin)
|
||||
|
||||
# WHEN: start_process() is called
|
||||
controller.start_process()
|
||||
|
||||
# THEN: The correct methods should have been called
|
||||
mocked_get_uno_command.assert_called_once()
|
||||
MockQProcess.assert_called_once()
|
||||
assert controller.process is mocked_process
|
||||
mocked_process.startDetached.assert_called_once_with('libreoffice')
|
||||
|
||||
|
||||
class TestImpressDocument(TestCase):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user