- Added two tests for checking if doubleclicking preview should add item to service or send it to live.

This commit is contained in:
suutari-olli 2016-04-20 18:56:10 +03:00
parent 518dde5d2d
commit 55061b8fc1
2 changed files with 44 additions and 16 deletions

View File

@ -1095,7 +1095,8 @@ class SlideController(DisplayController, RegistryProperties):
self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.'
% timeout)
return
# If "click live slide to unblank" is enabled, unblank the display.
# If "click live slide to unblank" is enabled, unblank the display. And start = Item is sent to Live.
# 'core/is live item edited and replaced' is only True when replacing Live item with the same item from Service.
# Note: If this if statement is placed at the bottom of this function instead of top slide transitions are lost.
if self.is_live and Settings().value('core/click live slide to unblank'):
# With this display stays blanked when "auto unblank" setting is not enabled and new item is sent to Live.

View File

@ -713,6 +713,48 @@ class TestSlideController(TestCase):
slide_controller.theme_screen, slide_controller.blank_screen
])
@patch('openlp.core.ui.slidecontroller.Settings')
def on_preview_double_click_unblank_display_test(self, MockedSettings):
# GIVEN: A slide controller, actions needed, settins set to True.
slide_controller = SlideController(None)
mocked_settings = MagicMock()
mocked_settings.value.return_value = True
MockedSettings.return_value = mocked_settings
slide_controller.service_item = MagicMock()
slide_controller.service_item.is_media = MagicMock()
slide_controller.on_media_close = MagicMock()
slide_controller.on_go_live = MagicMock()
slide_controller.on_preview_add_to_service = MagicMock()
slide_controller.media_reset = MagicMock()
# WHEN: on_preview_double_click is called
slide_controller.on_preview_double_click()
# THEN: The call to addActions should be correct
self.assertEqual(1, slide_controller.on_go_live.call_count, 'on_go_live should have been called once.')
self.assertEqual(0, slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.')
@patch('openlp.core.ui.slidecontroller.Settings')
def on_preview_double_click_add_to_service_test(self, MockedSettings):
# GIVEN: A slide controller, actions needed, settins set to False.
slide_controller = SlideController(None)
mocked_settings = MagicMock()
mocked_settings.value.return_value = False
MockedSettings.return_value = mocked_settings
slide_controller.service_item = MagicMock()
slide_controller.service_item.is_media = MagicMock()
slide_controller.on_media_close = MagicMock()
slide_controller.on_go_live = MagicMock()
slide_controller.on_preview_add_to_service = MagicMock()
slide_controller.media_reset = MagicMock()
# WHEN: on_preview_double_click is called
slide_controller.on_preview_double_click()
# THEN: The call to addActions should be correct
self.assertEqual(0, slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.')
self.assertEqual(1, slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.')
class TestInfoLabel(TestCase):
@ -805,18 +847,3 @@ class TestLiveController(TestCase):
# WHEN: the default controller is built.
# THEN: The controller should not be a live controller.
self.assertEqual(live_controller.is_live, True, 'The slide controller should be a live controller')
class TestPreviewLiveController(TestCase):
def initial_preview_controller_test(self):
"""
Test the initial preview slide controller state.
"""
# GIVEN: A new SlideController instance.
Registry.create()
preview_controller = PreviewController(None)
# WHEN: the default controller is built.
# THEN: The controller should not be a live controller.
self.assertEqual(preview_controller.is_live, False, 'The slide controller should be a Preview controller')