forked from openlp/openlp
Fix more tests
This commit is contained in:
parent
6b4ed77fee
commit
927b68dc95
@ -446,6 +446,14 @@ class Renderer(RegistryBase, LogMixin, RegistryProperties, DisplayWindow):
|
||||
self.theme_height = 0
|
||||
self.theme_level = ThemeLevel.Global
|
||||
|
||||
def set_theme_level(self, theme_level):
|
||||
"""
|
||||
Sets the theme level.
|
||||
|
||||
:param theme_level: The theme level to be used.
|
||||
"""
|
||||
self.theme_level = theme_level
|
||||
|
||||
def calculate_line_count(self):
|
||||
"""
|
||||
Calculate the number of lines that fits on one slide
|
||||
|
@ -421,7 +421,6 @@ class ServiceItem(RegistryProperties):
|
||||
if other.theme is not None:
|
||||
self.theme = other.theme
|
||||
self._new_item()
|
||||
self.render()
|
||||
if self.is_capable(ItemCapabilities.HasBackgroundAudio):
|
||||
log.debug(self.background_audio)
|
||||
|
||||
@ -576,7 +575,6 @@ class ServiceItem(RegistryProperties):
|
||||
self.theme_overwritten = (theme is None)
|
||||
self.theme = theme
|
||||
self._new_item()
|
||||
self.render()
|
||||
|
||||
def remove_invalid_frames(self, invalid_paths=None):
|
||||
"""
|
||||
|
@ -1259,7 +1259,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
|
||||
"""
|
||||
The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
|
||||
"""
|
||||
visible = True # self.renderer.theme_level != ThemeLevel.Global
|
||||
visible = self.renderer.theme_level != ThemeLevel.Global
|
||||
self.toolbar.actions['theme_combo_box'].setVisible(visible)
|
||||
self.toolbar.actions['theme_label'].setVisible(visible)
|
||||
self.regenerate_service_items()
|
||||
|
@ -160,7 +160,7 @@ class ThemesTab(SettingsTab):
|
||||
settings.setValue('global theme', self.global_theme)
|
||||
settings.setValue('wrap footer', self.wrap_footer_check_box.isChecked())
|
||||
settings.endGroup()
|
||||
# self.renderer.set_theme_level(self.theme_level)
|
||||
self.renderer.set_theme_level(self.theme_level)
|
||||
if self.tab_visited:
|
||||
self.settings_form.register_post_process('theme_update_global')
|
||||
self.tab_visited = False
|
||||
@ -205,7 +205,7 @@ class ThemesTab(SettingsTab):
|
||||
self.default_combo_box.addItems(theme_list)
|
||||
find_and_set_in_combo_box(self.default_combo_box, self.global_theme)
|
||||
# self.renderer.set_global_theme()
|
||||
# self.renderer.set_theme_level(self.theme_level)
|
||||
self.renderer.set_theme_level(self.theme_level)
|
||||
if self.global_theme is not '':
|
||||
self._preview_global_theme()
|
||||
|
||||
|
@ -68,9 +68,14 @@ class TestController(TestCase):
|
||||
MagicMock(**{'geometry.return_value': SCREEN['size']})
|
||||
]
|
||||
self.screens = ScreenList.create(self.desktop)
|
||||
renderer = Renderer()
|
||||
renderer.empty_height = 1000
|
||||
# Mock the renderer and its format_slide method
|
||||
self.mocked_renderer = MagicMock()
|
||||
def side_effect_return_arg(arg1, arg2):
|
||||
return [arg1]
|
||||
self.mocked_slide_formater = MagicMock(side_effect=side_effect_return_arg)
|
||||
self.mocked_renderer.format_slide = self.mocked_slide_formater
|
||||
Registry().register('live_controller', self.mocked_live_controller)
|
||||
Registry().register('renderer', self.mocked_renderer)
|
||||
|
||||
def test_controller_text_empty(self):
|
||||
"""
|
||||
@ -101,7 +106,7 @@ class TestController(TestCase):
|
||||
State().update_pre_conditions("media", True)
|
||||
State().flush_preconditions()
|
||||
self.mocked_live_controller.service_item.set_from_service(line)
|
||||
self.mocked_live_controller.service_item.render(True)
|
||||
self.mocked_live_controller.service_item._create_slides()
|
||||
# WHEN: I trigger the method
|
||||
ret = controller_text("SomeText")
|
||||
|
||||
|
@ -77,11 +77,16 @@ class TestServiceItem(TestCase, TestMixin):
|
||||
self.build_settings()
|
||||
Settings().extend_default_settings(__default_settings__)
|
||||
Registry.create()
|
||||
# Mock the renderer and its format_slide method
|
||||
mocked_renderer = MagicMock()
|
||||
mocked_renderer.format_slide.return_value = [VERSE]
|
||||
def side_effect_return_arg(arg1, arg2):
|
||||
return [arg1]
|
||||
mocked_slide_formater = MagicMock(side_effect=side_effect_return_arg)
|
||||
mocked_renderer.format_slide = mocked_slide_formater
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
Registry().register('image_manager', MagicMock())
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Clean up
|
||||
@ -124,10 +129,8 @@ class TestServiceItem(TestCase, TestMixin):
|
||||
|
||||
# THEN: The frames should also be valid
|
||||
assert 'Test Custom' == service_item.get_display_title(), 'The title should be "Test Custom"'
|
||||
assert CLEANED_VERSE[:-1] == service_item.get_frames()[0]['text'], \
|
||||
'The returned text matches the input, except the last line feed'
|
||||
assert RENDERED_VERSE.split('\n', 1)[0] == service_item.get_rendered_frame(1), \
|
||||
'The first line has been returned'
|
||||
assert 'Slide 1' == service_item.get_frames()[0]['text']
|
||||
assert 'Slide 2' == service_item.get_rendered_frame(1)
|
||||
assert 'Slide 1' == service_item.get_frame_title(0), '"Slide 1" has been returned as the title'
|
||||
assert 'Slide 2' == service_item.get_frame_title(1), '"Slide 2" has been returned as the title'
|
||||
assert '' == service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3'
|
||||
|
@ -165,11 +165,8 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
|
||||
# THEN: the following registry functions should have been registered
|
||||
expected_service_list = ['application', 'main_window', 'http_server', 'settings_form', 'service_manager',
|
||||
'theme_manager', 'projection_manager']
|
||||
expected_functions_list = ['bootstrap_initialise', 'bootstrap_post_set_up', 'playbackPlay', 'playbackPause',
|
||||
'playbackStop', 'playbackLoop', 'seek_slider', 'volume_slider', 'media_hide',
|
||||
'media_blank', 'media_unblank', 'songs_hide', 'songs_blank', 'songs_unblank',
|
||||
'mediaitem_media_rebuild', 'mediaitem_suffixes', 'images_regenerate',
|
||||
'theme_manager', 'projector_manager']
|
||||
expected_functions_list = ['bootstrap_initialise', 'bootstrap_post_set_up', 'bootstrap_completion',
|
||||
'theme_update_global', 'config_screen_changed']
|
||||
assert list(self.registry.service_list.keys()) == expected_service_list, \
|
||||
'The service list should have been {}'.format(self.registry.service_list.keys())
|
||||
|
Loading…
Reference in New Issue
Block a user