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

Proposed by Dmitriy Marmyshev
Status: Rejected
Rejected by: Andreas Preikschat
Proposed branch: lp:~marmyshev/openlp/bug_1117098
Merge into: lp:openlp
Diff against target: 104 lines (+87/-0)
2 files modified
openlp/core/ui/maindisplay.py (+2/-0)
tests/functional/openlp_core_ui/test_maindisplay.py (+85/-0)
To merge this branch: bzr merge lp:~marmyshev/openlp/bug_1117098
Reviewer Review Type Date Requested Status
Andreas Preikschat (community) Needs Resubmitting
Raoul Snyman Needs Fixing
Jonathan Corwin Pending
Tim Bentley Pending
Review via email: mp+192797@code.launchpad.net

This proposal supersedes 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) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

sorry, you need to write a test

review: Needs Fixing
Revision history for this message
Jonathan Corwin (j-corwin) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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

Revision history for this message
Phill (phill-ridout) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

This now works fine on Windows

Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

main_dispaly !!!!

review: Needs Fixing
Revision history for this message
Dmitriy Marmyshev (marmyshev) wrote : Posted in a previous version of this proposal

haha :)) fast typing.

On Thu, Oct 24, 2013 at 11:57 PM, Tim Bentley <email address hidden> wrote:

> Review: Needs Fixing
>
> main_dispaly !!!!
> --
> https://code.launchpad.net/~marmyshev/openlp/bug_1117098/+merge/192565
> You are the owner of lp:~marmyshev/openlp/bug_1117098.
>

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Please merge trunk, and fix your test to match the way the others import mock.

http://ci.openlp.org/view/Branch/job/Branch-02-Functional-Tests/7/console

review: Needs Fixing
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

There are still 3 tests in your branch which are failing.

http://ci.openlp.org/view/Branch/job/Branch-02-Functional-Tests/9/console

review: Needs Fixing
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) wrote :

Hello,

If you are going to work on this, please execute these commands:

 bzr tag "2.2.2" --delete
 bzr tag "help" --delete

But for now, I am setting this to rejected

Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) :
review: Needs Resubmitting

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-26 22:57:50 +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-26 22:57:50 +0000
19@@ -0,0 +1,85 @@
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 tests.functional import MagicMock
54+from PyQt4 import QtCore
55+
56+from openlp.core.ui.maindisplay import MainDisplay
57+
58+
59+class TestMainDisplay(TestCase):
60+ """
61+ Test the functions in the :mod:`MainDisplay` module.
62+ """
63+ #TODO: The following classes still need tests written for
64+ # - Display
65+ # - MainDisplay
66+ # - AudioPlayer
67+
68+
69+ def set_transparency_enable_test(self):
70+ """
71+ Test creating an instance of the MainDisplay class
72+ """
73+ # GIVEN: get an instance of MainDisplay
74+ display = MagicMock()
75+ main_display = MainDisplay(display)
76+
77+ # WHEN: MainDisplay.set_transparency is called with a true value"
78+ main_display.set_transparency(True)
79+
80+ # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute,
81+ assert main_display.StyleSheet == "QGraphicsView {background: transparent; border: 0px;}", \
82+ 'MainDisplay instance should be transparent'
83+ assert main_display.getAutoFillBackground == False, \
84+ 'MainDisplay instance should be without background auto fill'
85+ assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \
86+ 'MainDisplay hasnt translusent background'
87+
88+ def set_transparency_disable_test(self):
89+ """
90+ Test creating an instance of the MainDisplay class
91+ """
92+ # GIVEN: get an instance of MainDisplay
93+ display = MagicMock()
94+ main_display = MainDisplay(display)
95+
96+ # WHEN: MainDispaly.set_transparency is called with a False value"
97+ main_display.set_transparency(False)
98+
99+ # THEN: check MainDisplay.setAutoFillBackground, MainDisplay.setStyleSheet, MainDisplay.setAttribute,
100+ assert main_display.StyleSheet == "QGraphicsView {}", \
101+ 'MainDisplay instance should not be transparent'
102+ assert main_display.getAutoFillBackground == True, 'MainDisplay instance should be with background auto fill'
103+ assert main_display.getAttribute(QtCore.Qt.WA_TranslucentBackground) == True, \
104+ 'MainDisplay hasnt translusent background'