From 3ae5240d157509915d42d68762d5aa8ffefbb761 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Thu, 19 May 2016 04:10:27 +0930 Subject: [PATCH 1/8] Implemented auto option & updated settings to use combo box --- openlp/core/common/settings.py | 2 +- openlp/core/ui/advancedtab.py | 27 ++++++++++++++++--------- openlp/core/ui/lib/listpreviewwidget.py | 23 ++++++++++++++------- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 7bbd4349d..d4e114c74 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -129,7 +129,7 @@ class Settings(QtCore.QSettings): 'advanced/recent file count': 4, 'advanced/save current plugin': False, 'advanced/slide limits': SlideLimits.End, - 'advanced/slide max height': 0, + 'advanced/slide max height': -4, 'advanced/single click preview': False, 'advanced/single click service preview': False, 'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 97e2d3617..ed720b5df 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -87,11 +87,14 @@ class AdvancedTab(SettingsTab): self.ui_layout.addRow(self.expand_service_item_check_box) self.slide_max_height_label = QtWidgets.QLabel(self.ui_group_box) self.slide_max_height_label.setObjectName('slide_max_height_label') - self.slide_max_height_spin_box = QtWidgets.QSpinBox(self.ui_group_box) - self.slide_max_height_spin_box.setObjectName('slide_max_height_spin_box') - self.slide_max_height_spin_box.setRange(0, 1000) - self.slide_max_height_spin_box.setSingleStep(20) - self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_spin_box) + self.slide_max_height_combo_box = QtWidgets.QComboBox(self.ui_group_box) + self.slide_max_height_combo_box.addItem('', userData=0) + self.slide_max_height_combo_box.addItem('', userData=-4) + # Generate numeric values for combo box dynamically + for px in range(60,801,5): + self.slide_max_height_combo_box.addItem(str(px)+'px', userData=px) + self.slide_max_height_combo_box.setObjectName('slide_max_height_combo_box') + self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_combo_box) self.autoscroll_label = QtWidgets.QLabel(self.ui_group_box) self.autoscroll_label.setObjectName('autoscroll_label') self.autoscroll_combo_box = QtWidgets.QComboBox(self.ui_group_box) @@ -265,7 +268,8 @@ class AdvancedTab(SettingsTab): 'Expand new service items on creation')) self.slide_max_height_label.setText(translate('OpenLP.AdvancedTab', 'Max height for non-text slides\nin slide controller:')) - self.slide_max_height_spin_box.setSpecialValueText(translate('OpenLP.AdvancedTab', 'Disabled')) + self.slide_max_height_combo_box.setItemText(0, translate('OpenLP.AdvancedTab', 'Disabled')) + self.slide_max_height_combo_box.setItemText(1, translate('OpenLP.AdvancedTab', 'Automatic')) self.autoscroll_label.setText(translate('OpenLP.AdvancedTab', 'When changing slides:')) self.autoscroll_combo_box.setItemText(0, translate('OpenLP.AdvancedTab', 'Do not auto-scroll')) @@ -355,10 +359,13 @@ class AdvancedTab(SettingsTab): self.single_click_preview_check_box.setChecked(settings.value('single click preview')) self.single_click_service_preview_check_box.setChecked(settings.value('single click service preview')) self.expand_service_item_check_box.setChecked(settings.value('expand service item')) - self.slide_max_height_spin_box.setValue(settings.value('slide max height')) + slide_max_height_value = settings.value('slide max height') + for i in range(0, self.slide_max_height_combo_box.count()): + if self.slide_max_height_combo_box.itemData(i) == slide_max_height_value: + self.slide_max_height_combo_box.setCurrentIndex(i) autoscroll_value = settings.value('autoscrolling') for i in range(0, len(self.autoscroll_map)): - if self.autoscroll_map[i] == autoscroll_value: + if self.autoscroll_map[i] == autoscroll_value and i < self.autoscroll_combo_box.count(): self.autoscroll_combo_box.setCurrentIndex(i) self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation')) self.hide_mouse_check_box.setChecked(settings.value('hide mouse')) @@ -439,7 +446,9 @@ class AdvancedTab(SettingsTab): settings.setValue('single click preview', self.single_click_preview_check_box.isChecked()) settings.setValue('single click service preview', self.single_click_service_preview_check_box.isChecked()) settings.setValue('expand service item', self.expand_service_item_check_box.isChecked()) - settings.setValue('slide max height', self.slide_max_height_spin_box.value()) + slide_max_height_index = self.slide_max_height_combo_box.currentIndex() + slide_max_height_value = self.slide_max_height_combo_box.itemData(slide_max_height_index) + settings.setValue('slide max height', slide_max_height_value) settings.setValue('autoscrolling', self.autoscroll_map[self.autoscroll_combo_box.currentIndex()]) settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked()) settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked()) diff --git a/openlp/core/ui/lib/listpreviewwidget.py b/openlp/core/ui/lib/listpreviewwidget.py index 2383cc35f..0edab337f 100644 --- a/openlp/core/ui/lib/listpreviewwidget.py +++ b/openlp/core/ui/lib/listpreviewwidget.py @@ -63,6 +63,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): # Initialize variables. self.service_item = ServiceItem() self.screen_ratio = screen_ratio + self.auto_row_height = 100 # Connect signals self.verticalHeader().sectionResized.connect(self.row_resized) @@ -87,8 +88,14 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): height = self.viewport().width() // self.screen_ratio max_img_row_height = Settings().value('advanced/slide max height') # Adjust for row height cap if in use. - if isinstance(max_img_row_height, int) and max_img_row_height > 0 and height > max_img_row_height: - height = max_img_row_height + if isinstance(max_img_row_height, int): + if max_img_row_height > 0 and height > max_img_row_height: + height = max_img_row_height + elif max_img_row_height < 0: + # If auto setting, show that number of slides, or if the resulting slides too small, 100px. + # E.g. If setting is -4, 4 slides will be visible, unless those slides are < 100px high. + self.auto_row_height = max(self.viewport().height() / (-1 * max_img_row_height), 100) + height = min(height, self.auto_row_height) # Apply new height to slides for frame_number in range(len(self.service_item.get_frames())): self.setRowHeight(frame_number, height) @@ -99,7 +106,7 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): """ # Only for non-text slides when row height cap in use max_img_row_height = Settings().value('advanced/slide max height') - if self.service_item.is_text() or not isinstance(max_img_row_height, int) or max_img_row_height <= 0: + if self.service_item.is_text() or not isinstance(max_img_row_height, int) or max_img_row_height == 0: return # Get and validate label widget containing slide & adjust max width try: @@ -165,11 +172,13 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): slide_height = width // self.screen_ratio # Setup and validate row height cap if in use. max_img_row_height = Settings().value('advanced/slide max height') - if isinstance(max_img_row_height, int) and max_img_row_height > 0: - if slide_height > max_img_row_height: + if isinstance(max_img_row_height, int) and max_img_row_height != 0: + if max_img_row_height > 0 and slide_height > max_img_row_height: slide_height = max_img_row_height - label.setMaximumWidth(max_img_row_height * self.screen_ratio) - label.resize(max_img_row_height * self.screen_ratio, max_img_row_height) + elif max_img_row_height < 0 and slide_height > self.auto_row_height: + slide_height = self.auto_row_height + label.setMaximumWidth(slide_height * self.screen_ratio) + label.resize(slide_height * self.screen_ratio, slide_height) # Build widget with stretch padding container = QtWidgets.QWidget() hbox = QtWidgets.QHBoxLayout() From 812c1245283d036fb05bd452f494e71786607072 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Fri, 20 May 2016 22:06:59 +0930 Subject: [PATCH 2/8] Added test case for Auto option. --- .../test_listpreviewwidget.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py index 704acc544..b6834d24b 100644 --- a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py +++ b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py @@ -225,6 +225,44 @@ class TestListPreviewWidget(TestCase): calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)] mocked_setRowHeight.assert_has_calls(calls) + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') + def replace_recalculate_layout_test_img_auto(self, mocked_setRowHeight, mocked_resizeRowsToContents): + """ + Test if "Max height for non-text slides..." auto, img slides resized in replace_service_item & __recalc... + """ + # GIVEN: A setting to adjust "Max height for non-text slides in slide controller", + # an image ServiceItem and a ListPreviewWidget. + + # Mock Settings().value('advanced/slide max height') + self.mocked_Settings_obj.value.return_value = -4 + # Mock self.viewport().width() + self.mocked_viewport_obj.width.return_value = 200 + self.mocked_viewport_obj.height.return_value = 600 + # Mock image service item + service_item = MagicMock() + service_item.is_text.return_value = False + service_item.is_capable.return_value = False + service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None}, + {'title': None, 'path': None, 'image': None}] + # init ListPreviewWidget and load service item + list_preview_widget = ListPreviewWidget(None, 1) + list_preview_widget.replace_service_item(service_item, 200, 0) + # Change viewport width before forcing a resize + self.mocked_viewport_obj.width.return_value = 400 + + # WHEN: __recalculate_layout() is called (via resizeEvent) + list_preview_widget.resizeEvent(None) + self.mocked_viewport_obj.height.return_value = 200 + list_preview_widget.resizeEvent(None) + + # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called + # twice for each slide. + self.assertEquals(mocked_resizeRowsToContents.call_count, 0, 'Should not be called') + self.assertEquals(mocked_setRowHeight.call_count, 6, 'Should be called 3 times for each slide') + calls = [call(0, 100), call(1, 100), call(0, 150), call(1, 150), call(0, 100), call(1, 100)] + mocked_setRowHeight.assert_has_calls(calls) + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') From 3b48a4b8175bb23b162f231b0650f3df91c5e39f Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Fri, 20 May 2016 22:08:36 +0930 Subject: [PATCH 3/8] Housekeeping --- openlp/core/ui/lib/listpreviewwidget.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/lib/listpreviewwidget.py b/openlp/core/ui/lib/listpreviewwidget.py index 0edab337f..2ea004160 100644 --- a/openlp/core/ui/lib/listpreviewwidget.py +++ b/openlp/core/ui/lib/listpreviewwidget.py @@ -174,8 +174,10 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): max_img_row_height = Settings().value('advanced/slide max height') if isinstance(max_img_row_height, int) and max_img_row_height != 0: if max_img_row_height > 0 and slide_height > max_img_row_height: + # Manual Setting slide_height = max_img_row_height elif max_img_row_height < 0 and slide_height > self.auto_row_height: + # Auto Setting slide_height = self.auto_row_height label.setMaximumWidth(slide_height * self.screen_ratio) label.resize(slide_height * self.screen_ratio, slide_height) From 2c1c7810b9bf710de2af8db4ba498be43d97d295 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Fri, 20 May 2016 22:57:52 +0930 Subject: [PATCH 4/8] Improved test coverage. --- .../test_listpreviewwidget.py | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py index b6834d24b..64239373a 100644 --- a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py +++ b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py @@ -251,10 +251,10 @@ class TestListPreviewWidget(TestCase): # Change viewport width before forcing a resize self.mocked_viewport_obj.width.return_value = 400 - # WHEN: __recalculate_layout() is called (via resizeEvent) - list_preview_widget.resizeEvent(None) + # WHEN: __recalculate_layout() is called (via screen_size_changed) + list_preview_widget.screen_size_changed(1) self.mocked_viewport_obj.height.return_value = 200 - list_preview_widget.resizeEvent(None) + list_preview_widget.screen_size_changed(1) # THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called # twice for each slide. @@ -369,6 +369,41 @@ class TestListPreviewWidget(TestCase): # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should be called mocked_cellWidget_child.setMaximumWidth.assert_called_once_with(150) + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') + def row_resized_test_setting_changed(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): + """ + Test if "Max height for non-text slides..." enabled while item live, program doesn't crash on row_resized. + """ + # GIVEN: A setting to adjust "Max height for non-text slides in slide controller", + # an image ServiceItem and a ListPreviewWidget. + + # Mock Settings().value('advanced/slide max height') + self.mocked_Settings_obj.value.return_value = 0 + # Mock self.viewport().width() + self.mocked_viewport_obj.width.return_value = 200 + # Mock image service item + service_item = MagicMock() + service_item.is_text.return_value = False + service_item.is_capable.return_value = False + service_item.get_frames.return_value = [{'title': None, 'path': None, 'image': None}, + {'title': None, 'path': None, 'image': None}] + # Mock self.cellWidget().children() + mocked_cellWidget_obj = MagicMock() + mocked_cellWidget_obj.children.return_value = None + mocked_cellWidget.return_value = mocked_cellWidget_obj + # init ListPreviewWidget and load service item + list_preview_widget = ListPreviewWidget(None, 1) + list_preview_widget.replace_service_item(service_item, 200, 0) + self.mocked_Settings_obj.value.return_value = 100 + + # WHEN: row_resized() is called + list_preview_widget.row_resized(0, 100, 150) + + # THEN: self.cellWidget(row, 0).children()[1].setMaximumWidth() should fail + self.assertRaises(Exception) + @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.selectRow') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.scrollToItem') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.item') From e09e867ad1b89f7a5b56eee891d55b6331d1aa77 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Fri, 20 May 2016 23:07:23 +0930 Subject: [PATCH 5/8] Pep8 Errors --- openlp/core/ui/advancedtab.py | 4 ++-- tests/functional/openlp_core_common/test_actions.py | 2 +- tests/functional/openlp_core_lib/test_lib.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index ed720b5df..10e6056d1 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -91,8 +91,8 @@ class AdvancedTab(SettingsTab): self.slide_max_height_combo_box.addItem('', userData=0) self.slide_max_height_combo_box.addItem('', userData=-4) # Generate numeric values for combo box dynamically - for px in range(60,801,5): - self.slide_max_height_combo_box.addItem(str(px)+'px', userData=px) + for px in range(60, 801, 5): + self.slide_max_height_combo_box.addItem(str(px) + 'px', userData=px) self.slide_max_height_combo_box.setObjectName('slide_max_height_combo_box') self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_combo_box) self.autoscroll_label = QtWidgets.QLabel(self.ui_group_box) diff --git a/tests/functional/openlp_core_common/test_actions.py b/tests/functional/openlp_core_common/test_actions.py index 92f030df2..afdc89c34 100644 --- a/tests/functional/openlp_core_common/test_actions.py +++ b/tests/functional/openlp_core_common/test_actions.py @@ -118,7 +118,7 @@ class TestCategoryActionList(TestCase): # GIVEN: The list including two actions self.list.add(self.action1) self.list.add(self.action2) - + # WHEN: Iterating over the list l = [a for a in self.list] # THEN: Make sure they are returned in correct order diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index c8493d005..d519837bf 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -431,7 +431,6 @@ class TestLib(TestCase): thumb_size = QtCore.QSize(-1, 100) expected_size_1 = QtCore.QSize(88, 88) expected_size_2 = QtCore.QSize(100, 100) - # Remove the thumb so that the test actually tests if the thumb will be created. Maybe it was not deleted in the # last test. @@ -458,7 +457,7 @@ class TestLib(TestCase): with patch('openlp.core.lib.QtGui.QImageReader.size') as mocked_size: mocked_size.return_value = QtCore.QSize(0, 0) icon = create_thumb(image_path, thumb_path, size=thumb_size) - + # THEN: Check if the thumb was created with aspect ratio of 1. self.assertIsInstance(icon, QtGui.QIcon, 'The icon should be a QIcon') self.assertFalse(icon.isNull(), 'The icon should not be null') From 3627976132811a105f4add030d6cb2c850816d77 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Wed, 1 Jun 2016 13:51:44 +0930 Subject: [PATCH 6/8] fixed pep8 error --- tests/functional/openlp_core_common/test_registryproperties.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/openlp_core_common/test_registryproperties.py b/tests/functional/openlp_core_common/test_registryproperties.py index 0f0184876..3f57913e2 100644 --- a/tests/functional/openlp_core_common/test_registryproperties.py +++ b/tests/functional/openlp_core_common/test_registryproperties.py @@ -75,4 +75,3 @@ class TestRegistryProperties(TestCase, RegistryProperties): # THEN the application should be none self.assertEqual(self.application, application, 'The application value should match') - From 83e11710f247c3e4f42f82cb75750a426943bc1c Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Thu, 2 Jun 2016 10:45:41 +0930 Subject: [PATCH 7/8] fixed test naming issue --- .../test_listpreviewwidget.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py index 64239373a..b0279cece 100644 --- a/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py +++ b/tests/functional/openlp_core_ui_lib/test_listpreviewwidget.py @@ -61,7 +61,7 @@ class TestListPreviewWidget(TestCase): self.mocked_viewport.return_value = self.mocked_viewport_obj self.addCleanup(self.viewport_patcher.stop) - def new_list_preview_widget_test(self): + def test_new_list_preview_widget(self): """ Test that creating an instance of ListPreviewWidget works """ @@ -77,7 +77,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.image_manager') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') - def replace_service_item_test_thumbs(self, mocked_setRowHeight, mocked_resizeRowsToContents, + def test_replace_service_item_thumbs(self, mocked_setRowHeight, mocked_resizeRowsToContents, mocked_image_manager): """ Test that thubmails for different slides are loaded properly in replace_service_item. @@ -123,7 +123,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') - def replace_recalculate_layout_test_text(self, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_replace_recalculate_layout_text(self, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." enabled, txt slides unchanged in replace_service_item & __recalc... """ @@ -155,7 +155,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') - def replace_recalculate_layout_test_img(self, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_replace_recalculate_layout_img(self, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." disabled, img slides unchanged in replace_service_item & __recalc... """ @@ -192,7 +192,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') - def replace_recalculate_layout_test_img_max(self, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_replace_recalculate_layout_img_max(self, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." enabled, img slides resized in replace_service_item & __recalc... """ @@ -227,7 +227,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') - def replace_recalculate_layout_test_img_auto(self, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_replace_recalculate_layout_img_auto(self, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." auto, img slides resized in replace_service_item & __recalc... """ @@ -266,7 +266,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') - def row_resized_test_text(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_row_resized_text(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." enabled, text-based slides not affected in row_resized. """ @@ -300,7 +300,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') - def row_resized_test_img(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_row_resized_img(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." disabled, image-based slides not affected in row_resized. """ @@ -337,7 +337,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') - def row_resized_test_img_max(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_row_resized_img_max(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." enabled, image-based slides are scaled in row_resized. """ @@ -372,7 +372,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.resizeRowsToContents') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget') - def row_resized_test_setting_changed(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): + def test_row_resized_setting_changed(self, mocked_cellWidget, mocked_setRowHeight, mocked_resizeRowsToContents): """ Test if "Max height for non-text slides..." enabled while item live, program doesn't crash on row_resized. """ @@ -408,7 +408,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.scrollToItem') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.item') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.slide_count') - def autoscroll_test_setting_invalid(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): + def test_autoscroll_setting_invalid(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): """ Test if 'advanced/autoscrolling' setting None or invalid, that no autoscrolling occurs on change_slide(). """ @@ -444,7 +444,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.scrollToItem') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.item') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.slide_count') - def autoscroll_test_dist_bounds(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): + def test_autoscroll_dist_bounds(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): """ Test if 'advanced/autoscrolling' setting asks to scroll beyond list bounds, that it does not beyond. """ @@ -474,7 +474,7 @@ class TestListPreviewWidget(TestCase): @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.scrollToItem') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.item') @patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.slide_count') - def autoscroll_test_normal(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): + def test_autoscroll_normal(self, mocked_slide_count, mocked_item, mocked_scrollToItem, mocked_selectRow): """ Test if 'advanced/autoscrolling' setting valid, autoscrolling called as expected. """ From 47da0a1c8bad9b3ac4d664cb72bebfd5d0c4d5c2 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Thu, 2 Jun 2016 20:02:34 +0930 Subject: [PATCH 8/8] Fixed PEP8 Errors --- tests/functional/openlp_plugins/bibles/test_lib.py | 1 + tests/functional/openlp_plugins/songs/test_opsproimport.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_plugins/bibles/test_lib.py b/tests/functional/openlp_plugins/bibles/test_lib.py index a8dba0bd9..27d7f5e51 100644 --- a/tests/functional/openlp_plugins/bibles/test_lib.py +++ b/tests/functional/openlp_plugins/bibles/test_lib.py @@ -43,6 +43,7 @@ class TestLib(TestCase): separators = {'sep_r': '\\s*(?:e)\\s*', 'sep_e_default': 'end', 'sep_v_display': 'w', 'sep_l_display': 'r', 'sep_v_default': ':|v|V|verse|verses', 'sep_l': '\\s*(?:r)\\s*', 'sep_l_default': ',|and', 'sep_e': '\\s*(?:t)\\s*', 'sep_v': '\\s*(?:w)\\s*', 'sep_r_display': 'e', 'sep_r_default': '-|to'} + def _update_side_effect(): """ Update the references after mocking out the method diff --git a/tests/functional/openlp_plugins/songs/test_opsproimport.py b/tests/functional/openlp_plugins/songs/test_opsproimport.py index 239b77c30..8db69b609 100644 --- a/tests/functional/openlp_plugins/songs/test_opsproimport.py +++ b/tests/functional/openlp_plugins/songs/test_opsproimport.py @@ -171,4 +171,3 @@ class TestOpsProSongImport(TestCase): result_data = json.loads(result_file.read().decode()) self.assertListEqual(importer.verses, _get_item(result_data, 'verses')) self.assertListEqual(importer.verse_order_list_generated, _get_item(result_data, 'verse_order_list')) -