From 5d648f80c6e680a9eec6719dc5bb19d27d581dea Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Tue, 17 Sep 2013 20:23:45 +0400 Subject: [PATCH 1/7] fixed transparent display for OS X Fixes: https://launchpad.net/bugs/1117098 --- openlp/core/ui/maindisplay.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f2c1033ed..5c19e10c8 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -167,8 +167,10 @@ class MainDisplay(Display): """ if enabled: self.setAutoFillBackground(False) + self.setStyleSheet("QGraphicsView {background: transparent;}") else: self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) + self.setStyleSheet("QGraphicsView {background: white;}") self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) self.repaint() From 1ff6f5fe205e16928896d66702a5e980b698586a Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Wed, 18 Sep 2013 10:48:25 +0400 Subject: [PATCH 2/7] Removes border, but not affects to OSX border and shadow --- openlp/core/ui/maindisplay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 5c19e10c8..0a3f48152 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -167,10 +167,10 @@ class MainDisplay(Display): """ if enabled: self.setAutoFillBackground(False) - self.setStyleSheet("QGraphicsView {background: transparent;}") + self.setStyleSheet("QGraphicsView {background: transparent; border: 0px;}") else: self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False) - self.setStyleSheet("QGraphicsView {background: white;}") + self.setStyleSheet("QGraphicsView {}") self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) self.repaint() From 3c246f2d2eb5931a6ec5bd56ff661236344c63aa Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 11 Oct 2013 19:48:14 +0400 Subject: [PATCH 3/7] some start --- .../openlp_core_ui/test_maindisplay.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_maindisplay.py diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py new file mode 100644 index 000000000..c869afc7f --- /dev/null +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 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, Dmitriy Marmyshev # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +Package to test the openlp.core.lib.maindisplay package. +""" +from unittest import TestCase + +from mock import MagicMock + +from openlp.core.ui.maindisplay import MainDisplay + + +class TestMainDisplay(TestCase): + """ + Test the functions in the :mod:`MainDisplay` module. + """ + #TODO: The following classes still need tests written for + # - Display + # - MainDisplay + # - AudioPlayer + + def setUp(self): + self.main_dispaly_patcher = patch('openlp.core.ui.maindisplay.MainDisplay') + self.mocked_main_dispaly = self.main_dispaly_patcher.start() + self.mocked_main_dispaly.__init__() + + #.setAutoFillBackground, .setStyleSheet, .setAttribute, .repaint + + + def tearDown(self): + self.main_dispaly_patcher.stop() + + + + def set_transparency_enable_test(self): + """ + Test creating an instance of the MainDisplay class + """ + # GIVEN: Reset mocks: MainDisplay.__init__, MainDisplay.setAutoFillBackground, etc. And an instance of MainDisplay + #self.mocked_main_dispaly.__init__() + + # WHEN: MainDispaly.set_transparency is called with a true value" + self.mocked_main_dispaly.set_transparency(True) + + # THEN: MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, + # MainDisplay.repaint should have been called with known values" + assert self.mocked_main_dispaly.StyleSheet != "QGraphicsView {background: transparent; border: 0px;}", \ + 'MainDisplay instance should be transparent' From 77f1878ff59c0075f0af307bd1ce1b83b4aa5612 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Thu, 24 Oct 2013 22:12:41 +0400 Subject: [PATCH 4/7] Tests for transparency --- .../openlp_core_ui/test_maindisplay.py | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index c869afc7f..1fb07615a 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -45,30 +45,40 @@ class TestMainDisplay(TestCase): # - MainDisplay # - AudioPlayer - def setUp(self): - self.main_dispaly_patcher = patch('openlp.core.ui.maindisplay.MainDisplay') - self.mocked_main_dispaly = self.main_dispaly_patcher.start() - self.mocked_main_dispaly.__init__() - - #.setAutoFillBackground, .setStyleSheet, .setAttribute, .repaint - - - def tearDown(self): - self.main_dispaly_patcher.stop() - - def set_transparency_enable_test(self): """ Test creating an instance of the MainDisplay class """ - # GIVEN: Reset mocks: MainDisplay.__init__, MainDisplay.setAutoFillBackground, etc. And an instance of MainDisplay - #self.mocked_main_dispaly.__init__() + # GIVEN: get an instance of MainDisplay + display = MagicMock() + main_dispaly = MainDisplay(display) # WHEN: MainDispaly.set_transparency is called with a true value" - self.mocked_main_dispaly.set_transparency(True) + main_dispaly.set_transparency(True) - # THEN: MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - # MainDisplay.repaint should have been called with known values" - assert self.mocked_main_dispaly.StyleSheet != "QGraphicsView {background: transparent; border: 0px;}", \ + # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, + assert main_dispaly.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \ 'MainDisplay instance should be transparent' + assert main_dispaly.getAutoFillBackground == False, \ + 'MainDisplay instance should be without background auto fill' + assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ + 'MainDisplay hasnt translusent background' + + def set_transparency_disable_test(self): + """ + Test creating an instance of the MainDisplay class + """ + # GIVEN: get an instance of MainDisplay + display = MagicMock() + main_dispaly = MainDisplay(display) + + # WHEN: MainDispaly.set_transparency is called with a False value" + main_dispaly.set_transparency(False) + + # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, + assert main_dispaly.StyleSheet == "QGraphicsView {}", \ + 'MainDisplay instance should not be transparent' + assert main_dispaly.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill' + assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ + 'MainDisplay hasnt translusent background' From aed25c0f0bb70003dfa9d58a7394fab533b53197 Mon Sep 17 00:00:00 2001 From: Dmitriy Marmyshev Date: Fri, 25 Oct 2013 00:24:58 +0400 Subject: [PATCH 5/7] fixes --- .../openlp_core_ui/test_maindisplay.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 1fb07615a..7a0dcb8ac 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -32,6 +32,7 @@ Package to test the openlp.core.lib.maindisplay package. from unittest import TestCase from mock import MagicMock +from PyQt4 import QtCore from openlp.core.ui.maindisplay import MainDisplay @@ -52,17 +53,17 @@ class TestMainDisplay(TestCase): """ # GIVEN: get an instance of MainDisplay display = MagicMock() - main_dispaly = MainDisplay(display) + main_display = MainDisplay(display) - # WHEN: MainDispaly.set_transparency is called with a true value" - main_dispaly.set_transparency(True) + # WHEN: MainDisplay.set_transparency is called with a true value" + main_display.set_transparency(True) # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_dispaly.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \ + assert main_display.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \ 'MainDisplay instance should be transparent' - assert main_dispaly.getAutoFillBackground == False, \ + assert main_display.getAutoFillBackground == False, \ 'MainDisplay instance should be without background auto fill' - assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ + assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ 'MainDisplay hasnt translusent background' def set_transparency_disable_test(self): @@ -71,14 +72,14 @@ class TestMainDisplay(TestCase): """ # GIVEN: get an instance of MainDisplay display = MagicMock() - main_dispaly = MainDisplay(display) + main_display = MainDisplay(display) # WHEN: MainDispaly.set_transparency is called with a False value" - main_dispaly.set_transparency(False) + main_display.set_transparency(False) # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_dispaly.StyleSheet == "QGraphicsView {}", \ + assert main_display.StyleSheet == "QGraphicsView {}", \ 'MainDisplay instance should not be transparent' - assert main_dispaly.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill' - assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ + assert main_display.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill' + assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ 'MainDisplay hasnt translusent background' From 791fdba019ebeb792e1ecd8a492c2c26730dab8a Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 17:15:46 +0200 Subject: [PATCH 6/7] Fix test --- .../openlp_core_ui/test_maindisplay.py | 37 +++----- .../openlp_core_ui/test_maindisplay.py.moved | 85 ------------------- 2 files changed, 14 insertions(+), 108 deletions(-) delete mode 100644 tests/functional/openlp_core_ui/test_maindisplay.py.moved diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 48f05978c..fb6b1f0f3 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -88,31 +88,22 @@ class TestMainDisplay(TestCase): display = MagicMock() main_display = MainDisplay(display) - # WHEN: MainDisplay.set_transparency is called with a true value" + # WHEN: We enable transparency main_display.set_transparency(True) - # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_display.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \ - 'MainDisplay instance should be transparent' - assert main_display.getAutoFillBackground == False, \ - 'MainDisplay instance should be without background auto fill' - assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ - 'MainDisplay hasnt translusent background' + # THEN: There should be a Stylesheet + self.assertEqual('QGraphicsView {background: transparent; border: 0px;}', main_display.styleSheet(), + 'MainDisplay instance should be transparent') + self.assertFalse(main_display.autoFillBackground(), + 'MainDisplay instance should be without background auto fill') + self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), + 'MainDisplay hasnt translucent background') - def set_transparency_disable_test(self): - """ - Test creating an instance of the MainDisplay class - """ - # GIVEN: get an instance of MainDisplay - display = MagicMock() - main_display = MainDisplay(display) - - # WHEN: MainDisplay.set_transparency is called with a False value" + # WHEN: We disable transparency main_display.set_transparency(False) - # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_display.StyleSheet == "QGraphicsView {}", \ - 'MainDisplay instance should not be transparent' - assert main_display.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill' - assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ - 'MainDisplay hasnt translusent background' + # THEN: The Stylesheet should be empty + self.assertEqual('QGraphicsView {}', main_display.styleSheet(), + 'MainDisplay instance should not be transparent') + self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground), + 'MainDisplay hasnt translucent background') diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py.moved b/tests/functional/openlp_core_ui/test_maindisplay.py.moved deleted file mode 100644 index 0a1f85d5f..000000000 --- a/tests/functional/openlp_core_ui/test_maindisplay.py.moved +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 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, Dmitriy Marmyshev # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### -""" -Package to test the openlp.core.lib.maindisplay package. -""" -from unittest import TestCase - -from tests.functional import MagicMock -from PyQt4 import QtCore - -from openlp.core.ui.maindisplay import MainDisplay - - -class TestMainDisplay(TestCase): - """ - Test the functions in the :mod:`MainDisplay` module. - """ - #TODO: The following classes still need tests written for - # - Display - # - MainDisplay - # - AudioPlayer - - - def set_transparency_enable_test(self): - """ - Test creating an instance of the MainDisplay class - """ - # GIVEN: get an instance of MainDisplay - display = MagicMock() - main_display = MainDisplay(display) - - # WHEN: MainDisplay.set_transparency is called with a true value" - main_display.set_transparency(True) - - # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_display.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \ - 'MainDisplay instance should be transparent' - assert main_display.getAutoFillBackground == False, \ - 'MainDisplay instance should be without background auto fill' - assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ - 'MainDisplay hasnt translusent background' - - def set_transparency_disable_test(self): - """ - Test creating an instance of the MainDisplay class - """ - # GIVEN: get an instance of MainDisplay - display = MagicMock() - main_display = MainDisplay(display) - - # WHEN: MainDispaly.set_transparency is called with a False value" - main_display.set_transparency(False) - - # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, - assert main_display.StyleSheet == "QGraphicsView {}", \ - 'MainDisplay instance should not be transparent' - assert main_display.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill' - assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \ - 'MainDisplay hasnt translusent background' From 129f726d4cf297659045cae5ffe7750abe8b879d Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 17:23:40 +0200 Subject: [PATCH 7/7] Rename method --- tests/functional/openlp_core_ui/test_maindisplay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index fb6b1f0f3..b1a4dc7f7 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -80,7 +80,7 @@ class TestMainDisplay(TestCase): # 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_enable_test(self): + def set_transparency_test(self): """ Test creating an instance of the MainDisplay class """