Housekeeping

This commit is contained in:
Ian Knight 2016-05-06 11:16:49 +09:30
parent aac09c0afb
commit 3cdbaff2a6
2 changed files with 14 additions and 15 deletions

View File

@ -717,9 +717,9 @@ class TestSlideController(TestCase):
@patch(u'PyQt5.QtCore.QTimer.singleShot')
def update_preview_test_live(self, mocked_singleShot, mocked_image_manager):
"""
Test that the preview screen is updated with the correct preview for different service items
Test that the preview screen is updated with a screen grab for live service items
"""
# GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
# GIVEN: A mocked live service item, a mocked image_manager, a mocked Registry,
# and a slide controller with many mocks.
# Mocked Live Item
mocked_live_item = MagicMock()
@ -749,7 +749,7 @@ class TestSlideController(TestCase):
# WHEN: update_preview is called
slide_controller.update_preview()
# THEN: Registry.execute should have been called to stop the presentation
# THEN: A screen_grab should have been called
self.assertEqual(0, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should not be called')
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
self.assertEqual(2, mocked_singleShot.call_count,
@ -760,9 +760,9 @@ class TestSlideController(TestCase):
@patch(u'PyQt5.QtCore.QTimer.singleShot')
def update_preview_test_pres(self, mocked_singleShot, mocked_image_manager):
"""
Test that the preview screen is updated with the correct preview for different service items
Test that the preview screen is updated with the correct preview for presentation service items
"""
# GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
# GIVEN: A mocked presentation service item, a mocked image_manager, a mocked Registry,
# and a slide controller with many mocks.
# Mocked Presentation Item
mocked_pres_item = MagicMock()
@ -792,7 +792,7 @@ class TestSlideController(TestCase):
# WHEN: update_preview is called
slide_controller.update_preview()
# THEN: Registry.execute should have been called to stop the presentation
# THEN: setPixmap and the image_manager should have been called
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')
@ -802,9 +802,9 @@ class TestSlideController(TestCase):
@patch(u'PyQt5.QtCore.QTimer.singleShot')
def update_preview_test_media(self, mocked_singleShot, mocked_image_manager):
"""
Test that the preview screen is updated with the correct preview for different service items
Test that the preview screen is updated with the correct preview for media service items
"""
# GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
# GIVEN: A mocked media service item, a mocked image_manager, a mocked Registry,
# and a slide controller with many mocks.
# Mocked Media Item
mocked_media_item = MagicMock()
@ -834,7 +834,7 @@ class TestSlideController(TestCase):
# WHEN: update_preview is called
slide_controller.update_preview()
# THEN: Registry.execute should have been called to stop the presentation
# THEN: setPixmap should have been called
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
self.assertEqual(0, slide_controller.display.preview.call_count, 'display.preview() should not be called')
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')
@ -844,9 +844,9 @@ class TestSlideController(TestCase):
@patch(u'PyQt5.QtCore.QTimer.singleShot')
def update_preview_test_image(self, mocked_singleShot, mocked_image_manager):
"""
Test that the preview screen is updated with the correct preview for different service items
Test that the preview screen is updated with the correct preview for image service items
"""
# GIVEN: A mocked presentation service item, a mocked media service item, a mocked Registry.execute
# GIVEN: A mocked image service item, a mocked image_manager, a mocked Registry,
# and a slide controller with many mocks.
# Mocked Image Item
mocked_img_item = MagicMock()
@ -876,7 +876,7 @@ class TestSlideController(TestCase):
# WHEN: update_preview is called
slide_controller.update_preview()
# THEN: Registry.execute should have been called to stop the presentation
# THEN: setPixmap and display.preview should have been called
self.assertEqual(1, slide_controller.slide_preview.setPixmap.call_count, 'setPixmap should be called')
self.assertEqual(1, slide_controller.display.preview.call_count, 'display.preview() should be called')
self.assertEqual(0, mocked_singleShot.call_count, 'Timer to grab_maindisplay should not be called')

View File

@ -83,7 +83,7 @@ class TestListPreviewWidget(TestCase):
Test that thubmails for different slides are loaded properly in replace_service_item.
"""
# GIVEN: A setting to adjust "Max height for non-text slides in slide controller",
# different ServiceItem(s) and a ListPreviewWidget.
# different ServiceItem(s), an ImageManager, and a ListPreviewWidget.
# Mock Settings().value('advanced/slide max height')
self.mocked_Settings_obj.value.return_value = 0
@ -115,8 +115,7 @@ class TestListPreviewWidget(TestCase):
list_preview_widget.replace_service_item(mocked_img_service_item, 200, 0)
list_preview_widget.replace_service_item(mocked_cmd_service_item, 200, 0)
# THEN: resizeRowsToContents() should not be called, while setRowHeight() should be called
# twice for each slide.
# THEN: The ImageManager should be called in the appriopriate manner for each service item.
self.assertEquals(mocked_image_manager.get_image.call_count, 4, 'Should be called once for each slide')
calls = [call('TEST1', ImageSource.ImagePlugin), call('TEST2', ImageSource.ImagePlugin),
call('TEST3', ImageSource.CommandPlugins), call('TEST4', ImageSource.CommandPlugins)]