From a69323ea896632ae776964c532265f8892f22d7b Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 29 Mar 2013 13:40:04 +0100 Subject: [PATCH 1/3] fixed auto preview of next service item --- openlp/core/ui/servicemanager.py | 2 +- tests/interfaces/openlp_plugins/__init__.pyc | Bin 184 -> 0 bytes 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 tests/interfaces/openlp_plugins/__init__.pyc diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 7be147b8a..7aea8b6c0 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1404,7 +1404,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): self.preview_controller.addServiceManagerItem(self.service_items[item][u'service_item'], 0) next_item = self.service_manager_list.topLevelItem(item) self.service_manager_list.setCurrentItem(next_item) - self.live_controller.previewListWidget.setFocus() + self.live_controller.preview_list_widget.setFocus() else: critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), translate('OpenLP.ServiceManager', diff --git a/tests/interfaces/openlp_plugins/__init__.pyc b/tests/interfaces/openlp_plugins/__init__.pyc deleted file mode 100644 index 0d24c9eff54ac7d86f14523ef46194c4bbc24cad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmZ9GO$q`r423JY5W#!QX3Pa-@BpGC9-x#qGe-JH(*ZrLhY(zw0apgz3w(L-vV3nh zpI3LW>NgA72NAEtoKn|jCZ|SB{TUl!a7zKfL|4!-^d;TVR)%xNc Date: Sat, 30 Mar 2013 10:01:21 +0100 Subject: [PATCH 2/3] added test --- .../custom/forms/test_customform.py | 4 +- .../custom/forms/test_customslideform.py | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index ebd12f49d..6e6318ca6 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -1,5 +1,5 @@ """ -Module to test the custom edit form. +Module to test the EditCustomForm. """ from unittest import TestCase from mock import MagicMock, patch @@ -12,7 +12,7 @@ from openlp.plugins.custom.lib.mediaitem import CustomMediaItem from openlp.plugins.custom.forms.editcustomform import EditCustomForm -class TestCustomFrom(TestCase): +class TestEditCustomForm(TestCase): """ Test the EditCustomForm. """ diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py new file mode 100644 index 000000000..26da9afa6 --- /dev/null +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -0,0 +1,68 @@ +""" +Module to test the EditCustomSlideForm. +""" +from unittest import TestCase +from mock import MagicMock, patch + +from PyQt4 import QtGui + +from openlp.core.lib import Registry +from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm + + +class TestEditCustomSlideForm(TestCase): + """ + Test the EditCustomSlideForm. + """ + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.app = QtGui.QApplication([]) + self.main_window = QtGui.QMainWindow() + Registry().register(u'main_window', self.main_window) + self.form = EditCustomSlideForm() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.form + del self.main_window + del self.app + + def basic_test(self): + """ + Test if the dialog is correctly set up. + """ + # GIVEN: A mocked QDialog.exec_() method + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # WHEN: Show the dialog. + self.form.exec_() + + # THEN: The dialog should be empty. + assert self.form.slide_text_edit.toPlainText() == u'', u'There should not be any text in the text editor.' + + + def set_text_test(self): + """ + Test the set_text() method. + """ + # GIVEN: A mocked QDialog.exec_() method + with patch(u'PyQt4.QtGui.QDialog.exec_') as mocked_exec: + mocked_set_focus = MagicMock() + self.form.slide_text_edit.setFocus = mocked_set_focus + wanted_text = u'THIS TEXT SHOULD BE SHOWN.' + + # WHEN: Show the dialog and set the text. + self.form.exec_() + self.form.set_text(wanted_text) + + # THEN: The dialog should show the text. + assert self.form.slide_text_edit.toPlainText() == wanted_text, \ + u'The text editor should show the correct text.' + + # THEN: The dialog should have focus. + mocked_set_focus.assert_called_with() + From a0bdbd55bef74ff29d15b8701a11315d98a65f25 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 30 Mar 2013 16:39:20 +0100 Subject: [PATCH 3/3] removed obsolete line --- .../openlp_plugins/custom/forms/test_customslideform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py index 26da9afa6..7108db7ee 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -44,7 +44,6 @@ class TestEditCustomSlideForm(TestCase): # THEN: The dialog should be empty. assert self.form.slide_text_edit.toPlainText() == u'', u'There should not be any text in the text editor.' - def set_text_test(self): """ Test the set_text() method.