forked from openlp/openlp
Fix bug and test it
This commit is contained in:
parent
585321376d
commit
a7dd65245a
@ -1321,7 +1321,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
"""
|
||||
The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
|
||||
"""
|
||||
visible = 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()
|
||||
|
@ -27,6 +27,7 @@ from unittest import TestCase
|
||||
|
||||
from openlp.core.common import Registry, ThemeLevel
|
||||
from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
|
||||
from openlp.core.lib.toolbar import OpenLPToolbar
|
||||
from openlp.core.ui import ServiceManager
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
@ -592,3 +593,41 @@ class TestServiceManager(TestCase):
|
||||
# THEN: The "save_as" method is called to save the service
|
||||
self.assertTrue(result)
|
||||
mocked_save_file_as.assert_called_with()
|
||||
|
||||
@patch(u'openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
|
||||
def test_theme_change(self, mocked_regenerate_service_items):
|
||||
"""
|
||||
Test that when a Toolbar theme combobox displays correctly
|
||||
"""
|
||||
# GIVEN: A service manager, a service to save with a theme level of the renderer
|
||||
mocked_renderer = MagicMock()
|
||||
service_manager = ServiceManager(None)
|
||||
Registry().register('renderer', mocked_renderer)
|
||||
service_manager.toolbar = OpenLPToolbar(None)
|
||||
|
||||
service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
|
||||
service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
|
||||
|
||||
# WHEN: The service manager has a Global theme
|
||||
mocked_renderer.theme_level = ThemeLevel.Global
|
||||
result = service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should not be visible
|
||||
self.assertFalse(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be False')
|
||||
|
||||
# WHEN: The service manager has a Service theme
|
||||
mocked_renderer.theme_level = ThemeLevel.Service
|
||||
result = service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should not be visible
|
||||
self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be True')
|
||||
|
||||
# WHEN: The service manager has a Song theme
|
||||
mocked_renderer.theme_level = ThemeLevel.Song
|
||||
result = service_manager.theme_change()
|
||||
|
||||
# THEN: The the theme toolbar should not be visible
|
||||
self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
|
||||
'The visibility should be true')
|
||||
|
Loading…
Reference in New Issue
Block a user