From 9a068f5144ec160aa5dd22a4da13fb53fec54fca Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 May 2013 09:43:19 +0200 Subject: [PATCH] started with test --- .../openlp_core_ui/test_mainwindow.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/interfaces/openlp_core_ui/test_mainwindow.py diff --git a/tests/interfaces/openlp_core_ui/test_mainwindow.py b/tests/interfaces/openlp_core_ui/test_mainwindow.py new file mode 100644 index 000000000..e2f523ee0 --- /dev/null +++ b/tests/interfaces/openlp_core_ui/test_mainwindow.py @@ -0,0 +1,45 @@ +""" +Package to test the openlp.core.ui.mainwindow package. +""" +from unittest import TestCase +from mock import MagicMock, patch + +from PyQt4 import QtCore, QtGui, QtTest + +from openlp.core.lib import Registry, ScreenList +from openlp.core.ui.mainwindow import MainWindow + + +class TestMainWindow(TestCase): + + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.registry = Registry() + ScreenList.create(MagicMock()) + self.app = QtGui.QApplication([]) + self.app.args =[] + Registry().register(u'application', self.app) + self.main_window = MainWindow() + Registry().register(u'main_window', self.main_window) + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.main_window + del self.app + + def on_search_shortcut_triggered_test(self): + """ + """ + # GIVEN: Mocked mehtod. + mocked_current_widget = MagicMock() + self.main_window.media_tool_box.currentWidget = mocked_current_widget + + # WHEN: Press the shortcut + + # THEN: The on_focus method should have been called. + mocked_current_widget.on_focus.assert_called_with()