Exemple #1
0
 def test_build_media_context_menu(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.slides.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.
     assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.rename_action.setVisible.call_count == 2, 'Should have be called twice'
     assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.auto_start_action.setVisible.call_count == 2, 'Should have be called twice'
     assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
         'Should have be called once'
     assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
     assert 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.
     assert service_manager.time_action.setVisible.call_count == 3, 'Should have be called three times'
Exemple #2
0
 def test_build_presentation_pdf_context_menu(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.slides.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.
     assert service_manager.edit_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.maintain_action.setVisible.call_count == 2, 'Should have be called twice'
     assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
         'Should have be called once'
     assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
         'Should have be called once'
Exemple #3
0
 def test_build_context_menu(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.
     assert service_manager.edit_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.rename_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.notes_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.time_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have been called once'
     assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
         'Should have been called once'
     assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.theme_menu.menuAction().setVisible.call_count == 1, \
         'Should have been called once'
Exemple #4
0
 def test_build_custom_context_menu(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_slides = []
     service_item._display_slides.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.
     assert service_manager.edit_action.setVisible.call_count == 2, 'Should have be called twice'
     assert service_manager.rename_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.create_custom_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.maintain_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.notes_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.time_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.auto_start_action.setVisible.call_count == 1, 'Should have be called once'
     assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 1, \
         'Should have be called once'
     assert service_manager.auto_play_slides_once.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.auto_play_slides_loop.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.timed_slide_interval.setChecked.call_count == 0, 'Should not be called'
     assert service_manager.theme_menu.menuAction().setVisible.call_count == 2, \
         'Should have be called twice'
     # THEN we add a 2nd display frame
     service_item._display_slides.append(MagicMock())
     service_manager.context_menu(1)
     # THEN the following additional calls should have occurred.
     assert service_manager.auto_play_slides_menu.menuAction().setVisible.call_count == 2, \
         'Should have be called twice'
     assert service_manager.auto_play_slides_once.setChecked.call_count == 1, 'Should have be called once'
     assert service_manager.auto_play_slides_loop.setChecked.call_count == 1, 'Should have be called once'
     assert service_manager.timed_slide_interval.setChecked.call_count == 1, 'Should have be called once'