2013-02-16 10:28:37 +00:00
|
|
|
"""
|
|
|
|
Package to test the openlp.core.lib.screenlist package.
|
|
|
|
"""
|
2013-02-16 12:27:13 +00:00
|
|
|
import copy
|
2013-02-16 10:28:37 +00:00
|
|
|
from unittest import TestCase
|
|
|
|
|
2013-02-16 12:33:54 +00:00
|
|
|
from PyQt4 import QtGui, QtCore
|
2013-02-16 10:28:37 +00:00
|
|
|
|
|
|
|
from openlp.core.lib import ScreenList
|
|
|
|
|
|
|
|
|
2013-02-16 12:27:13 +00:00
|
|
|
class TestScreenList(TestCase):
|
2013-02-16 10:28:37 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""
|
|
|
|
Set up the components need for all tests.
|
|
|
|
"""
|
2013-02-16 12:27:13 +00:00
|
|
|
self.application = QtGui.QApplication.instance()
|
|
|
|
self.screens = ScreenList.create(self.application.desktop())
|
2013-02-16 10:28:37 +00:00
|
|
|
|
|
|
|
def add_desktop_test(self):
|
|
|
|
"""
|
|
|
|
Test to check if new monitors are detected by OpenLP (= plugged in while OpenLP is running).
|
|
|
|
"""
|
2013-02-16 12:27:13 +00:00
|
|
|
# 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.'
|
2013-02-16 10:28:37 +00:00
|
|
|
|