Merge lp:~springermac/openlp/bug-1395848 into lp:openlp

Proposed by Jonathan Springer
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2541
Merged at revision: 2538
Proposed branch: lp:~springermac/openlp/bug-1395848
Merge into: lp:openlp
Diff against target: 107 lines (+49/-13)
2 files modified
openlp/core/ui/maindisplay.py (+2/-0)
tests/functional/openlp_core_ui/test_maindisplay.py (+47/-13)
To merge this branch: bzr merge lp:~springermac/openlp/bug-1395848
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+260096@code.launchpad.net

This proposal supersedes a proposal from 2015-05-26.

Description of the change

Fix bug 1395848 by setting the WindowStaysOnTop window flag when the MainDisplay is not on the primary screen.

To post a comment you must log in.
Revision history for this message
Jonathan Springer (springermac) wrote : Posted in a previous version of this proposal

lp:~springermac/openlp/bug-1395848 (revision 2540)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1027/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/950/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/892/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/779/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/377/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/508/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/379/

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

Can these be two tests with two asserts instead of 4 tests with one assert?

Revision history for this message
Jonathan Springer (springermac) wrote :

lp:~springermac/openlp/bug-1395848 (revision 2541)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1028/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/951/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/893/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/780/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/378/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/509/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/380/

Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I'll need to test this out on Linux to make sure it doesn't mess with anything on there. Let's ask ElderP or tgc to test out on Windows.

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

Seems to work fine.

review: Approve

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 2015-04-02 20:32:20 +0000
3+++ openlp/core/ui/maindisplay.py 2015-05-26 04:55:20 +0000
4@@ -164,6 +164,8 @@
5 # and menu bar
6 if self.screens.current['primary']:
7 self.setWindowState(QtCore.Qt.WindowFullScreen)
8+ else:
9+ window_flags |= QtCore.Qt.WindowStaysOnTopHint
10 self.setWindowFlags(window_flags)
11 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
12 self.set_transparency(False)
13
14=== modified file 'tests/functional/openlp_core_ui/test_maindisplay.py'
15--- tests/functional/openlp_core_ui/test_maindisplay.py 2015-01-19 08:34:29 +0000
16+++ tests/functional/openlp_core_ui/test_maindisplay.py 2015-05-26 04:55:20 +0000
17@@ -34,12 +34,6 @@
18 from tests.helpers.testmixin import TestMixin
19 from tests.functional import MagicMock, patch
20
21-SCREEN = {
22- 'primary': False,
23- 'number': 1,
24- 'size': QtCore.QRect(0, 0, 1024, 768)
25-}
26-
27
28 class TestMainDisplay(TestCase, TestMixin):
29
30@@ -49,9 +43,10 @@
31 """
32 # Mocked out desktop object
33 self.desktop = MagicMock()
34- self.desktop.primaryScreen.return_value = SCREEN['primary']
35- self.desktop.screenCount.return_value = SCREEN['number']
36- self.desktop.screenGeometry.return_value = SCREEN['size']
37+ self.desktop.primaryScreen.return_value = 0
38+ self.desktop.screenCount.return_value = 2
39+ self.desktop.screenGeometry.side_effect = lambda x: {0: QtCore.QRect(0, 0, 1024, 768),
40+ 1: QtCore.QRect(0, 0, 1024, 768)}[x]
41 self.screens = ScreenList.create(self.desktop)
42 Registry.create()
43 self.registry = Registry()
44@@ -69,16 +64,16 @@
45
46 def initial_main_display_test(self):
47 """
48- Test the initial Main Display state .
49+ Test the initial Main Display state
50 """
51- # GIVEN: A new slideController instance.
52+ # GIVEN: A new SlideController instance.
53 display = MagicMock()
54 display.is_live = True
55
56- # WHEN: the default controller is built.
57+ # WHEN: The default controller is built.
58 main_display = MainDisplay(display)
59
60- # THEN: The controller should not be a live controller.
61+ # THEN: The controller should be a live controller.
62 self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
63
64 def set_transparency_enabled_test(self):
65@@ -138,3 +133,42 @@
66 # THEN: The plugins should have each been given an opportunity to add their bit to the CSS
67 mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame)
68 mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)
69+
70+ @patch('openlp.core.ui.maindisplay.is_macosx')
71+ def macosx_non_primary_screen_window_flags_state_test(self, is_macosx):
72+ """
73+ Test that on Mac OS X when the current screen isn't primary we set the proper window flags and window state
74+ """
75+ # GIVEN: A new SlideController instance on Mac OS X with the current display not being primary.
76+ is_macosx.return_value = True
77+ self.screens.set_current_display(1)
78+ display = MagicMock()
79+
80+ # WHEN: The default controller is built.
81+ main_display = MainDisplay(display)
82+
83+ # THEN: The window flags and state should be the same as those needed on Mac OS X for the non primary display.
84+ self.assertEqual(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint,
85+ main_display.windowFlags(),
86+ 'The window flags should be Qt.WindowStaysOnTop, Qt.Window, and Qt.FramelessWindowHint.')
87+ self.assertNotEqual(QtCore.Qt.WindowFullScreen, main_display.windowState(),
88+ 'The window state should not be full screen.')
89+
90+ @patch('openlp.core.ui.maindisplay.is_macosx')
91+ def macosx_primary_screen_window_flags_state_test(self, is_macosx):
92+ """
93+ Test that on Mac OS X when the current screen is primary we set the proper window flags and window state
94+ """
95+ # GIVEN: A new SlideController instance on Mac OS X with the current display being primary.
96+ is_macosx.return_value = True
97+ self.screens.set_current_display(0)
98+ display = MagicMock()
99+
100+ # WHEN: The default controller is built.
101+ main_display = MainDisplay(display)
102+
103+ # THEN: The window flags and state should be the same as those needed on Mac OS X for the primary display.
104+ self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint, main_display.windowFlags(),
105+ 'The window flags should be Qt.Window and Qt.FramelessWindowHint.')
106+ self.assertEqual(QtCore.Qt.WindowFullScreen, main_display.windowState(),
107+ 'The window state should be full screen.')