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
1=== modified file 'openlp/core/ui/servicemanager.py'
2--- openlp/core/ui/servicemanager.py 2016-07-19 20:56:31 +0000
3+++ openlp/core/ui/servicemanager.py 2016-08-13 04:56:47 +0000
4@@ -1321,7 +1321,7 @@
5 """
6 The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state.
7 """
8- visible = self.renderer.theme_level == ThemeLevel.Global
9+ visible = self.renderer.theme_level != ThemeLevel.Global
10 self.toolbar.actions['theme_combo_box'].setVisible(visible)
11 self.toolbar.actions['theme_label'].setVisible(visible)
12 self.regenerate_service_items()
13
14=== modified file 'tests/functional/openlp_core_ui/test_servicemanager.py'
15--- tests/functional/openlp_core_ui/test_servicemanager.py 2016-07-19 20:56:31 +0000
16+++ tests/functional/openlp_core_ui/test_servicemanager.py 2016-08-13 04:56:47 +0000
17@@ -27,6 +27,7 @@
18
19 from openlp.core.common import Registry, ThemeLevel
20 from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
21+from openlp.core.lib.toolbar import OpenLPToolbar
22 from openlp.core.ui import ServiceManager
23
24 from tests.functional import MagicMock, patch
25@@ -592,3 +593,41 @@
26 # THEN: The "save_as" method is called to save the service
27 self.assertTrue(result)
28 mocked_save_file_as.assert_called_with()
29+
30+ @patch(u'openlp.core.ui.servicemanager.ServiceManager.regenerate_service_items')
31+ def test_theme_change(self, mocked_regenerate_service_items):
32+ """
33+ Test that when a Toolbar theme combobox displays correctly
34+ """
35+ # GIVEN: A service manager, a service to save with a theme level of the renderer
36+ mocked_renderer = MagicMock()
37+ service_manager = ServiceManager(None)
38+ Registry().register('renderer', mocked_renderer)
39+ service_manager.toolbar = OpenLPToolbar(None)
40+
41+ service_manager.toolbar.add_toolbar_action('theme_combo_box', triggers=MagicMock())
42+ service_manager.toolbar.add_toolbar_action('theme_label', triggers=MagicMock())
43+
44+ # WHEN: The service manager has a Global theme
45+ mocked_renderer.theme_level = ThemeLevel.Global
46+ result = service_manager.theme_change()
47+
48+ # THEN: The the theme toolbar should not be visible
49+ self.assertFalse(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
50+ 'The visibility should be False')
51+
52+ # WHEN: The service manager has a Service theme
53+ mocked_renderer.theme_level = ThemeLevel.Service
54+ result = service_manager.theme_change()
55+
56+ # THEN: The the theme toolbar should not be visible
57+ self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
58+ 'The visibility should be True')
59+
60+ # WHEN: The service manager has a Song theme
61+ mocked_renderer.theme_level = ThemeLevel.Song
62+ result = service_manager.theme_change()
63+
64+ # THEN: The the theme toolbar should not be visible
65+ self.assertTrue(service_manager.toolbar.actions['theme_combo_box'].isVisible(),
66+ 'The visibility should be true')

Subscribers

People subscribed via source and target branches

to all changes: