This commit is contained in:
Tim Bentley 2012-12-09 20:57:41 +00:00
parent 39f7aabeeb
commit 5a4a33b9b8
2 changed files with 34 additions and 26 deletions

View File

@ -289,6 +289,9 @@ class MediaController(object):
controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24)) controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24))
controller.volumeSlider.setObjectName(u'volumeSlider') controller.volumeSlider.setObjectName(u'volumeSlider')
controller.mediabar.addToolbarWidget(controller.volumeSlider) controller.mediabar.addToolbarWidget(controller.volumeSlider)
controller.volumeButton = QtGui.QToolButton()
controller.volumeButton.setAutoRaise(True)
controller.mediabar.addToolbarWidget(controller.volumeButton)
controller.controllerLayout.addWidget(controller.mediabar) controller.controllerLayout.addWidget(controller.mediabar)
controller.mediabar.setVisible(False) controller.mediabar.setVisible(False)
# Signals # Signals

View File

@ -3,7 +3,7 @@
""" """
from unittest import TestCase from unittest import TestCase
from mock import MagicMock, patch from mock import MagicMock, patch
from openlp.core.lib import ServiceItem, Renderer from openlp.core.lib import ServiceItem
VERSE = u'The Lord said to {r}Noah{/r}: \n'\ VERSE = u'The Lord said to {r}Noah{/r}: \n'\
'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n'\ 'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n'\
@ -20,34 +20,39 @@ class TestServiceItem(TestCase):
""" """
Test the Service Item Test the Service Item
""" """
with patch(u'openlp.core.lib.Plugin') as mocked_plugin: #GIVEN: A new service item
#GIVEN: A new service item
service_item = ServiceItem(mocked_plugin) # WHEN:A service item is created (without a plugin)
#true_boolean = True service_item = ServiceItem(None)
# WHEN:
# THEN: We should get back a valid service item # THEN: We should get back a valid service item
#assert isinstance(true_result, bool), u'The result should be a boolean' assert service_item.is_valid is True, u'A valid Service Item'
assert service_item.is_valid is True, u'A valid Service Item' assert service_item.missing_frames() is True, u'No frames loaded yet'
assert service_item.missing_frames() is False, u'No frames loaded yet'
def serviceitem_add_text_test(self): def serviceitem_add_text_test(self):
""" """
Test the Service Item Test the Service Item
""" """
with patch(u'openlp.core.lib.Plugin') as mocked_plugin: #GIVEN: A new service item
#GIVEN: A new service item service_item = ServiceItem(None)
service_item = ServiceItem(mocked_plugin)
# WHEN: adding text to a service item
service_item.add_from_text(VERSE)
service_item.raw_footer = FOOTER
# THEN: We should get back a valid service item
assert service_item.is_valid is True, u'A valid Service Item'
assert service_item.missing_frames() is True, u'frames loaded '
#GIVEN: A service item with text # WHEN: adding text to a service item
service_item.renderer = MagicMock().Renderer.format_slide.return_value = VERSE service_item.add_from_text(VERSE)
#WHEN: Render called service_item.raw_footer = FOOTER
assert len(service_item._display_frames) is 0, u'A blank Service Item'
service_item.render(True) # THEN: We should get back a valid service item
#THEN: ? assert service_item.is_valid is True, u'A valid Service Item'
assert len(service_item._display_frames) > 0, u'A valid rendered Service Item has display frames' assert service_item.missing_frames() is False, u'frames loaded '
#GIVEN: A service item with text
mocked_renderer = MagicMock()
mocked_renderer.format_slide.return_value = [VERSE]
service_item.renderer = mocked_renderer
#WHEN: Render called
assert len(service_item._display_frames) is 0, u'A blank Service Item'
service_item.render(True)
#THEN: We should should have a page of output.
assert len(service_item._display_frames) is 1, u'A valid rendered Service Item has display frames'
assert service_item.get_rendered_frame(0) == VERSE.split(u'\n')[0], u'A valid render'