forked from openlp/openlp
- fixed presentation file mask
bzr-revno: 2279
This commit is contained in:
commit
53d5cda91a
@ -59,7 +59,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.controllers = controllers
|
||||
self.icon_path = u'presentations/presentation'
|
||||
self.Automatic = u''
|
||||
MediaManagerItem.__init__(self, parent, plugin)
|
||||
super(PresentationMediaItem, self).__init__(parent, plugin)
|
||||
self.message_listener = MessageListener(self)
|
||||
self.has_search = True
|
||||
self.single_service_item = False
|
||||
@ -80,15 +80,15 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
"""
|
||||
Build the list of file extensions to be used in the Open file dialog.
|
||||
"""
|
||||
file_type_list = u''
|
||||
file_type_string = u''
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled():
|
||||
file_types = self.controllers[controller].supports + self.controllers[controller].also_supports
|
||||
for file_type in file_types:
|
||||
if file_type.find(file_type) == -1:
|
||||
file_type_list += u'*.%s ' % file_type
|
||||
if file_type not in file_type_string:
|
||||
file_type_string += u'*.%s ' % file_type
|
||||
self.service_manager.supported_suffixes(file_type)
|
||||
self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % file_type_list
|
||||
self.on_new_file_masks = translate('PresentationPlugin.MediaItem', 'Presentations (%s)') % file_type_string
|
||||
|
||||
def required_icons(self):
|
||||
"""
|
||||
|
@ -0,0 +1,71 @@
|
||||
"""
|
||||
This module contains tests for the lib submodule of the Presentations plugin.
|
||||
"""
|
||||
import os
|
||||
from tempfile import mkstemp
|
||||
from unittest import TestCase
|
||||
|
||||
from mock import patch, MagicMock
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import Registry
|
||||
|
||||
from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
|
||||
|
||||
|
||||
class TestMediaItem(TestCase):
|
||||
"""
|
||||
Test the mediaitem methods.
|
||||
"""
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the components need for all tests.
|
||||
"""
|
||||
Registry.create()
|
||||
Registry().register(u'service_manager', MagicMock())
|
||||
Registry().register(u'main_window', MagicMock())
|
||||
|
||||
with patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.__init__') as mocked_init:
|
||||
mocked_init.return_value = None
|
||||
self.media_item = PresentationMediaItem(MagicMock(), MagicMock, MagicMock(), MagicMock())
|
||||
|
||||
self.application = QtGui.QApplication.instance()
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Delete all the C++ objects at the end so that we don't have a segfault
|
||||
"""
|
||||
del self.application
|
||||
|
||||
def build_file_mask_string_test(self):
|
||||
"""
|
||||
Test the build_file_mask_string() method
|
||||
"""
|
||||
# GIVEN: Different controllers.
|
||||
impress_controller = MagicMock()
|
||||
impress_controller.enabled.return_value = True
|
||||
impress_controller.supports = [u'odp']
|
||||
impress_controller.also_supports = [u'ppt']
|
||||
presentation_controller = MagicMock()
|
||||
presentation_controller.enabled.return_value = True
|
||||
presentation_controller.supports = [u'ppt']
|
||||
presentation_controller.also_supports = []
|
||||
presentation_viewer_controller = MagicMock()
|
||||
presentation_viewer_controller.enabled.return_value = False
|
||||
# Mock the controllers.
|
||||
self.media_item.controllers = {
|
||||
u'Impress': impress_controller,
|
||||
u'Powerpoint': presentation_controller,
|
||||
u'Powerpoint Viewer': presentation_viewer_controller
|
||||
}
|
||||
|
||||
# WHEN: Build the file mask.
|
||||
with patch('openlp.plugins.presentations.lib.mediaitem.translate') as mocked_translate:
|
||||
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
|
||||
self.media_item.build_file_mask_string()
|
||||
|
||||
# THEN: The file mask should be generated.
|
||||
assert self.media_item.on_new_file_masks == u'Presentations (*.odp *.ppt )', \
|
||||
u'The file mask should contain the odp and ppt extensions'
|
||||
|
@ -80,9 +80,7 @@ class TestEditCustomForm(TestCase):
|
||||
# GIVEN: Mocked methods.
|
||||
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
|
||||
mocked_critical_error_message_box:
|
||||
mocked_displayText = MagicMock()
|
||||
mocked_displayText.return_value = u''
|
||||
self.form.title_edit.displayText = mocked_displayText
|
||||
self.form.title_edit.displayText = MagicMock(return_value=u'')
|
||||
mocked_setFocus = MagicMock()
|
||||
self.form.title_edit.setFocus = mocked_setFocus
|
||||
|
||||
@ -101,12 +99,8 @@ class TestEditCustomForm(TestCase):
|
||||
# GIVEN: Mocked methods.
|
||||
with patch(u'openlp.plugins.custom.forms.editcustomform.critical_error_message_box') as \
|
||||
mocked_critical_error_message_box:
|
||||
mocked_displayText = MagicMock()
|
||||
mocked_displayText.return_value = u'something'
|
||||
self.form.title_edit.displayText = mocked_displayText
|
||||
mocked_count = MagicMock()
|
||||
mocked_count.return_value = 0
|
||||
self.form.slide_list_view.count = mocked_count
|
||||
self.form.title_edit.displayText = MagicMock(return_value=u'something')
|
||||
self.form.slide_list_view.count = MagicMock(return_value=0)
|
||||
|
||||
# WHEN: Call the method.
|
||||
result = self.form._validate()
|
||||
|
Loading…
Reference in New Issue
Block a user