openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #24119
[Merge] lp:~trb143/openlp/bugsandtests into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/bugsandtests into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~trb143/openlp/bugsandtests/+merge/232001
Fix bug from code conversions
Add full test for the Service Manager Context menu covering all ServiceItem Types.
lp:~trb143/openlp/bugsandtests (revision 2404)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/580/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/531/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/475/
[ABORTED] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/435/
Stopping after failure
Windows tests aborted with wine error after all tests passed!
--
https://code.launchpad.net/~trb143/openlp/bugsandtests/+merge/232001
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bugsandtests into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2014-07-07 11:17:24 +0000
+++ openlp/core/ui/servicemanager.py 2014-08-24 09:53:51 +0000
@@ -993,7 +993,7 @@
service_item.auto_play_slides_once = False
self.set_modified()
- def on_auto_start(self):
+ def on_auto_start(self, field=None):
"""
Toggles to Auto Start Setting.
"""
=== modified file 'scripts/jenkins_script.py'
--- scripts/jenkins_script.py 2014-08-04 17:12:03 +0000
+++ scripts/jenkins_script.py 2014-08-24 09:53:51 +0000
@@ -89,7 +89,7 @@
:param token: The token we need to trigger the build. If you do not have this token, ask in IRC.
"""
self.token = token
- self.repo_name = get_repo_name()
+ self.base_name, self.repo_name = get_repo_name('b')
self.jenkins_instance = Jenkins(JENKINS_URL)
def trigger_build(self):
@@ -113,7 +113,8 @@
bzr = Popen(('bzr', 'revno'), stdout=PIPE, stderr=PIPE)
raw_output, error = bzr.communicate()
revno = raw_output.decode().strip()
- print('%s (revision %s)' % (get_repo_name(), revno))
+ print('Remote repository: %s ' % self.repo_name)
+ print(' Local repository: %s (revision %s)' % (self.repo_name, revno))
for job in OpenLPJobs.Jobs:
if not self.__print_build_info(job):
@@ -153,7 +154,7 @@
return is_success
-def get_repo_name():
+def get_repo_name(branch_type='l'):
"""
This returns the name of branch of the working directory. For example it returns *lp:~googol/openlp/render*.
"""
@@ -169,6 +170,7 @@
output_list = list(map(str.strip, raw_output.split('\n')))
# Determine the branch's name
repo_name = ''
+ base_name = ''
for line in output_list:
# Check if it is remote branch.
if 'push branch' in line:
@@ -181,7 +183,15 @@
if match:
repo_name = 'lp:%s' % match.group(2)
break
- return repo_name.strip('/')
+ elif 'repository branch' in line:
+ base_name = line.split(':')[1]
+ break
+ if branch_type == 'b':
+ return base_name.strip('/'), repo_name.strip('/')
+ elif branch_type == 'r':
+ return base_name.strip('/')
+ else:
+ return repo_name.strip('/')
def main():
@@ -195,9 +205,12 @@
options, args = parser.parse_args(sys.argv)
if len(args) == 2:
- if not get_repo_name():
+ if not get_repo_name('l'):
print('Not a branch. Have you pushed it to launchpad? Did you cd to the branch?')
return
+ if not get_repo_name('r'):
+ print('No remote branch. Have you pushed it to launchpad? Did you cd to the branch?')
+ return
token = args[-1]
if token in OLD_TOKENS:
print('Your token is not valid anymore. Get the most recent one.')
=== modified file 'tests/functional/openlp_core_ui/test_servicemanager.py'
--- tests/functional/openlp_core_ui/test_servicemanager.py 2014-06-05 16:32:29 +0000
+++ tests/functional/openlp_core_ui/test_servicemanager.py 2014-08-24 09:53:51 +0000
@@ -31,7 +31,8 @@
"""
from unittest import TestCase
-from openlp.core.common import Registry
+from openlp.core.common import Registry, ThemeLevel
+from openlp.core.lib import ServiceItem, ServiceItemType, ItemCapabilities
from openlp.core.ui import ServiceManager
from tests.interfaces import MagicMock, patch
@@ -89,3 +90,466 @@
self.assertEqual('txt' in service_manager.suffixes, True, 'The suffix txt should be in the list')
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')
+
+ def build_context_menu_test(self):
+ """
+ Test the creation of a context menu from a null service item.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have been called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have been called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
+ 'Should have been called once')
+
+ def build_song_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type text from Songs.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ mocked_renderer = MagicMock()
+ mocked_renderer.theme_level = ThemeLevel.Song
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', mocked_renderer)
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.CanEdit)
+ service_item.add_capability(ItemCapabilities.CanPreview)
+ service_item.add_capability(ItemCapabilities.CanLoop)
+ service_item.add_capability(ItemCapabilities.OnLoadUpdate)
+ service_item.add_capability(ItemCapabilities.AddIfNewItem)
+ service_item.add_capability(ItemCapabilities.CanSoftBreak)
+ service_item.service_item_type = ServiceItemType.Text
+ service_item.edit_id = 1
+ service_item._display_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ # THEN we add a 2nd display frame
+ service_item._display_frames.append(MagicMock())
+ service_manager.context_menu(1)
+ # THEN the following additional calls should have occurred.
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
+
+ def build_bible_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type text from Bibles.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ mocked_renderer = MagicMock()
+ mocked_renderer.theme_level = ThemeLevel.Song
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', mocked_renderer)
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.NoLineBreaks)
+ service_item.add_capability(ItemCapabilities.CanPreview)
+ service_item.add_capability(ItemCapabilities.CanLoop)
+ service_item.add_capability(ItemCapabilities.CanWordSplit)
+ service_item.add_capability(ItemCapabilities.CanEditTitle)
+ service_item.service_item_type = ServiceItemType.Text
+ service_item.edit_id = 1
+ service_item._display_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ # THEN we add a 2nd display frame
+ service_item._display_frames.append(MagicMock())
+ service_manager.context_menu(1)
+ # THEN the following additional calls should have occurred.
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
+
+ def build_custom_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type text from Custom.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ mocked_renderer = MagicMock()
+ mocked_renderer.theme_level = ThemeLevel.Song
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', mocked_renderer)
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.CanEdit)
+ service_item.add_capability(ItemCapabilities.CanPreview)
+ service_item.add_capability(ItemCapabilities.CanLoop)
+ service_item.add_capability(ItemCapabilities.CanSoftBreak)
+ service_item.add_capability(ItemCapabilities.OnLoadUpdate)
+ service_item.service_item_type = ServiceItemType.Text
+ service_item.edit_id = 1
+ service_item._display_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ # THEN we add a 2nd display frame
+ service_item._display_frames.append(MagicMock())
+ service_manager.context_menu(1)
+ # THEN the following additional calls should have occurred.
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
+
+ def build_image_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type Image from Image.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', MagicMock())
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.CanMaintain)
+ service_item.add_capability(ItemCapabilities.CanPreview)
+ service_item.add_capability(ItemCapabilities.CanLoop)
+ service_item.add_capability(ItemCapabilities.CanAppend)
+ service_item.add_capability(ItemCapabilities.CanEditTitle)
+ service_item.service_item_type = ServiceItemType.Image
+ service_item.edit_id = 1
+ service_item._raw_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ # THEN we add a 2nd display frame and regenerate the menu.
+ service_item._raw_frames.append(MagicMock())
+ service_manager.context_menu(1)
+ # THEN the following additional calls should have occurred.
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
+ 'Should have be called twice')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
+
+ def build_media_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type Command from Media.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', MagicMock())
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
+ service_item.add_capability(ItemCapabilities.CanEditTitle)
+ service_item.add_capability(ItemCapabilities.RequiresMedia)
+ service_item.service_item_type = ServiceItemType.Command
+ service_item.edit_id = 1
+ service_item._raw_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ # THEN I change the length of the media and regenerate the menu.
+ service_item.set_media_length(5)
+ service_manager.context_menu(1)
+ # THEN the following additional calls should have occurred.
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
+
+ def build_presentation_pdf_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type Command with PDF from Presentation.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', MagicMock())
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.CanMaintain)
+ service_item.add_capability(ItemCapabilities.CanPreview)
+ service_item.add_capability(ItemCapabilities.CanLoop)
+ service_item.add_capability(ItemCapabilities.CanAppend)
+ service_item.service_item_type = ServiceItemType.Command
+ service_item.edit_id = 1
+ service_item._raw_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 2, 'Should have be called twice')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+
+ def build_presentation_non_pdf_context_menu_test(self):
+ """
+ Test the creation of a context menu from service item of type Command with Impress from Presentation.
+ """
+ # GIVEN: A new service manager instance and a default service item.
+ Registry().register('plugin_manager', MagicMock())
+ Registry().register('renderer', MagicMock())
+ service_manager = ServiceManager(None)
+ item = MagicMock()
+ item.parent.return_value = False
+ item.data.return_value = 0
+ service_manager.service_manager_list = MagicMock()
+ service_manager.service_manager_list.itemAt.return_value = item
+ service_item = ServiceItem(None)
+ service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
+ service_item.service_item_type = ServiceItemType.Command
+ service_item.edit_id = 1
+ service_item._raw_frames.append(MagicMock())
+ service_manager.service_items.insert(1, {'service_item': service_item})
+ service_manager.edit_action = MagicMock()
+ service_manager.rename_action = MagicMock()
+ service_manager.create_custom_action = MagicMock()
+ service_manager.maintain_action = MagicMock()
+ service_manager.notes_action = MagicMock()
+ service_manager.time_action = MagicMock()
+ service_manager.auto_start_action = MagicMock()
+ service_manager.auto_play_slides_menu = MagicMock()
+ service_manager.auto_play_slides_once = MagicMock()
+ service_manager.auto_play_slides_loop = MagicMock()
+ service_manager.timed_slide_interval = MagicMock()
+ service_manager.theme_menu = MagicMock()
+ service_manager.menu = MagicMock()
+ # WHEN I define a context menu
+ service_manager.context_menu(1)
+ # THEN the following calls should have occurred.
+ self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')
+ self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
+ self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
+ 'Should have be called once')