forked from openlp/openlp
Allow x11 override
This commit is contained in:
parent
60a69f8666
commit
cef0e67bd2
@ -109,13 +109,17 @@ class DisplayWindow(QtWidgets.QWidget):
|
||||
Create the display window
|
||||
"""
|
||||
super(DisplayWindow, self).__init__(parent)
|
||||
# Gather all flags for the display window
|
||||
flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint
|
||||
if Settings().value('advanced/x11 bypass wm'):
|
||||
flags |= QtCore.Qt.X11BypassWindowManagerHint
|
||||
# Need to import this inline to get around a QtWebEngine issue
|
||||
from openlp.core.display.webengine import WebEngineView
|
||||
self._is_initialised = False
|
||||
self._can_show_startup_screen = can_show_startup_screen
|
||||
self._fbo = None
|
||||
self.setWindowTitle(translate('OpenLP.DisplayWindow', 'Display Window'))
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint)
|
||||
self.setWindowFlags(flags)
|
||||
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
||||
self.setAutoFillBackground(True)
|
||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
|
@ -144,6 +144,23 @@ class TestInit(TestCase, TestMixin):
|
||||
# THEN: the result will be as expected - try again
|
||||
assert str(value) == 'called'
|
||||
|
||||
def test_requires_auth_missing_credentials(self):
|
||||
"""
|
||||
Test the requires_auth wrapper with enabled security and authorization taken place and and error
|
||||
:return:
|
||||
"""
|
||||
# GIVEN: An enabled security and a known user
|
||||
Settings().setValue('api/authentication enabled', True)
|
||||
Settings().setValue('api/user id', 'superfly')
|
||||
Settings().setValue('api/password', 'lamas')
|
||||
|
||||
# WHEN: I call the function with no password
|
||||
wrapped_function = requires_auth(func)
|
||||
value = wrapped_function(0)
|
||||
|
||||
# THEN: the result will be as expected (unauthorized)
|
||||
assert str(value) == str(authenticate())
|
||||
|
||||
|
||||
def func(field=None):
|
||||
return 'called'
|
||||
|
72
tests/functional/openlp_core/display/test_window.py
Normal file
72
tests/functional/openlp_core/display/test_window.py
Normal file
@ -0,0 +1,72 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##########################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# ---------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
||||
# ---------------------------------------------------------------------- #
|
||||
# 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, either version 3 of the License, or #
|
||||
# (at your option) any later version. #
|
||||
# #
|
||||
# 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, see <https://www.gnu.org/licenses/>. #
|
||||
##########################################################################
|
||||
"""
|
||||
Package to test the openlp.core.display.window package.
|
||||
"""
|
||||
import sys
|
||||
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
# Mock QtWebEngineWidgets
|
||||
sys.modules['PyQt5.QtWebEngineWidgets'] = MagicMock()
|
||||
|
||||
from openlp.core.display.window import DisplayWindow
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
from openlp.core.common.settings import Settings
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@patch('openlp.core.display.webengine.WebEngineView')
|
||||
class TestDisplayWindow(TestCase, TestMixin):
|
||||
"""
|
||||
A test suite to test the functions in DisplayWindow
|
||||
"""
|
||||
|
||||
def test_x11_override_on(self, mocked_webengine, mocked_addWidget):
|
||||
"""
|
||||
Test that the x11 override option bit is set
|
||||
"""
|
||||
# GIVEN: x11 bypass is on
|
||||
Settings().setValue('advanced/x11 bypass wm', True)
|
||||
|
||||
# WHEN: A DisplayWindow is generated
|
||||
display_window = DisplayWindow()
|
||||
|
||||
# THEN: The x11 override flag should be set
|
||||
x11_bit = display_window.windowFlags() & QtCore.Qt.X11BypassWindowManagerHint
|
||||
assert x11_bit == QtCore.Qt.X11BypassWindowManagerHint
|
||||
|
||||
def test_x11_override_off(self, mocked_webengine, mocked_addWidget):
|
||||
"""
|
||||
Test that the x11 override option bit is not set when setting if off
|
||||
"""
|
||||
# GIVEN: x11 bypass is off
|
||||
Settings().setValue('advanced/x11 bypass wm', False)
|
||||
|
||||
# WHEN: A DisplayWindow is generated
|
||||
display_window = DisplayWindow()
|
||||
|
||||
# THEN: The x11 override flag should not be set
|
||||
x11_bit = display_window.windowFlags() & QtCore.Qt.X11BypassWindowManagerHint
|
||||
assert x11_bit != QtCore.Qt.X11BypassWindowManagerHint
|
Loading…
Reference in New Issue
Block a user