From 5b4e285782cb6d36cb09467027a3433754059938 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 16 Feb 2013 19:14:41 +0100 Subject: [PATCH] created constant; changed test method description --- .../functional/openlp_core_lib/test_screen.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index 8f6631043..92dd48172 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -10,6 +10,13 @@ from PyQt4 import QtGui, QtCore from openlp.core.lib import ScreenList +SCREEN = { + u'primary': False, + u'number': 1, + u'size': QtCore.QRect(0, 0, 1024, 768) +} + + class TestScreenList(TestCase): def setUp(self): @@ -21,25 +28,20 @@ class TestScreenList(TestCase): def tearDown(self): """ + Delete QApplication. """ del self.application def add_desktop_test(self): """ - Test to check if new monitors are detected by OpenLP (= plugged in while OpenLP is running). + Test the ScreenList class' screen_count_changed method to check if new monitors are detected by OpenLP. """ # 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']) + 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)) @@ -49,5 +51,5 @@ class TestScreenList(TestCase): 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.' + assert SCREEN == new_screens.pop(), u'The new screen should be identically to the screen defined above.'