cleaned code

This commit is contained in:
Andreas Preikschat 2013-02-16 16:02:19 +01:00
parent 479244fde2
commit bea5fe2596
7 changed files with 24 additions and 8 deletions

View File

@ -5,4 +5,9 @@ sip.setapi(u'QString', 2)
sip.setapi(u'QTextStream', 2) sip.setapi(u'QTextStream', 2)
sip.setapi(u'QTime', 2) sip.setapi(u'QTime', 2)
sip.setapi(u'QUrl', 2) sip.setapi(u'QUrl', 2)
sip.setapi(u'QVariant', 2) sip.setapi(u'QVariant', 2)
from PyQt4 import QtGui
# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication.
application = QtGui.QApplication([])

View File

@ -20,10 +20,16 @@ class TestImageManager(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) self.app = QtGui.QApplication.instance()
ScreenList.create(self.app.desktop()) ScreenList.create(self.app.desktop())
self.image_manager = ImageManager() self.image_manager = ImageManager()
def tearDown(self):
"""
Delete all the C++ objects at the end so that we don't have a segfault
"""
del self.app
def basic_image_manager_test(self): def basic_image_manager_test(self):
""" """
Test the Image Manager setup basic functionality Test the Image Manager setup basic functionality

View File

@ -19,6 +19,11 @@ class TestScreenList(TestCase):
self.application = QtGui.QApplication.instance() self.application = QtGui.QApplication.instance()
self.screens = ScreenList.create(self.application.desktop()) self.screens = ScreenList.create(self.application.desktop())
def tearDown(self):
"""
"""
del self.application
def add_desktop_test(self): def add_desktop_test(self):
""" """
Test to check if new monitors are detected by OpenLP (= plugged in while OpenLP is running). Test to check if new monitors are detected by OpenLP (= plugged in while OpenLP is running).

View File

@ -15,7 +15,7 @@ class TestStartFileRenameForm(TestCase):
Create the UI Create the UI
""" """
registry = Registry.create() registry = Registry.create()
self.app = QtGui.QApplication([]) self.app = QtGui.QApplication.instance()
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register(u'main_window', self.main_window) Registry().register(u'main_window', self.main_window)
self.form = filerenameform.FileRenameForm() self.form = filerenameform.FileRenameForm()

View File

@ -18,7 +18,7 @@ class TestStartNoteDialog(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) self.app = QtGui.QApplication.instance()
ScreenList.create(self.app.desktop()) ScreenList.create(self.app.desktop())
Registry().register(u'application', MagicMock()) Registry().register(u'application', MagicMock())
self.main_window = MainWindow() self.main_window = MainWindow()

View File

@ -17,7 +17,7 @@ class TestStartNoteDialog(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) self.app = QtGui.QApplication.instance()
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register(u'main_window', self.main_window) Registry().register(u'main_window', self.main_window)
self.form = servicenoteform.ServiceNoteForm() self.form = servicenoteform.ServiceNoteForm()
@ -66,4 +66,4 @@ class TestStartNoteDialog(TestCase):
QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton) QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
# THEN the following text is returned # THEN the following text is returned
self.assertEqual(self.form.text_edit.toPlainText(), text, u'The new text should be returned') self.assertEqual(self.form.text_edit.toPlainText(), text, u'The new text should be returned')

View File

@ -17,7 +17,7 @@ class TestStartTimeDialog(TestCase):
Create the UI Create the UI
""" """
Registry.create() Registry.create()
self.app = QtGui.QApplication([]) self.app = QtGui.QApplication.instance()
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
Registry().register(u'main_window', self.main_window) Registry().register(u'main_window', self.main_window)
self.form = starttimeform.StartTimeForm() self.form = starttimeform.StartTimeForm()
@ -93,4 +93,4 @@ class TestStartTimeDialog(TestCase):
self.assertEqual(self.form.hourSpinBox.value(), 0) self.assertEqual(self.form.hourSpinBox.value(), 0)
self.assertEqual(self.form.minuteSpinBox.value(), 2) self.assertEqual(self.form.minuteSpinBox.value(), 2)
self.assertEqual(self.form.secondSpinBox.value(), 3) self.assertEqual(self.form.secondSpinBox.value(), 3)
self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time should have changed') self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time should have changed')