From 837013763a35662489fdd5ba1486ff59509b3034 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Nov 2014 07:47:26 +0000 Subject: [PATCH 1/3] fix focus --- openlp/core/ui/slidecontroller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1b8b45815..d12506452 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -851,6 +851,7 @@ class SlideController(DisplayController, RegistryProperties): if service_item.is_media(): self.on_media_start(service_item) self.slide_selected(True) + self.preview_widget.setFocus() if old_item: # Close the old item after the new one is opened # This avoids the service theme/desktop flashing on screen From 6323f8bba70f1d04a6438597915ba02ff39969ea Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Nov 2014 10:59:45 +0000 Subject: [PATCH 2/3] Add tests --- .../openlp_plugins/images/test_imagetab.py | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/functional/openlp_plugins/images/test_imagetab.py diff --git a/tests/functional/openlp_plugins/images/test_imagetab.py b/tests/functional/openlp_plugins/images/test_imagetab.py new file mode 100644 index 000000000..7d6ef10ff --- /dev/null +++ b/tests/functional/openlp_plugins/images/test_imagetab.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +This module contains tests for the lib submodule of the Images plugin. +""" +from unittest import TestCase +from PyQt4 import QtGui + +from openlp.core.common import Settings + +from openlp.core.common import Registry +from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups +from openlp.plugins.images.lib.mediaitem import ImageMediaItem +from openlp.plugins.images.lib import ImageTab +from tests.functional import MagicMock, patch +from tests.helpers.testmixin import TestMixin + +__default_settings__ = { + 'images/db type': 'sqlite', + 'images/background color': '#000000', +} + + +class TestImageMediaItem(TestCase, TestMixin): + """ + This is a test case to test various methods in the ImageTab. + """ + + def setUp(self): + """ + Create the UI + """ + Registry.create() + Registry().register('settings_form', MagicMock()) + self.setup_application() + self.build_settings() + Settings().extend_default_settings(__default_settings__) + self.parent = QtGui.QMainWindow() + self.form = ImageTab(self.parent, 'Images', None, None) + self.form.settings_form.register_post_process = MagicMock() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.parent + del self.form + self.destroy_settings() + + def save_tab_nochange_test_test(self): + """ + Test no changes does not trigger post processing + """ + # GIVEN: No changes on the form. + self.initial_color = '#999999' + # WHEN: the save is invoked + self.form.save() + #THEN: the post process should not be requested + self.assertEqual(0, self.form.settings_form.register_post_process.call_count, + 'Image Post processing should not have been requested') + + def save_tab_change_test_test(self): + """ + Test a change triggers post processing. + """ + # GIVEN: Apply a change to the form. + self.form.background_color = '#999999' + # WHEN: the save is invoked + self.form.save() + #THEN: the post process should be requested + self.assertEqual(1, self.form.settings_form.register_post_process.call_count, + 'Image Post processing should have been requested') \ No newline at end of file From b20b114a7b962890910cb11bb9d4e6ca6292d314 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 1 Nov 2014 11:06:17 +0000 Subject: [PATCH 3/3] test fix --- tests/functional/openlp_plugins/images/test_imagetab.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/images/test_imagetab.py b/tests/functional/openlp_plugins/images/test_imagetab.py index 7d6ef10ff..fade284a4 100644 --- a/tests/functional/openlp_plugins/images/test_imagetab.py +++ b/tests/functional/openlp_plugins/images/test_imagetab.py @@ -81,7 +81,7 @@ class TestImageMediaItem(TestCase, TestMixin): self.initial_color = '#999999' # WHEN: the save is invoked self.form.save() - #THEN: the post process should not be requested + # THEN: the post process should not be requested self.assertEqual(0, self.form.settings_form.register_post_process.call_count, 'Image Post processing should not have been requested') @@ -93,6 +93,6 @@ class TestImageMediaItem(TestCase, TestMixin): self.form.background_color = '#999999' # WHEN: the save is invoked self.form.save() - #THEN: the post process should be requested + # THEN: the post process should be requested self.assertEqual(1, self.form.settings_form.register_post_process.call_count, 'Image Post processing should have been requested') \ No newline at end of file