forked from openlp/openlp
Added test case for Auto option.
This commit is contained in:
parent
3ae5240d15
commit
812c124528
@ -225,6 +225,44 @@ class TestListPreviewWidget(TestCase):
|
|||||||
calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)]
|
calls = [call(0, 100), call(1, 100), call(0, 100), call(1, 100)]
|
||||||
mocked_setRowHeight.assert_has_calls(calls)
|
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.resizeRowsToContents')
|
||||||
@patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
@patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.setRowHeight')
|
||||||
@patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget')
|
@patch(u'openlp.core.ui.lib.listpreviewwidget.ListPreviewWidget.cellWidget')
|
||||||
|
Loading…
Reference in New Issue
Block a user