Fix issue with android where tagging is wrong is the render takes too long

This commit is contained in:
Tim Bentley 2015-05-25 20:31:12 +01:00
parent 002d68086a
commit 54dbafed8e
2 changed files with 91 additions and 62 deletions

View File

@ -824,6 +824,8 @@ class SlideController(DisplayController, RegistryProperties):
"""
self.on_stop_loop()
old_item = self.service_item
# rest to allow the remote pick up verse 1 if large imaged
self.selected_row = 0
# take a copy not a link to the servicemanager copy.
self.service_item = copy.copy(service_item)
if old_item and self.is_live and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
@ -1417,11 +1419,11 @@ class SlideController(DisplayController, RegistryProperties):
class PreviewController(RegistryMixin, OpenLPMixin, SlideController):
"""
Set up the Live Controller.
Set up the Preview Controller.
"""
def __init__(self, parent):
"""
Set up the general Controller.
Set up the base Controller as a preview.
"""
super(PreviewController, self).__init__(parent)
self.split = 0
@ -1441,7 +1443,7 @@ class LiveController(RegistryMixin, OpenLPMixin, SlideController):
"""
def __init__(self, parent):
"""
Set up the general Controller.
Set up the base Controller as a live.
"""
super(LiveController, self).__init__(parent)
self.is_live = True

View File

@ -27,7 +27,7 @@ from PyQt4 import QtCore, QtGui
from unittest import TestCase
from openlp.core import Registry
from openlp.core.lib import ServiceItemAction
from openlp.core.ui import SlideController
from openlp.core.ui import SlideController, LiveController, PreviewController
from openlp.core.ui.slidecontroller import InfoLabel, WIDE_MENU, NON_TEXT_MENU
from tests.functional import MagicMock, patch
@ -84,11 +84,11 @@ class TestSlideController(TestCase):
# THEN: then call set up the toolbar to blank the display screen.
toolbar.set_widget_visible.assert_called_with(NON_TEXT_MENU, True)
def receive_spin_delay_test(self):
@patch('openlp.core.ui.slidecontroller.Settings')
def receive_spin_delay_test(self, MockedSettings):
"""
Test that the spin box is updated accordingly after a call to receive_spin_delay()
"""
with patch('openlp.core.ui.slidecontroller.Settings') as MockedSettings:
# GIVEN: A new SlideController instance.
mocked_value = MagicMock(return_value=1)
MockedSettings.return_value = MagicMock(value=mocked_value)
@ -267,12 +267,12 @@ class TestSlideController(TestCase):
mocked_keypress_queue.append.assert_called_once_with(ServiceItemAction.Next)
mocked_process_queue.assert_called_once_with()
def update_slide_limits_test(self):
@patch('openlp.core.ui.slidecontroller.Settings')
def update_slide_limits_test(self, MockedSettings):
"""
Test that calling the update_slide_limits() method updates the slide limits
"""
# GIVEN: A mocked out Settings object, a new SlideController and a mocked out main_window
with patch('openlp.core.ui.slidecontroller.Settings') as MockedSettings:
mocked_value = MagicMock(return_value=10)
MockedSettings.return_value = MagicMock(value=mocked_value)
mocked_main_window = MagicMock(advanced_settings_section='advanced')
@ -522,7 +522,8 @@ class TestSlideController(TestCase):
# THEN: It should have exited early
self.assertEqual(0, mocked_item.is_command.call_count, 'The service item should have not been called')
def on_slide_selected_index_service_item_command_test(self):
@patch.object(Registry, 'execute')
def on_slide_selected_index_service_item_command_test(self, mocked_execute):
"""
Test that when there is a command service item, the command is executed
"""
@ -533,7 +534,6 @@ class TestSlideController(TestCase):
mocked_update_preview = MagicMock()
mocked_preview_widget = MagicMock()
mocked_slide_selected = MagicMock()
with patch.object(Registry, 'execute') as mocked_execute:
Registry.create()
slide_controller = SlideController(None)
slide_controller.service_item = mocked_item
@ -552,7 +552,8 @@ class TestSlideController(TestCase):
self.assertEqual(0, mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called')
self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
def on_slide_selected_index_service_item_not_command_test(self):
@patch.object(Registry, 'execute')
def on_slide_selected_index_service_item_not_command_test(self, mocked_execute):
"""
Test that when there is a service item but it's not a command, the preview widget is updated
"""
@ -563,7 +564,6 @@ class TestSlideController(TestCase):
mocked_update_preview = MagicMock()
mocked_preview_widget = MagicMock()
mocked_slide_selected = MagicMock()
with patch.object(Registry, 'execute') as mocked_execute:
Registry.create()
slide_controller = SlideController(None)
slide_controller.service_item = mocked_item
@ -642,12 +642,11 @@ class TestInfoLabel(TestCase):
elided_test_string = metrics.elidedText(test_string, QtCore.Qt.ElideRight, label_width)
mocked_qpainter().drawText.assert_called_once_with(mocked_rect(), QtCore.Qt.AlignLeft, elided_test_string)
def set_text_test(self):
@patch('builtins.super')
def set_text_test(self, mocked_super):
"""
Test the reimplemented setText method
"""
with patch('builtins.super') as mocked_super:
# GIVEN: An instance of InfoLabel and mocked setToolTip method
info_label = InfoLabel()
set_tool_tip_mock = MagicMock()
@ -659,3 +658,31 @@ class TestInfoLabel(TestCase):
# THEN: The setToolTip and super class setText methods should have been called with the same text
set_tool_tip_mock.assert_called_once_with('Label Text')
mocked_super().setText.assert_called_once_with('Label Text')
class TestLiveController(TestCase):
def initial_live_controller_test(self):
"""
Test the initial live slide controller state .
"""
# GIVEN: A new SlideController instance.
Registry.create()
live_controller = LiveController(None)
# 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')