forked from openlp/openlp
Style updates and more tests
This commit is contained in:
parent
174905b991
commit
e03a265ba9
@ -54,7 +54,7 @@ class MediaSlider(QtGui.QSlider):
|
||||
"""
|
||||
Override event to allow hover time to be displayed.
|
||||
"""
|
||||
timevalue = QtGui.QStyle.sliderValueFromPosition(self.minimum(),self.maximum(),event.x(),self.width())
|
||||
timevalue = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width())
|
||||
self.setToolTip(u'%s' % datetime.timedelta(seconds=int(timevalue/1000)))
|
||||
QtGui.QSlider.mouseMoveEvent(self, event)
|
||||
|
||||
@ -68,7 +68,7 @@ class MediaSlider(QtGui.QSlider):
|
||||
"""
|
||||
Set the slider position when the mouse is clicked and released on the slider.
|
||||
"""
|
||||
self.setValue(QtGui.QStyle.sliderValueFromPosition(self.minimum(),self.maximum(),event.x(),self.width()))
|
||||
self.setValue(QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()))
|
||||
QtGui.QSlider.mouseReleaseEvent(self, event)
|
||||
|
||||
|
||||
|
BIN
tests/functional/openlp_core_lib/resources/church.jpg
Normal file
BIN
tests/functional/openlp_core_lib/resources/church.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 KiB |
@ -18,7 +18,7 @@ class TestServiceItem(TestCase):
|
||||
|
||||
def serviceitem_basic_test(self):
|
||||
"""
|
||||
Test the Service Item
|
||||
Test the Service Item basic test
|
||||
"""
|
||||
#GIVEN: A new service item
|
||||
|
||||
@ -26,12 +26,14 @@ class TestServiceItem(TestCase):
|
||||
service_item = ServiceItem(None)
|
||||
|
||||
# THEN: We should get back a valid service item
|
||||
print service_item
|
||||
print dir(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'
|
||||
|
||||
def serviceitem_add_text_test(self):
|
||||
"""
|
||||
Test the Service Item
|
||||
Test the Service Item add text test
|
||||
"""
|
||||
#GIVEN: A new service item
|
||||
service_item = ServiceItem(None)
|
||||
@ -42,7 +44,7 @@ class TestServiceItem(TestCase):
|
||||
|
||||
# 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 False, u'frames loaded '
|
||||
assert service_item.missing_frames() is False, u'check frames loaded '
|
||||
|
||||
#GIVEN: A service item with text
|
||||
mocked_renderer = MagicMock()
|
||||
@ -59,7 +61,7 @@ class TestServiceItem(TestCase):
|
||||
|
||||
def serviceitem_add_image_test(self):
|
||||
"""
|
||||
Test the Service Item
|
||||
Test the Service Item add image test
|
||||
"""
|
||||
#GIVEN: A new service item and a mocked renderer
|
||||
service_item = ServiceItem(None)
|
||||
@ -72,7 +74,6 @@ class TestServiceItem(TestCase):
|
||||
|
||||
# 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 False, u'frames loaded '
|
||||
assert len(service_item._display_frames) is 0, u'A blank Service Item'
|
||||
|
||||
#THEN: We should should have a page of output.
|
||||
@ -104,9 +105,18 @@ class TestServiceItem(TestCase):
|
||||
#Then the service item should be valid
|
||||
assert service_item.is_valid is True, u'The service item is valid'
|
||||
|
||||
# WHEN: adding a second image to a service item
|
||||
service_item.add_from_image(u'resources/church1.jpg', u'Image1 Title')
|
||||
|
||||
#When validating a service item
|
||||
service_item.validate_item([u'jpg'])
|
||||
|
||||
#Then the service item should be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid'
|
||||
|
||||
def serviceitem_add_command_test(self):
|
||||
"""
|
||||
Test the Service Item
|
||||
Test the Service Item add command test
|
||||
"""
|
||||
#GIVEN: A new service item and a mocked renderer
|
||||
service_item = ServiceItem(None)
|
||||
@ -119,7 +129,6 @@ class TestServiceItem(TestCase):
|
||||
|
||||
# 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 False, u'frames loaded '
|
||||
assert len(service_item._display_frames) is 0, u'A blank Service Item'
|
||||
|
||||
#THEN: We should should have a page of output.
|
||||
@ -141,3 +150,9 @@ class TestServiceItem(TestCase):
|
||||
|
||||
#Then the service item should be valid
|
||||
assert service_item.is_valid is True, u'The service item is valid'
|
||||
|
||||
#When validating a service item with a different suffix
|
||||
service_item.validate_item([u'png'])
|
||||
|
||||
#Then the service item should not be valid
|
||||
assert service_item.is_valid is False, u'The service item is not valid'
|
48
tests/functional/openlp_core_ui/starttimedialog.py
Normal file
48
tests/functional/openlp_core_ui/starttimedialog.py
Normal file
@ -0,0 +1,48 @@
|
||||
"""
|
||||
Package to test the openlp.core.ui package.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from unittest import TestCase
|
||||
from mock import MagicMock
|
||||
from openlp.core.ui import starttimeform
|
||||
from PyQt4 import QtCore, QtGui, QtTest
|
||||
|
||||
class TestStartTimeDialog(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create the UI
|
||||
"""
|
||||
self.app = QtGui.QApplication(sys.argv)
|
||||
self.window = QtGui.QMainWindow()
|
||||
self.form = starttimeform.StartTimeForm(self.window)
|
||||
|
||||
def ui_defaults_test(self):
|
||||
"""
|
||||
Test StartTimeDialog defaults
|
||||
"""
|
||||
self.assertEqual(self.form.hourSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.hourSpinBox.maximum(), 4)
|
||||
self.assertEqual(self.form.minuteSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.minuteSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.secondSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.secondSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.hourFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.hourFinishSpinBox.maximum(), 4)
|
||||
self.assertEqual(self.form.minuteFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.minuteFinishSpinBox.maximum(), 59)
|
||||
self.assertEqual(self.form.secondFinishSpinBox.minimum(), 0)
|
||||
self.assertEqual(self.form.secondFinishSpinBox.maximum(), 59)
|
||||
|
||||
def time_display_test(self):
|
||||
"""
|
||||
Test StartTimeDialog display initialisation
|
||||
"""
|
||||
#GIVEN: A service item with with time
|
||||
mocked_serviceitem = MagicMock()
|
||||
mocked_serviceitem.start_time = 61
|
||||
mocked_serviceitem.end_time = 3701
|
||||
|
||||
self.form.item = mocked_serviceitem
|
||||
#self.form.exec_()
|
Loading…
Reference in New Issue
Block a user