diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 2bb00b34c..76b2ec376 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -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() diff --git a/tests/functional/openlp_core_ui/test_servicemanager.py b/tests/functional/openlp_core_ui/test_servicemanager.py index 897b02fe9..0bb8017fb 100644 --- a/tests/functional/openlp_core_ui/test_servicemanager.py +++ b/tests/functional/openlp_core_ui/test_servicemanager.py @@ -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')