Merge lp:~trb143/openlp/themecombo-24 into lp:openlp/2.4

Proposed by Tim Bentley
Status: Merged
Merged at revision: 2649
Proposed branch: lp:~trb143/openlp/themecombo-24
Merge into: lp:openlp/2.4
Diff against target: 66 lines (+40/-1)
2 files modified
openlp/core/ui/servicemanager.py (+1/-1)
tests/functional/openlp_core_ui/test_servicemanager.py (+39/-0)
To merge this branch: bzr merge lp:~trb143/openlp/themecombo-24
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+302865@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Personally, I prefer multiple tests for each state (you can use setUp to do the common stuff necessary), as opposed to multiple scenarios within the same test, but this works.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2016-07-19 20:56:31 +0000
+++ openlp/core/ui/servicemanager.py 2016-08-13 04:56:47 +0000
@@ -1321,7 +1321,7 @@
1321 """1321 """
1322 The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.1322 The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
1323 """1323 """
1324 visible = self.renderer.theme_level == ThemeLevel.Global1324 visible = self.renderer.theme_level != ThemeLevel.Global
1325 self.toolbar.actions['theme_combo_box'].setVisible(visible)1325 self.toolbar.actions['theme_combo_box'].setVisible(visible)
1326 self.toolbar.actions['theme_label'].setVisible(visible)1326 self.toolbar.actions['theme_label'].setVisible(visible)
1327 self.regenerate_service_items()1327 self.regenerate_service_items()
13281328
=== modified file 'tests/functional/openlp_core_ui/test_servicemanager.py'
--- tests/functional/openlp_core_ui/test_servicemanager.py 2016-07-19 20:56:31 +0000
+++ tests/functional/openlp_core_ui/test_servicemanager.py 2016-08-13 04:56:47 +0000
@@ -27,6 +27,7 @@
2727
28from openlp.core.common import Registry, ThemeLevel28from openlp.core.common import Registry, ThemeLevel
29from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities29from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
30from openlp.core.lib.toolbar import OpenLPToolbar
30from openlp.core.ui import ServiceManager31from openlp.core.ui import ServiceManager
3132
32from tests.functional import MagicMock, patch33from tests.functional import MagicMock, patch
@@ -592,3 +593,41 @@
592 # THEN: The "save_as" method is called to save the service593 # THEN: The "save_as" method is called to save the service
593 self.assertTrue(result)594 self.assertTrue(result)
594 mocked_save_file_as.assert_called_with()595 mocked_save_file_as.assert_called_with()
596
597 @patch(u'openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
598 def test_theme_change(self, mocked_regenerate_service_items):
599 """
600 Test that when a Toolbar theme combobox displays correctly
601 """
602 # GIVEN: A service manager, a service to save with a theme level of the renderer
603 mocked_renderer = MagicMock()
604 service_manager = ServiceManager(None)
605 Registry().register('renderer', mocked_renderer)
606 service_manager.toolbar = OpenLPToolbar(None)
607
608 service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
609 service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
610
611 # WHEN: The service manager has a Global theme
612 mocked_renderer.theme_level = ThemeLevel.Global
613 result = service_manager.theme_change()
614
615 # THEN: The the theme toolbar should not be visible
616 self.assertFalse(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
617 'The visibility should be False')
618
619 # WHEN: The service manager has a Service theme
620 mocked_renderer.theme_level = ThemeLevel.Service
621 result = service_manager.theme_change()
622
623 # THEN: The the theme toolbar should not be visible
624 self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
625 'The visibility should be True')
626
627 # WHEN: The service manager has a Song theme
628 mocked_renderer.theme_level = ThemeLevel.Song
629 result = service_manager.theme_change()
630
631 # THEN: The the theme toolbar should not be visible
632 self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
633 'The visibility should be true')

Subscribers

People subscribed via source and target branches

to all changes: