Exemple #1
0
    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')
Exemple #2
0
    def test_macosx_display(self):
        """
        Test display on Mac OS X
        """
        # GIVEN: A new SlideController instance on Mac OS X.
        self.screens.set_current_display(0)
        display = MagicMock()

        # WHEN: The default controller is built and a reference to the underlying NSView is stored.
        main_display = MainDisplay(display)
        try:
            nsview_pointer = main_display.winId().ascapsule()
        except:
            nsview_pointer = voidptr(main_display.winId()).ascapsule()
        pythonapi.PyCapsule_SetName.restype = c_void_p
        pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p]
        pythonapi.PyCapsule_SetName(nsview_pointer,
                                    c_char_p(b"objc.__object__"))
        pyobjc_nsview = objc_object(cobject=nsview_pointer)

        # THEN: The window level and collection behavior should be the same as those needed for Mac OS X.
        self.assertEqual(pyobjc_nsview.window().level(),
                         NSMainMenuWindowLevel + 2,
                         'Window level should be NSMainMenuWindowLevel + 2')
        self.assertEqual(
            pyobjc_nsview.window().collectionBehavior(),
            NSWindowCollectionBehaviorManaged,
            'Window collection behavior should be NSWindowCollectionBehaviorManaged'
        )
Exemple #3
0
 def update_display(self):
     """
     Updates the renderer's information about the current screen.
     """
     self._calculate_default()
     if self.display:
         self.display.close()
     self.display = MainDisplay(self)
     self.display.setup()
     self._theme_dimensions = {}
Exemple #4
0
    def initial_main_display_test(self):
        """
        Test the initial Main Display state
        """
        # GIVEN: A new SlideController instance.
        display = MagicMock()
        display.is_live = True

        # WHEN: The default controller is built.
        main_display = MainDisplay(display)

        # THEN: The controller should be a live controller.
        self.assertEqual(main_display.is_live, True, 'The main display should be a live controller')
Exemple #5
0
    def test_macosx_display_window_flags_state(self):
        """
        Test that on Mac OS X we set the proper window flags
        """
        # GIVEN: A new SlideController instance on Mac OS X.
        self.screens.set_current_display(0)
        display = MagicMock()

        # WHEN: The default controller is built.
        main_display = MainDisplay(display)

        # THEN: The window flags should be the same as those needed on Mac OS X.
        assert QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint | QtCore.Qt.NoDropShadowWindowHint == \
            main_display.windowFlags(), \
            'The window flags should be Qt.Window, Qt.FramelessWindowHint, and Qt.NoDropShadowWindowHint.'
Exemple #6
0
    def set_transparency_disabled_test(self):
        """
        Test setting the display to be opaque
        """
        # GIVEN: An instance of MainDisplay
        display = MagicMock()
        main_display = MainDisplay(display)

        # WHEN: Transparency is disabled
        main_display.set_transparency(False)

        # THEN: The opaque stylesheet should be used
        self.assertEqual(OPAQUE_STYLESHEET, main_display.styleSheet(),
                         'The MainDisplay should use the opaque stylesheet')
        self.assertFalse(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
                         'The MainDisplay should not have a translucent background')
Exemple #7
0
    def macosx_primary_screen_window_flags_state_test(self, is_macosx):
        """
        Test that on Mac OS X when the current screen is primary we set the proper window flags and window state
        """
        # GIVEN: A new SlideController instance on Mac OS X with the current display being primary.
        is_macosx.return_value = True
        self.screens.set_current_display(0)
        display = MagicMock()

        # WHEN: The default controller is built.
        main_display = MainDisplay(display)

        # THEN: The window flags and state should be the same as those needed on Mac OS X for the primary display.
        self.assertEqual(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint, main_display.windowFlags(),
                         'The window flags should be Qt.Window and Qt.FramelessWindowHint.')
        self.assertEqual(QtCore.Qt.WindowFullScreen, main_display.windowState(),
                         'The window state should be full screen.')
Exemple #8
0
    def set_transparency_enabled_test(self):
        """
        Test setting the display to be transparent
        """
        # GIVEN: An instance of MainDisplay
        display = MagicMock()
        main_display = MainDisplay(display)

        # WHEN: Transparency is enabled
        main_display.set_transparency(True)

        # THEN: The transparent stylesheet should be used
        self.assertEqual(TRANSPARENT_STYLESHEET, main_display.styleSheet(),
                         'The MainDisplay should use the transparent stylesheet')
        self.assertFalse(main_display.autoFillBackground(),
                         'The MainDisplay should not have autoFillBackground set')
        self.assertTrue(main_display.testAttribute(QtCore.Qt.WA_TranslucentBackground),
                        'The MainDisplay should have a translucent background')
Exemple #9
0
    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()
Exemple #10
0
    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)
Exemple #11
0
 def bootstrap_initialise(self):
     """
     Initialise functions
     """
     self.display = MainDisplay(self)
     self.display.setup()