def test_build_html_video(self, MockedSettings, Mocked_build_html): # GIVEN: Mocked display display = MagicMock() mocked_media_controller = MagicMock() Registry.create() Registry().register('media_controller', mocked_media_controller) main_display = MainDisplay(display) main_display.frame = MagicMock() mocked_settings = MagicMock() mocked_settings.value.return_value = False MockedSettings.return_value = mocked_settings main_display.shake_web_view = MagicMock() service_item = MagicMock() service_item.theme_data = MagicMock() service_item.theme_data.background_type = 'video' mocked_plugin = MagicMock() display.plugin_manager = PluginManager() display.plugin_manager.plugins = [mocked_plugin] main_display.web_view = MagicMock() # WHEN: build_html is called with a normal service item and a video theme. main_display.build_html(service_item) # THEN: the following should had not been called self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') self.assertEquals( main_display.media_controller.video.call_count, 1, 'Media Controller video should have been called once')
def test_build_html_video(self, MockedSettings, Mocked_build_html): # GIVEN: Mocked display display = MagicMock() mocked_media_controller = MagicMock() Registry.create() Registry().register('media_controller', mocked_media_controller) main_display = MainDisplay(display) main_display.frame = MagicMock() mocked_settings = MagicMock() mocked_settings.value.return_value = False MockedSettings.return_value = mocked_settings main_display.shake_web_view = MagicMock() service_item = MagicMock() service_item.theme_data = MagicMock() service_item.theme_data.background_type = 'video' service_item.theme_data.theme_name = 'name' service_item.theme_data.background_filename = 'background_filename' mocked_plugin = MagicMock() display.plugin_manager = PluginManager() display.plugin_manager.plugins = [mocked_plugin] main_display.web_view = MagicMock() # WHEN: build_html is called with a normal service item and a video theme. main_display.build_html(service_item) # THEN: the following should had not been called self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') self.assertEquals(main_display.media_controller.video.call_count, 1, 'Media Controller video should have been called once')
def test_show_display_hide_startup_logo(self, MockedSettings): # GIVEN: Mocked show_display, setting for logo visibility display = MagicMock() main_display = MainDisplay(display) main_display.frame = MagicMock() main_display.isHidden = MagicMock() main_display.isHidden.return_value = False main_display.setVisible = MagicMock() mocked_settings = MagicMock() mocked_settings.value.return_value = False MockedSettings.return_value = mocked_settings main_display.shake_web_view = MagicMock() # WHEN: show_display is called. main_display.show_display() # THEN: setVisible should had not been called main_display.setVisible.assert_not_called()
def css_changed_test(self): """ Test that when the CSS changes, the plugins are looped over and given an opportunity to update the CSS """ # GIVEN: A mocked list of plugins, a mocked display and a MainDisplay mocked_songs_plugin = MagicMock() mocked_bibles_plugin = MagicMock() mocked_plugin_manager = MagicMock() mocked_plugin_manager.plugins = [mocked_songs_plugin, mocked_bibles_plugin] Registry().register('plugin_manager', mocked_plugin_manager) display = MagicMock() main_display = MainDisplay(display) # This is set up dynamically, so we need to mock it out for now main_display.frame = MagicMock() # WHEN: The css_changed() method is triggered main_display.css_changed() # THEN: The plugins should have each been given an opportunity to add their bit to the CSS mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame) mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame)