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()
def setUp(self): """ Create the UI """ Registry.create() self.setup_application() ScreenList.create(self.app.desktop()) self.image_manager = ImageManager() self.lock = Lock() self.sleep_time = 0.1
def setUp(self): """ Setup for tests """ Registry.create() self.registry = Registry() self.mocked_live_controller = MagicMock() self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] with patch('openlp.core.display.screens.QtWidgets.QApplication.screens') as mocked_screens: mocked_screens.return_value = [ MagicMock(**{'geometry.return_value': SCREEN['size']}) ] self.screens = ScreenList.create(self.desktop) # Mock the renderer and its format_slide method self.mocked_renderer = MagicMock() def side_effect_return_arg(arg1, arg2): return [arg1] self.mocked_slide_formater = MagicMock(side_effect=side_effect_return_arg) self.mocked_renderer.format_slide = self.mocked_slide_formater Registry().register('live_controller', self.mocked_live_controller) Registry().register('renderer', self.mocked_renderer) Registry().register('settings', MagicMock(**{'value.return_value': 'english'}))
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()
def setUp(self): """ Set up the components need for all tests """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Registry.create()
def setUp(self): """ Some pre-test setup required. """ self.dummy1 = MagicMock() self.dummy2 = MagicMock() self.dummy3 = MagicMock() self.desktop = MagicMock() self.setup_application() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Registry.create() self.form = settingsform.SettingsForm()
def setUp(self): """ Setup for tests """ Registry.create() self.registry = Registry() self.mocked_live_controller = MagicMock() self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) renderer = Renderer() renderer.empty_height = 1000 Registry().register('live_controller', self.mocked_live_controller)
def setUp(self): """ Set up the components need for all tests. """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.application = QtWidgets.QApplication.instance() Registry.create() self.application.setOrganizationName('OpenLP-tests') self.application.setOrganizationDomain('openlp.org') self.screens = ScreenList.create(self.desktop)
def setUp(self): """ Set up the components need for all tests. """ self.setup_application() self.build_settings() # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Settings().extend_default_settings(__default_settings__) self.temp_folder_path = Path(mkdtemp()) self.thumbnail_folder_path = Path(mkdtemp()) self.mock_plugin = MagicMock() self.mock_plugin.settings_section = self.temp_folder_path
def setUp(self): """ Set up the components need for all tests. """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = 0 self.desktop.screenCount.return_value = 2 self.desktop.screenGeometry.side_effect = lambda x: { 0: QtCore.QRect(0, 0, 1024, 768), 1: QtCore.QRect(0, 0, 1024, 768) }[x] self.screens = ScreenList.create(self.desktop) Registry.create() self.registry = Registry() self.setup_application() Registry().register('application', self.app) self.mocked_audio_player = patch( 'openlp.core.ui.maindisplay.AudioPlayer') self.mocked_audio_player.start()