diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 3ad0e1348..1898c361b 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -276,7 +276,8 @@ def main(args=None): qt_args.append('OpenLP') # Initialise the resources qInitResources() - # Now create and actually run the application. + # Now create and actually run the application.# + print qt_args application = OpenLP(qt_args) application.setOrganizationName(u'OpenLP') application.setOrganizationDomain(u'openlp.org') diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index d13c82c04..a257fec20 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -28,7 +28,8 @@ class TestImageManager(TestCase): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.app + #del self.app + pass def basic_image_manager_test(self): """ diff --git a/tests/functional/openlp_core_lib/test_screenlist.py b/tests/functional/openlp_core_lib/test_screenlist.py index e61338d05..cb7635c71 100644 --- a/tests/functional/openlp_core_lib/test_screenlist.py +++ b/tests/functional/openlp_core_lib/test_screenlist.py @@ -1,38 +1,48 @@ """ Package to test the openlp.core.lib.screenlist package. """ +import copy from unittest import TestCase -#from mock import MagicMock, patch +from mock import MagicMock from openlp.core.lib import ScreenList -from PyQt4 import QtGui +from PyQt4 import QtGui, QtCore -class TestScreenList(object): +class TestScreenList(TestCase): def setUp(self): """ Set up the components need for all tests. """ - self.application = QtGui.QApplication([]) - print ScreenList.create(self.application.desktop()) - self.screen_list = ScreenList() - - def tearDown(self): - """ - Clean up the components needed for the tests. - """ - del self.application - - def basic_test(self): - """ - """ - print self.screen_list.get_screen_list() + self.application = QtGui.QApplication.instance() + self.screens = ScreenList.create(self.application.desktop()) def add_desktop_test(self): """ Test to check if new monitors are detected by OpenLP (= plugged in while OpenLP is running). """ - pass + # GIVEN: The screen list. + old_screens = copy.deepcopy(self.screens.screen_list) + + screen = { + u'primary': False, + u'number': 1, + u'size': QtCore.QRect(0, 0, 1024, 768) + } + # Mock the attributes. + self.screens.desktop.primaryScreen = MagicMock(return_value=screen[u'primary']) + self.screens.desktop.screenCount = MagicMock(return_value=screen[u'number'] + 1) + self.screens.desktop.screenGeometry = MagicMock(return_value=screen[u'size']) + + # WHEN: Add a new screen. + self.screens.screen_count_changed(len(old_screens)) + + # THEN: The screen should have been added. + new_screens = self.screens.screen_list + assert len(old_screens) + 1 == len(new_screens), u'The new_screens list should be bigger.' + + # THEN: The screens should be identically. + assert screen == new_screens.pop(), u'The new screen should be identically to the screen defined above.'