Merge lp:~raoul-snyman/openlp/qsize-2.4 into lp:openlp/2.4

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2661
Proposed branch: lp:~raoul-snyman/openlp/qsize-2.4
Merge into: lp:openlp/2.4
Diff against target: 189 lines (+95/-15)
3 files modified
openlp/core/ui/projector/sourceselectform.py (+6/-7)
tests/functional/openlp_core_ui/test_projector_sourceselectform.py (+83/-0)
tests/interfaces/openlp_core_ui/test_projectorsourceform.py (+6/-8)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/qsize-2.4
Reviewer Review Type Date Requested Status
Tomas Groth Approve
Review via email: mp+313345@code.launchpad.net

This proposal supersedes a proposal from 2016-12-15.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/ui/projector/sourceselectform.py'
--- openlp/core/ui/projector/sourceselectform.py 2016-08-12 09:23:56 +0000
+++ openlp/core/ui/projector/sourceselectform.py 2016-12-15 11:23:06 +0000
@@ -61,9 +61,8 @@
61 """61 """
62 groupdict = {}62 groupdict = {}
63 keydict = {}63 keydict = {}
64 checklist = inputs64 key = inputs[0][0]
65 key = checklist[0][0]65 for item in inputs:
66 for item in checklist:
67 if item[0] == key:66 if item[0] == key:
68 groupdict[item] = source_text[item]67 groupdict[item] = source_text[item]
69 continue68 continue
@@ -75,7 +74,7 @@
75 return keydict74 return keydict
7675
7776
78def Build_Tab(group, source_key, default, projector, projectordb, edit=False):77def build_tab(group, source_key, default, projector, projectordb, edit=False):
79 """78 """
80 Create the radio button page for a tab.79 Create the radio button page for a tab.
81 Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.80 Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
@@ -174,7 +173,7 @@
174 :param width: Remove default width parameter in kwargs173 :param width: Remove default width parameter in kwargs
175 :param height: Remove default height parameter in kwargs174 :param height: Remove default height parameter in kwargs
176 """175 """
177 self.tabSize = QtWidgets.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))176 self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
178 QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)177 QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
179178
180 def paintEvent(self, event):179 def paintEvent(self, event):
@@ -275,7 +274,7 @@
275 keys.sort()274 keys.sort()
276 if self.edit:275 if self.edit:
277 for key in keys:276 for key in keys:
278 (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,277 (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
279 source_key={key: self.source_group[key]},278 source_key={key: self.source_group[key]},
280 default=self.projector.source,279 default=self.projector.source,
281 projector=self.projector,280 projector=self.projector,
@@ -290,7 +289,7 @@
290 QtWidgets.QDialogButtonBox.Cancel)289 QtWidgets.QDialogButtonBox.Cancel)
291 else:290 else:
292 for key in keys:291 for key in keys:
293 (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,292 (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
294 source_key={key: self.source_group[key]},293 source_key={key: self.source_group[key]},
295 default=self.projector.source,294 default=self.projector.source,
296 projector=self.projector,295 projector=self.projector,
297296
=== added file 'tests/functional/openlp_core_ui/test_projector_sourceselectform.py'
--- tests/functional/openlp_core_ui/test_projector_sourceselectform.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_ui/test_projector_sourceselectform.py 2016-12-15 11:23:06 +0000
@@ -0,0 +1,83 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2016 OpenLP Developers #
8# --------------------------------------------------------------------------- #
9# This program is free software; you can redistribute it and/or modify it #
10# under the terms of the GNU General Public License as published by the Free #
11# Software Foundation; version 2 of the License. #
12# #
13# This program is distributed in the hope that it will be useful, but WITHOUT #
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
15# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
16# more details. #
17# #
18# You should have received a copy of the GNU General Public License along #
19# with this program; if not, write to the Free Software Foundation, Inc., 59 #
20# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21###############################################################################
22"""
23:mod: `tests.functional.openlp_core_ui.test_projectorsourceform` module
24
25Tests for the Projector Source Select form.
26"""
27from PyQt5 import QtCore
28
29from openlp.core.ui.projector.sourceselectform import FingerTabBarWidget, source_group
30
31
32def test_source_group():
33 """
34 Test the source_group() method
35 """
36 # GIVEN: A list of inputs and source text
37 inputs = [
38 'vga1', 'vga2',
39 'hdmi1', 'hdmi2'
40 ]
41 source_text = {
42 'vga1': 'VGA 1',
43 'vga2': 'VGA 2',
44 'hdmi1': 'HDMI 1',
45 'hdmi2': 'HDMI 2'
46 }
47
48 # WHEN: source_group() is called
49 result = source_group(inputs, source_text)
50
51 # THEN: the resultant dictionary should be correct
52 expected_dict = {
53 'v': {'vga1': 'VGA 1', 'vga2': 'VGA 2'},
54 'h': {'hdmi1': 'HDMI 1', 'hdmi2': 'HDMI 2'}
55 }
56 assert result == expected_dict, result
57
58
59def test_finger_tab_bar_widget():
60 """
61 Test that the FingerTabBarWidget is initialised correctly
62 """
63 # GIVEN: A FinderTabBarWidget class
64 # WHEN: An instance of the FingerTabBarWidget is created
65 widget = FingerTabBarWidget()
66
67 # THEN: It should havea tabSize of 100x25
68 assert widget.tabSize == QtCore.QSize(100, 25)
69
70
71def test_finger_tab_bar_widget_with_kwargs():
72 """
73 Test that the FingerTabBarWidget is initialised correctly from kwargs
74 """
75 # GIVEN: A FinderTabBarWidget class and some arguments
76 width = 300
77 height = 100
78
79 # WHEN: An instance of the FingerTabBarWidget is created
80 widget = FingerTabBarWidget(width=width, height=height)
81
82 # THEN: It should havea tabSize of 100x25
83 assert widget.tabSize == QtCore.QSize(width, height)
084
=== modified file 'tests/interfaces/openlp_core_ui/test_projectorsourceform.py'
--- tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2016-01-15 19:41:14 +0000
+++ tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2016-12-15 11:23:06 +0000
@@ -24,19 +24,17 @@
2424
25Tests for the Projector Source Select form.25Tests for the Projector Source Select form.
26"""26"""
27import logging
28log = logging.getLogger(__name__)
29log.debug('test_projectorsourceform loaded')
30import os27import os
28import time
31from unittest import TestCase29from unittest import TestCase
30from unittest.mock import patch
3231
33from PyQt5.QtWidgets import QDialog32from PyQt5.QtWidgets import QDialog
3433
35from tests.functional import patch
36from tests.helpers.testmixin import TestMixin34from tests.helpers.testmixin import TestMixin
37from tests.resources.projector.data import TEST_DB, TEST1_DATA35from tests.resources.projector.data import TEST_DB, TEST1_DATA
3836
39from openlp.core.common import Registry, Settings37from openlp.core.common import Registry
40from openlp.core.lib.projector.db import ProjectorDB, Projector38from openlp.core.lib.projector.db import ProjectorDB, Projector
41from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES39from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
42from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle40from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
@@ -49,7 +47,7 @@
49 :returns: dictionary of valid PJLink source codes grouped by PJLink source group47 :returns: dictionary of valid PJLink source codes grouped by PJLink source group
50 """48 """
51 test_group = {}49 test_group = {}
52 for group in PJLINK_DEFAULT_SOURCES.keys():50 for group in PJLINK_DEFAULT_SOURCES:
53 test_group[group] = {}51 test_group[group] = {}
54 for key in PJLINK_DEFAULT_CODES:52 for key in PJLINK_DEFAULT_CODES:
55 test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]53 test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]
@@ -86,8 +84,8 @@
86 Delete all C++ objects at end so we don't segfault.84 Delete all C++ objects at end so we don't segfault.
87 """85 """
88 self.projectordb.session.close()86 self.projectordb.session.close()
89 del(self.projectordb)87 del self.projectordb
90 del(self.projector)88 del self.projector
91 retries = 089 retries = 0
92 while retries < 5:90 while retries < 5:
93 try:91 try:
9492
=== added file 'tests/resources/__init__.py'
=== added file 'tests/resources/projector/__init__.py'

Subscribers

People subscribed via source and target branches

to all changes: