Fix the QSize bug.

Add this to your merge proposal:
--------------------------------
lp:~raoul-snyman/openlp/qsize-2.4 (revision 2664)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1866/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1777/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1715/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1455/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/1045/
[SUCCESS] https:/...

bzr-revno: 2661
This commit is contained in:
Raoul Snyman 2016-12-15 23:22:28 +02:00
commit f4f0b3d035
5 changed files with 95 additions and 15 deletions

View File

@ -61,9 +61,8 @@ def source_group(inputs, source_text):
""" """
groupdict = {} groupdict = {}
keydict = {} keydict = {}
checklist = inputs key = inputs[0][0]
key = checklist[0][0] for item in inputs:
for item in checklist:
if item[0] == key: if item[0] == key:
groupdict[item] = source_text[item] groupdict[item] = source_text[item]
continue continue
@ -75,7 +74,7 @@ def source_group(inputs, source_text):
return keydict return keydict
def Build_Tab(group, source_key, default, projector, projectordb, edit=False): def build_tab(group, source_key, default, projector, projectordb, edit=False):
""" """
Create the radio button page for a tab. Create the radio button page for a tab.
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs. Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
@ -174,7 +173,7 @@ class FingerTabBarWidget(QtWidgets.QTabBar):
:param width: Remove default width parameter in kwargs :param width: Remove default width parameter in kwargs
:param height: Remove default height parameter in kwargs :param height: Remove default height parameter in kwargs
""" """
self.tabSize = QtWidgets.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25)) self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs) QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
def paintEvent(self, event): def paintEvent(self, event):
@ -275,7 +274,7 @@ class SourceSelectTabs(QtWidgets.QDialog):
keys.sort() keys.sort()
if self.edit: if self.edit:
for key in keys: for key in keys:
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group, (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
source_key={key: self.source_group[key]}, source_key={key: self.source_group[key]},
default=self.projector.source, default=self.projector.source,
projector=self.projector, projector=self.projector,
@ -290,7 +289,7 @@ class SourceSelectTabs(QtWidgets.QDialog):
QtWidgets.QDialogButtonBox.Cancel) QtWidgets.QDialogButtonBox.Cancel)
else: else:
for key in keys: for key in keys:
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group, (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
source_key={key: self.source_group[key]}, source_key={key: self.source_group[key]},
default=self.projector.source, default=self.projector.source,
projector=self.projector, projector=self.projector,

View File

@ -0,0 +1,83 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2016 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; 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 #
###############################################################################
"""
:mod: `tests.functional.openlp_core_ui.test_projectorsourceform` module
Tests for the Projector Source Select form.
"""
from PyQt5 import QtCore
from openlp.core.ui.projector.sourceselectform import FingerTabBarWidget, source_group
def test_source_group():
"""
Test the source_group() method
"""
# GIVEN: A list of inputs and source text
inputs = [
'vga1', 'vga2',
'hdmi1', 'hdmi2'
]
source_text = {
'vga1': 'VGA 1',
'vga2': 'VGA 2',
'hdmi1': 'HDMI 1',
'hdmi2': 'HDMI 2'
}
# WHEN: source_group() is called
result = source_group(inputs, source_text)
# THEN: the resultant dictionary should be correct
expected_dict = {
'v': {'vga1': 'VGA 1', 'vga2': 'VGA 2'},
'h': {'hdmi1': 'HDMI 1', 'hdmi2': 'HDMI 2'}
}
assert result == expected_dict, result
def test_finger_tab_bar_widget():
"""
Test that the FingerTabBarWidget is initialised correctly
"""
# GIVEN: A FinderTabBarWidget class
# WHEN: An instance of the FingerTabBarWidget is created
widget = FingerTabBarWidget()
# THEN: It should havea tabSize of 100x25
assert widget.tabSize == QtCore.QSize(100, 25)
def test_finger_tab_bar_widget_with_kwargs():
"""
Test that the FingerTabBarWidget is initialised correctly from kwargs
"""
# GIVEN: A FinderTabBarWidget class and some arguments
width = 300
height = 100
# WHEN: An instance of the FingerTabBarWidget is created
widget = FingerTabBarWidget(width=width, height=height)
# THEN: It should havea tabSize of 100x25
assert widget.tabSize == QtCore.QSize(width, height)

View File

@ -24,19 +24,17 @@
Tests for the Projector Source Select form. Tests for the Projector Source Select form.
""" """
import logging
log = logging.getLogger(__name__)
log.debug('test_projectorsourceform loaded')
import os import os
import time
from unittest import TestCase from unittest import TestCase
from unittest.mock import patch
from PyQt5.QtWidgets import QDialog from PyQt5.QtWidgets import QDialog
from tests.functional import patch
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
from tests.resources.projector.data import TEST_DB, TEST1_DATA from tests.resources.projector.data import TEST_DB, TEST1_DATA
from openlp.core.common import Registry, Settings from openlp.core.common import Registry
from openlp.core.lib.projector.db import ProjectorDB, Projector from openlp.core.lib.projector.db import ProjectorDB, Projector
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
@ -49,7 +47,7 @@ def build_source_dict():
:returns: dictionary of valid PJLink source codes grouped by PJLink source group :returns: dictionary of valid PJLink source codes grouped by PJLink source group
""" """
test_group = {} test_group = {}
for group in PJLINK_DEFAULT_SOURCES.keys(): for group in PJLINK_DEFAULT_SOURCES:
test_group[group] = {} test_group[group] = {}
for key in PJLINK_DEFAULT_CODES: for key in PJLINK_DEFAULT_CODES:
test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key] test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]
@ -86,8 +84,8 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
Delete all C++ objects at end so we don't segfault. Delete all C++ objects at end so we don't segfault.
""" """
self.projectordb.session.close() self.projectordb.session.close()
del(self.projectordb) del self.projectordb
del(self.projector) del self.projector
retries = 0 retries = 0
while retries < 5: while retries < 5:
try: try:

View File

View File