Merge lp:~marmyshev/openlp/bug_1117098 into lp:openlp

Proposed by Dmitriy Marmyshev
Status: Superseded
Proposed branch: lp:~marmyshev/openlp/bug_1117098
Merge into: lp:openlp
Diff against target: 103 lines (+86/-0)
2 files modified
openlp/core/ui/maindisplay.py (+2/-0)
tests/functional/openlp_core_ui/test_maindisplay.py (+84/-0)
To merge this branch: bzr merge lp:~marmyshev/openlp/bug_1117098
Reviewer Review Type Date Requested Status
Jonathan Corwin (community) Needs Fixing
Raoul Snyman Needs Fixing
Review via email: mp+186095@code.launchpad.net

This proposal has been superseded by a proposal from 2013-10-24.

Description of the change

Fixed transparent display on OS X

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

sorry, you need to write a test

review: Needs Fixing
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

This causes a 1 pixel white border to appear around the transparent display screen on Windows.

review: Needs Fixing
Revision history for this message
Dmitriy Marmyshev (marmyshev) wrote :

Raoul, can you help me wiht writing test for this? Because I dont know how to test it.

lp:~marmyshev/openlp/bug_1117098 updated
2300. By Dmitriy Marmyshev

Removes border, but not affects to OSX border and shadow

Revision history for this message
Phill (phill-ridout) wrote :

Dmitriy,

http://wiki.openlp.org/Development:Unit_Tests should be of some help.

A good example to follow would be http://bazaar.launchpad.net/~openlp-core/openlp/trunk/view/head:/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py

The encoding_declaration_removal_test method is probably similar to what you want to achieve (if a little more basic)

This is probably a nice easy one to start on. We're going to test the function you modified. (set_transparency )There is not any tests written for this module yet, so you will need to create a new file /tests/functional/openlp_core_ui/test_maindisplay.py

In a #TODO: Make a list of all the classes and methods so that we know what needs doing still

Create a class call it "TestMainDisplay" and sub class from TestCase

Because this function has two paths (one if enabled is true and one if enabled is false) you will need to write two tests.

You might as well write a setUp and tearDown functions as these will be helpful when more tests are added. In the setUp you will need to patch and mock __init__ .setAutoFillBackground, .setStyleSheet, .setAttribute, .repaint

Create two test functions, I'd call it "test_set_transparency_enable" & "test_set_transparency_disable"

First thing you will need to do in each test function is write you #GIVEN so something like:
"#GIVEN: Reset mocks: MainDisplay.__init__, MainDisplay.setAutoFillBackground, etc. And an instance of MainDisplay
Now reset the mocks that we are going to check the calls on later and create an instance of MainDisplay

Now you need to write you #WHEN: so one will be like:
"#WHEN: MainDispaly.set_transparency is called with a true value"
So call result = instance.set_transparency(True)

Now write you #THEN:
"#THEN: MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute, MainDisplay.repaint should have been called with known values"
Now you will need to assert that your mocks have been called with the expected values so the mock for MainDisplay.setStyleSheet should be called with "QGraphicsView {background: transparent; border: 0px;}"

Hope this gives you a start.

Revision history for this message
Jonathan Corwin (j-corwin) wrote :

This now works fine on Windows

lp:~marmyshev/openlp/bug_1117098 updated
2301. By Dmitriy Marmyshev

some start

2302. By Dmitriy Marmyshev

Tests for transparency

2303. By Dmitriy Marmyshev

fixes

2304. By Dmitriy Marmyshev

Trunk & fixes

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/maindisplay.py'
2--- openlp/core/ui/maindisplay.py 2013-10-23 18:49:39 +0000
3+++ openlp/core/ui/maindisplay.py 2013-10-24 18:41:39 +0000
4@@ -167,8 +167,10 @@
5 """
6 if enabled:
7 self.setAutoFillBackground(False)
8+ self.setStyleSheet("QGraphicsView {background: transparent; border: 0px;}")
9 else:
10 self.setAttribute(QtCore.Qt.WA_NoSystemBackground, False)
11+ self.setStyleSheet("QGraphicsView {}")
12 self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled)
13 self.repaint()
14
15
16=== added file 'tests/functional/openlp_core_ui/test_maindisplay.py'
17--- tests/functional/openlp_core_ui/test_maindisplay.py 1970-01-01 00:00:00 +0000
18+++ tests/functional/openlp_core_ui/test_maindisplay.py 2013-10-24 18:41:39 +0000
19@@ -0,0 +1,84 @@
20+# -*- coding: utf-8 -*-
21+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
22+
23+###############################################################################
24+# OpenLP - Open Source Lyrics Projection #
25+# --------------------------------------------------------------------------- #
26+# Copyright (c) 2008-2013 Raoul Snyman #
27+# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
28+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
29+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
30+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
31+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
32+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
33+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann, Dmitriy Marmyshev #
34+# --------------------------------------------------------------------------- #
35+# This program is free software; you can redistribute it and/or modify it #
36+# under the terms of the GNU General Public License as published by the Free #
37+# Software Foundation; version 2 of the License. #
38+# #
39+# This program is distributed in the hope that it will be useful, but WITHOUT #
40+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
41+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
42+# more details. #
43+# #
44+# You should have received a copy of the GNU General Public License along #
45+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
46+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
47+###############################################################################
48+"""
49+Package to test the openlp.core.lib.maindisplay package.
50+"""
51+from unittest import TestCase
52+
53+from mock import MagicMock
54+
55+from openlp.core.ui.maindisplay import MainDisplay
56+
57+
58+class TestMainDisplay(TestCase):
59+ """
60+ Test the functions in the :mod:`MainDisplay` module.
61+ """
62+ #TODO: The following classes still need tests written for
63+ # - Display
64+ # - MainDisplay
65+ # - AudioPlayer
66+
67+
68+ def set_transparency_enable_test(self):
69+ """
70+ Test creating an instance of the MainDisplay class
71+ """
72+ # GIVEN: get an instance of MainDisplay
73+ display = MagicMock()
74+ main_dispaly = MainDisplay(display)
75+
76+ # WHEN: MainDispaly.set_transparency is called with a true value"
77+ main_dispaly.set_transparency(True)
78+
79+ # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute,
80+ assert main_dispaly.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \
81+ 'MainDisplay instance should be transparent'
82+ assert main_dispaly.getAutoFillBackground == False, \
83+ 'MainDisplay instance should be without background auto fill'
84+ assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \
85+ 'MainDisplay hasnt translusent background'
86+
87+ def set_transparency_disable_test(self):
88+ """
89+ Test creating an instance of the MainDisplay class
90+ """
91+ # GIVEN: get an instance of MainDisplay
92+ display = MagicMock()
93+ main_dispaly = MainDisplay(display)
94+
95+ # WHEN: MainDispaly.set_transparency is called with a False value"
96+ main_dispaly.set_transparency(False)
97+
98+ # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute,
99+ assert main_dispaly.StyleSheet == "QGraphicsView {}", \
100+ 'MainDisplay instance should not be transparent'
101+ assert main_dispaly.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill'
102+ assert main_dispaly.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \
103+ 'MainDisplay hasnt translusent background'