← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-1314469 into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-1314469 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1314469 in OpenLP: "Glow/Border on KDE in openSUSE 13.1 with Oxygen Theme"
  https://bugs.launchpad.net/openlp/+bug/1314469

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-1314469/+merge/246062

[bug 1314469] Fix the border seen in the main display on KDE by not overwriting that bit of the stylesheet

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/bug-1314469 (revision 2460)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/859/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/791/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/737/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/641/
Stopping after failure
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-1314469 into lp:openlp.
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2014-12-31 10:58:13 +0000
+++ openlp/core/ui/maindisplay.py	2015-01-11 15:24:19 +0000
@@ -38,20 +38,37 @@
 
 import cgi
 import logging
-import sys
 
 from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
 from PyQt4.phonon import Phonon
 
 from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx
-from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte
+from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte
 from openlp.core.lib.theme import BackgroundType
-
-from openlp.core.lib import ScreenList
 from openlp.core.ui import HideMode, AlertLocation
 
 log = logging.getLogger(__name__)
 
+OPAQUE_STYLESHEET = """
+QWidget {
+    border: 0px;
+    margin: 0px;
+    padding: 0px;
+}
+QGraphicsView {}
+"""
+TRANSPARENT_STYLESHEET = """
+QWidget {
+    border: 0px;
+    margin: 0px;
+    padding: 0px;
+}
+QGraphicsView {
+    background: transparent;
+    border: 0px;
+}
+"""
+
 
 class Display(QtGui.QGraphicsView):
     """
@@ -135,7 +152,7 @@
             self.audio_player = None
         self.first_time = True
         self.web_loaded = True
-        self.setStyleSheet('border: 0px; margin: 0px; padding: 0px;')
+        self.setStyleSheet(OPAQUE_STYLESHEET)
         window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint
         if Settings().value('advanced/x11 bypass wm'):
             window_flags |= QtCore.Qt.X11BypassWindowManagerHint
@@ -175,10 +192,10 @@
         """
         if enabled:
             self.setAutoFillBackground(False)
-            self.setStyleSheet("QGraphicsView {background: transparent; border: 0px;}")
+            self.setStyleSheet(TRANSPARENT_STYLESHEET)
         else:
             self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
-            self.setStyleSheet("QGraphicsView {}")
+            self.setStyleSheet(OPAQUE_STYLESHEET)
         self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled)
         self.repaint()
 

=== modified file 'tests/functional/openlp_core_ui/test_maindisplay.py'
--- tests/functional/openlp_core_ui/test_maindisplay.py	2014-12-31 10:58:13 +0000
+++ tests/functional/openlp_core_ui/test_maindisplay.py	2015-01-11 15:24:19 +0000
@@ -36,8 +36,10 @@
 from openlp.core.common import Registry
 from openlp.core.lib import ScreenList
 from openlp.core.ui import MainDisplay
+from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET
 
-from tests.interfaces import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
+from tests.interfaces import MagicMock
 
 SCREEN = {
     'primary': False,
@@ -46,7 +48,7 @@
 }
 
 
-class TestMainDisplay(TestCase):
+class TestMainDisplay(TestCase, TestMixin):
 
     def setUp(self):
         """
@@ -59,6 +61,9 @@
         self.desktop.screenGeometry.return_value = SCREEN['size']
         self.screens = ScreenList.create(self.desktop)
         Registry.create()
+        self.registry = Registry()
+        self.setup_application()
+        Registry().register('application', self.app)
 
     def tearDown(self):
         """
@@ -80,30 +85,60 @@
         # THEN: The controller should not be a live controller.
         self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
 
-    def set_transparency_test(self):
-        """
-        Test creating an instance of the MainDisplay class
-        """
-        # GIVEN: get an instance of MainDisplay
+    def set_transparency_enabled_test(self):
+        """
+        Test setting the display to be transparent
+        """
+        # GIVEN: An instance of MainDisplay
         display = MagicMock()
         main_display = MainDisplay(display)
 
-        # WHEN: We enable transparency
+        # WHEN: Transparency is enabled
         main_display.set_transparency(True)
 
-        # THEN: There should be a Stylesheet
-        self.assertEqual('QGraphicsView {background: transparent; border: 0px;}', main_display.styleSheet(),
-                         'MainDisplay instance should be transparent')
+        # THEN: The transparent stylesheet should be used
+        self.assertEqual(TRANSPARENT_STYLESHEET, main_display.styleSheet(),
+                         'The MainDisplay should use the transparent stylesheet')
         self.assertFalse(main_display.autoFillBackground(),
-                         'MainDisplay instance should be without background auto fill')
+                         'The MainDisplay should not have autoFillBackground set')
         self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
-                        'MainDisplay hasnt translucent background')
-
-        # WHEN: We disable transparency
+                        'The MainDisplay should have a translucent background')
+
+    def set_transparency_disabled_test(self):
+        """
+        Test setting the display to be opaque
+        """
+        # GIVEN: An instance of MainDisplay
+        display = MagicMock()
+        main_display = MainDisplay(display)
+
+        # WHEN: Transparency is disabled
         main_display.set_transparency(False)
 
-        # THEN: The Stylesheet should be empty
-        self.assertEqual('QGraphicsView {}', main_display.styleSheet(),
-                         'MainDisplay instance should not be transparent')
+        # THEN: The opaque stylesheet should be used
+        self.assertEqual(OPAQUE_STYLESHEET, main_display.styleSheet(),
+                         'The MainDisplay should use the opaque stylesheet')
         self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
-                         'MainDisplay hasnt translucent background')
+                         'The MainDisplay should not have a translucent background')
+
+    def css_changed_test(self):
+        """
+        Test that when the CSS changes, the plugins are looped over and given an opportunity to update the CSS
+        """
+        # GIVEN: A mocked list of plugins, a mocked display and a MainDisplay
+        mocked_songs_plugin = MagicMock()
+        mocked_bibles_plugin = MagicMock()
+        mocked_plugin_manager = MagicMock()
+        mocked_plugin_manager.plugins = [mocked_songs_plugin, mocked_bibles_plugin]
+        Registry().register('plugin_manager', mocked_plugin_manager)
+        display = MagicMock()
+        main_display = MainDisplay(display)
+        # This is set up dynamically, so we need to mock it out for now
+        main_display.frame = MagicMock()
+
+        # WHEN: The css_changed() method is triggered
+        main_display.css_changed()
+
+        # THEN: The plugins should have each been given an opportunity to add their bit to the CSS
+        mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame)
+        mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)

=== modified file 'tests/functional/openlp_core_ui/test_mainwindow.py'
--- tests/functional/openlp_core_ui/test_mainwindow.py	2014-12-31 10:58:13 +0000
+++ tests/functional/openlp_core_ui/test_mainwindow.py	2015-01-11 15:24:19 +0000
@@ -36,9 +36,10 @@
 from openlp.core.ui.mainwindow import MainWindow
 from openlp.core.lib.ui import UiStrings
 from openlp.core.common.registry import Registry
+
+from tests.functional import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
 from tests.utils.constants import TEST_RESOURCES_PATH
-from tests.helpers.testmixin import TestMixin
-from tests.functional import MagicMock, patch
 
 
 class TestMainWindow(TestCase, TestMixin):

=== modified file 'tests/functional/openlp_core_ui/test_themeform.py'
--- tests/functional/openlp_core_ui/test_themeform.py	2015-01-09 19:51:39 +0000
+++ tests/functional/openlp_core_ui/test_themeform.py	2015-01-11 15:24:19 +0000
@@ -34,7 +34,7 @@
 
 from openlp.core.ui import ThemeForm
 
-from tests.interfaces import MagicMock, patch
+from tests.functional import MagicMock, patch
 
 
 class TestThemeManager(TestCase):

=== modified file 'tests/interfaces/openlp_core_common/test_historycombobox.py'
--- tests/interfaces/openlp_core_common/test_historycombobox.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_common/test_historycombobox.py	2015-01-11 15:24:19 +0000
@@ -42,6 +42,9 @@
 
 class TestHistoryComboBox(TestCase, TestMixin):
     def setUp(self):
+        """
+        Some pre-test setup required.
+        """
         Registry.create()
         self.setup_application()
         self.main_window = QtGui.QMainWindow()
@@ -49,9 +52,13 @@
         self.combo = HistoryComboBox(self.main_window)
 
     def tearDown(self):
+        """
+        Delete all the C++ objects at the end so that we don't have a segfault
+        """
         del self.combo
+        del self.main_window
 
-    def getItems_test(self):
+    def get_items_test(self):
         """
         Test the getItems() method
         """

=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
--- tests/interfaces/openlp_core_lib/test_pluginmanager.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py	2015-01-11 15:24:19 +0000
@@ -63,9 +63,9 @@
         Registry().register('main_window', self.main_window)
 
     def tearDown(self):
-        del self.main_window
         Settings().remove('advanced/data path')
         self.destroy_settings()
+        del self.main_window
         # On windows we need to manually garbage collect to close sqlalchemy files
         # to avoid errors when temporary files are deleted.
         gc.collect()
@@ -86,12 +86,12 @@
 
         # THEN: We should find the "Songs", "Bibles", etc in the plugins list
         plugin_names = [plugin.name for plugin in plugin_manager.plugins]
-        assert 'songs' in plugin_names, 'There should be a "songs" plugin.'
-        assert 'bibles' in plugin_names, 'There should be a "bibles" plugin.'
-        assert 'presentations' in plugin_names, 'There should be a "presentations" plugin.'
-        assert 'images' in plugin_names, 'There should be a "images" plugin.'
-        assert 'media' in plugin_names, 'There should be a "media" plugin.'
-        assert 'custom' in plugin_names, 'There should be a "custom" plugin.'
-        assert 'songusage' in plugin_names, 'There should be a "songusage" plugin.'
-        assert 'alerts' in plugin_names, 'There should be a "alerts" plugin.'
-        assert 'remotes' in plugin_names, 'There should be a "remotes" plugin.'
+        self.assertIn('songs', plugin_names, 'There should be a "songs" plugin')
+        self.assertIn('bibles', plugin_names, 'There should be a "bibles" plugin')
+        self.assertIn('presentations', plugin_names, 'There should be a "presentations" plugin')
+        self.assertIn('images', plugin_names, 'There should be a "images" plugin')
+        self.assertIn('media', plugin_names, 'There should be a "media" plugin')
+        self.assertIn('custom', plugin_names, 'There should be a "custom" plugin')
+        self.assertIn('songusage', plugin_names, 'There should be a "songusage" plugin')
+        self.assertIn('alerts', plugin_names, 'There should be a "alerts" plugin')
+        self.assertIn('remotes', plugin_names, 'There should be a "remotes" plugin')

=== modified file 'tests/interfaces/openlp_core_lib/test_searchedit.py'
--- tests/interfaces/openlp_core_lib/test_searchedit.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_lib/test_searchedit.py	2015-01-11 15:24:19 +0000
@@ -35,10 +35,14 @@
 
 from openlp.core.common import Registry
 from openlp.core.lib.searchedit import SearchEdit
+
 from tests.helpers.testmixin import TestMixin
 
 
 class SearchTypes(object):
+    """
+    Types of search
+    """
     First = 0
     Second = 1
 
@@ -69,6 +73,7 @@
         """
         Delete all the C++ objects at the end so that we don't have a segfault
         """
+        del self.search_edit
         del self.main_window
 
     def set_search_types_test(self):

=== modified file 'tests/interfaces/openlp_core_ui/__init__.py'
--- tests/interfaces/openlp_core_ui/__init__.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_ui/__init__.py	2015-01-11 15:24:19 +0000
@@ -31,14 +31,17 @@
 """
 
 import os
+
+from openlp.core.common import is_win
+
 from tests.interfaces import patch
-
-from openlp.core.common import is_win
-
 from .test_projectormanager import tmpfile
 
 
 def setUp():
+    """
+    Set up this module of tests
+    """
     if not is_win():
         # Wine creates a sharing violation during tests. Ignore.
         try:

=== modified file 'tests/interfaces/openlp_core_ui/test_projectormanager.py'
--- tests/interfaces/openlp_core_ui/test_projectormanager.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_ui/test_projectormanager.py	2015-01-11 15:24:19 +0000
@@ -70,8 +70,8 @@
         Delete all the C++ objects at the end so that we don't have a segfault.
         """
         self.projectordb.session.close()
+        self.destroy_settings()
         del self.projector_manager
-        self.destroy_settings()
 
     def bootstrap_initialise_test(self):
         """

=== modified file 'tests/interfaces/openlp_core_ui/test_thememanager.py'
--- tests/interfaces/openlp_core_ui/test_thememanager.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_core_ui/test_thememanager.py	2015-01-11 15:24:19 +0000
@@ -54,8 +54,8 @@
         """
         Delete all the C++ objects at the end so that we don't have a segfault
         """
-
         self.destroy_settings()
+        del self.theme_manager
 
     def initialise_test(self):
         """

=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_manager.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_manager.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_manager.py	2015-01-11 15:24:19 +0000
@@ -73,6 +73,7 @@
         """
         Delete all the C++ objects at the end so that we don't have a segfault
         """
+        del self.manager
         self.destroy_settings()
 
     def get_books_test(self):

=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py	2015-01-11 15:24:19 +0000
@@ -73,6 +73,7 @@
         """
         Delete all the C++ objects at the end so that we don't have a segfault
         """
+        del self.manager
         self.destroy_settings()
 
     def parse_reference_one_test(self):

=== modified file 'tests/interfaces/openlp_plugins/custom/forms/test_customform.py'
--- tests/interfaces/openlp_plugins/custom/forms/test_customform.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_plugins/custom/forms/test_customform.py	2015-01-11 15:24:19 +0000
@@ -34,7 +34,7 @@
 from PyQt4 import QtGui, QtTest, QtCore
 
 from openlp.core.common import Registry
-# Import needed due to import problems.
+# TODO: FIXME: Import needed due to horrible bad imports
 from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
 from openlp.plugins.custom.forms.editcustomform import EditCustomForm
 from tests.interfaces import MagicMock, patch

=== modified file 'tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py'
--- tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py	2014-12-31 10:58:13 +0000
+++ tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py	2015-01-11 15:24:19 +0000
@@ -76,8 +76,8 @@
         """
         Delete all the C++ objects at the end so that we don't have a segfault
         """
+        del self.form
         self.vlc_patcher.stop()
-        del self.form
         del self.main_window
 
     def basic_test(self):


References