예제 #1
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     mocked_plugin = MagicMock()
     mocked_plugin.status = PluginStatus.Active
     mocked_plugin.icon = QtGui.QIcon()
     Registry().register('mock_plugin', mocked_plugin)
     State().add_service("mock",
                         1,
                         is_plugin=True,
                         status=PluginStatus.Active)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm'), \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
             patch('openlp.core.ui.mainwindow.ServiceManager'), \
             patch('openlp.core.ui.mainwindow.ThemeManager'), \
             patch('openlp.core.ui.mainwindow.ProjectorManager'), \
             patch('openlp.core.ui.mainwindow.HttpServer'), \
             patch('openlp.core.ui.mainwindow.WebSocketServer'), \
             patch('openlp.core.ui.mainwindow.start_zeroconf'), \
             patch('openlp.core.ui.mainwindow.PluginForm'):
         self.main_window = MainWindow()
예제 #2
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm'), \
             patch('openlp.core.ui.mainwindow.ImageManager'), \
             patch('openlp.core.ui.mainwindow.LiveController'), \
             patch('openlp.core.ui.mainwindow.PreviewController'), \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
             patch('openlp.core.ui.mainwindow.ServiceManager'), \
             patch('openlp.core.ui.mainwindow.ThemeManager'), \
             patch('openlp.core.ui.mainwindow.ProjectorManager'), \
             patch('openlp.core.ui.mainwindow.Renderer'), \
             patch('openlp.core.ui.mainwindow.websockets.WebSocketServer'), \
             patch('openlp.core.ui.mainwindow.server.HttpServer'):
         self.main_window = MainWindow()
예제 #3
0
 def setUp(self):
     """
     Set up the objects we need for all of the tests
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.process_events = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     self.add_toolbar_action_patcher = patch(
         'openlp.core.ui.mainwindow.create_action')
     self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start(
     )
     self.mocked_add_toolbar_action.side_effect = self._create_mock_action
     with patch('openlp.core.display.screens.ScreenList.__instance__',
                spec=ScreenList) as mocked_screen_list:
         mocked_screen_list.current = {
             'number': 0,
             'size': QtCore.QSize(600, 800),
             'primary': True
         }
         self.main_window = MainWindow()
예제 #4
0
    def setUp(self, mocked_init_url):
        """
        Set up anything necessary for all tests
        """
        self.tmp_folder = mkdtemp(prefix='openlp_')
        # Create a test app to keep from segfaulting
        Registry.create()
        self.registry = Registry()
        self.setup_application()
        # Mock cursor busy/normal methods.
        self.app.set_busy_cursor = MagicMock()
        self.app.set_normal_cursor = MagicMock()
        self.app.args = []
        Registry().register('application', self.app)
        Registry().set_flag('no_web_server', True)
        # Mock classes and methods used by mainwindow.
        with patch('openlp.core.ui.mainwindow.SettingsForm'), \
                patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
                patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
                patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
                patch('openlp.core.ui.mainwindow.ServiceManager'), \
                patch('openlp.core.ui.mainwindow.ThemeManager'), \
                patch('openlp.core.ui.mainwindow.ProjectorManager'), \
                patch('openlp.core.ui.mainwindow.WebSocketServer'), \
                patch('openlp.core.ui.mainwindow.HttpServer'), \
                patch('openlp.core.ui.mainwindow.start_zeroconf'), \
                patch('openlp.core.state.State.list_plugins') as mock_plugins:
            mock_plugins.return_value = []
            self.main_window = MainWindow()

        tmpdb_url = 'sqlite:///{db}'.format(
            db=os.path.join(self.tmp_folder, TEST_DB))
        mocked_init_url.return_value = tmpdb_url
        self.projector = ProjectorDB()
예제 #5
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \
             patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \
             patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \
             patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \
             patch('openlp.core.ui.mainwindow.ServiceManager') as mocked_service_manager, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.main_window = MainWindow()
예제 #6
0
 def setUp(self):
     """
     Set up the objects we need for all of the tests
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.process_events = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     self.add_toolbar_action_patcher = patch(
         'openlp.core.ui.mainwindow.create_action')
     self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start(
     )
     self.mocked_add_toolbar_action.side_effect = self._create_mock_action
     self.renderer_patcher = patch('openlp.core.display.render.Renderer')
     self.mocked_renderer = self.renderer_patcher.start()
     mocked_desktop = MagicMock()
     mocked_desktop.screenCount.return_value = 1
     mocked_desktop.screenGeometry.return_value = QtCore.QRect(
         0, 0, 1024, 768)
     mocked_desktop.primaryScreen.return_value = 1
     ScreenList.create(mocked_desktop)
     State().load_settings()
     self.main_window = MainWindow()
예제 #7
0
파일: app.py 프로젝트: simhnna/openlp
    def run(self, args):
        """
        Run the OpenLP application.

        :param args: Some Args
        """
        self.is_event_loop_active = False
        # On Windows, the args passed into the constructor are ignored. Not very handy, so set the ones we want to use.
        # On Linux and FreeBSD, in order to set the WM_CLASS property for X11, we pass "OpenLP" in as a command line
        # argument. This interferes with files being passed in as command line arguments, so we remove it from the list.
        if 'OpenLP' in args:
            args.remove('OpenLP')
        self.args.extend(args)
        # Decide how many screens we have and their size
        screens = ScreenList.create(self.desktop())
        # First time checks in settings
        has_run_wizard = Settings().value('core/has run wizard')
        if not has_run_wizard:
            ftw = FirstTimeForm()
            ftw.initialize(screens)
            if ftw.exec() == QtWidgets.QDialog.Accepted:
                Settings().setValue('core/has run wizard', True)
            elif ftw.was_cancelled:
                QtCore.QCoreApplication.exit()
                sys.exit()
        # Correct stylesheet bugs
        application_stylesheet = get_application_stylesheet()
        if application_stylesheet:
            self.setStyleSheet(application_stylesheet)
        can_show_splash = Settings().value('core/show splash')
        if can_show_splash:
            self.splash = SplashScreen()
            self.splash.show()
        # make sure Qt really display the splash screen
        self.processEvents()
        # Check if OpenLP has been upgrade and if a backup of data should be created
        self.backup_on_upgrade(has_run_wizard, can_show_splash)
        # start the main app window
        self.main_window = MainWindow()
        Registry().execute('bootstrap_initialise')
        Registry().execute('bootstrap_post_set_up')
        Registry().initialise = False
        self.main_window.show()
        if can_show_splash:
            # now kill the splashscreen
            log.debug('Splashscreen closing')
            self.splash.close()
            log.debug('Splashscreen closed')
        # make sure Qt really display the splash screen
        self.processEvents()
        self.main_window.repaint()
        self.processEvents()
        if not has_run_wizard:
            self.main_window.first_time()
        if Settings().value('core/update check'):
            check_for_update(self.main_window)
        self.main_window.is_display_blank()
        self.main_window.app_startup()
        return self.exec()
예제 #8
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     ScreenList.create(self.app.desktop())
     Registry().register('application', MagicMock())
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \
             patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \
             patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \
             patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \
             patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \
             patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.main_window = MainWindow()
     self.service_manager = Registry().get('service_manager')
예제 #9
0
    def run(self, args):
        """
        Run the OpenLP application.

        :param args: Some Args
        """
        self.is_event_loop_active = False
        # On Windows, the args passed into the constructor are ignored. Not very handy, so set the ones we want to use.
        # On Linux and FreeBSD, in order to set the WM_CLASS property for X11, we pass "OpenLP" in as a command line
        # argument. This interferes with files being passed in as command line arguments, so we remove it from the list.
        if 'OpenLP' in args:
            args.remove('OpenLP')
        self.args.extend(args)
        # Decide how many screens we have and their size
        screens = ScreenList.create(self.desktop())
        # First time checks in settings
        has_run_wizard = Settings().value('core/has run wizard')
        if not has_run_wizard:
            ftw = FirstTimeForm()
            ftw.initialize(screens)
            if ftw.exec() == QtWidgets.QDialog.Accepted:
                Settings().setValue('core/has run wizard', True)
            elif ftw.was_cancelled:
                QtCore.QCoreApplication.exit()
                sys.exit()
        # Correct stylesheet bugs
        application_stylesheet = ''
        if not Settings().value('advanced/alternate rows'):
            base_color = self.palette().color(QtGui.QPalette.Active,
                                              QtGui.QPalette.Base)
            alternate_rows_repair_stylesheet = \
                'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n'
            application_stylesheet += alternate_rows_repair_stylesheet
        if is_win():
            application_stylesheet += WIN_REPAIR_STYLESHEET
        if application_stylesheet:
            self.setStyleSheet(application_stylesheet)
        can_show_splash = Settings().value('core/show splash')
        if can_show_splash:
            self.splash = SplashScreen()
            self.splash.show()
        # make sure Qt really display the splash screen
        self.processEvents()
        # Check if OpenLP has been upgrade and if a backup of data should be created
        self.backup_on_upgrade(has_run_wizard, can_show_splash)
        # start the main app window
        self.main_window = MainWindow()
        Registry().execute('bootstrap_initialise')
        Registry().execute('bootstrap_post_set_up')
        Registry().initialise = False
        self.main_window.show()
        if can_show_splash:
            # now kill the splashscreen
            self.splash.finish(self.main_window)
            log.debug('Splashscreen closed')
        # make sure Qt really display the splash screen
        self.processEvents()
        self.main_window.repaint()
        self.processEvents()
        if not has_run_wizard:
            self.main_window.first_time()
        update_check = Settings().value('core/update check')
        if update_check:
            version = VersionThread(self.main_window)
            version.start()
        self.main_window.is_display_blank()
        self.main_window.app_startup()
        return self.exec()