From 3aa7851c7df002b27fa3f257653daba7e542a6e6 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Thu, 31 Mar 2016 23:35:04 +0300 Subject: [PATCH] Added two tests for this. The other to check if visibility is changed to "True" for logo, the other for the opposite. To do: How to name this new setting? / Old "Default image" settings. --- openlp/core/ui/advancedtab.py | 2 +- .../openlp_core_ui/test_maindisplay.py | 42 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 5f37ff2d0..163c9ccd0 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -307,7 +307,7 @@ class AdvancedTab(SettingsTab): self.default_file_label.setText(translate('OpenLP.AdvancedTab', 'Image file:')) self.default_browse_button.setToolTip(translate('OpenLP.AdvancedTab', 'Browse for an image file to display.')) self.default_revert_button.setToolTip(translate('OpenLP.AdvancedTab', 'Revert to the default OpenLP logo.')) - self.default_show_nothing_check_box.setText(translate('OpenLP.AdvancedTab', 'Don\'t show Logo ')) + self.default_show_nothing_check_box.setText(translate('OpenLP.AdvancedTab', 'Don\'t show image or background')) self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:')) self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab', diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 9c80740f2..fc7ae4910 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -26,7 +26,7 @@ from unittest import TestCase, skipUnless from PyQt5 import QtCore -from openlp.core.common import Registry, is_macosx +from openlp.core.common import Registry, is_macosx, Settings from openlp.core.lib import ScreenList from openlp.core.ui import MainDisplay from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET @@ -183,3 +183,43 @@ class TestMainDisplay(TestCase, TestMixin): 'Window level should be NSMainMenuWindowLevel + 2') self.assertEqual(pyobjc_nsview.window().collectionBehavior(), NSWindowCollectionBehaviorManaged, 'Window collection behavior should be NSWindowCollectionBehaviorManaged') + + @patch(u'openlp.core.ui.maindisplay.Settings') + def show_display_startup_logo_test(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 = True + 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 been called with "True" + main_display.setVisible.assert_called_once_with(True) + + @patch(u'openlp.core.ui.maindisplay.Settings') + def show_display_hide_startup_logo_test(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()