def __loading_failure(self, has_proxy): mainloop = common.create_main_loop() app = common.create_pitivi_mock(lastProjectFolder="/tmp", edgeSnapDeadband=32) app.project_manager = ProjectManager(app) mainwindow = MainWindow(app) mainwindow.viewer = mock.MagicMock() def __pm_missing_uri_cb(project_manager, project, error, asset): nonlocal mainloop nonlocal mainwindow nonlocal self nonlocal app nonlocal has_proxy with mock.patch('gi.repository.Gtk.Dialog') as dialog: failed_cb = mock.MagicMock() app.project_manager.connect("new-project-failed", failed_cb) dialog.return_value = mock.MagicMock() dialog.return_value.run = mock.MagicMock( return_value=Gtk.ResponseType.CLOSE) # Call the actual callback # pylint: disable=protected-access app.proxy_manager.checkProxyLoadingSucceeded = \ mock.MagicMock(return_value=has_proxy) mainwindow._projectManagerMissingUriCb(project_manager, project, error, asset) self.assertTrue(dialog.called) self.assertTrue(dialog.return_value.run.called) self.assertEqual(failed_cb.called, not has_proxy) # pylint: disable=protected-access app.project_manager.connect("missing-uri", mainwindow._projectManagerMissingUriCb) # pylint: disable=protected-access app.project_manager.connect( "new-project-failed", mainwindow._projectManagerNewProjectFailedCb) mainwindow.destroy() mainloop.quit() # pylint: disable=protected-access disconnectAllByFunc(app.project_manager, mainwindow._projectManagerMissingUriCb) disconnectAllByFunc(app.project_manager, mainwindow._projectManagerNewProjectFailedCb) app.project_manager.connect("missing-uri", __pm_missing_uri_cb) with common.created_project_file() as uri: app.project_manager.loadProject(uri) mainloop.run()
def createMainWindow(self): if self.gui: return self.gui = MainWindow(self) self.add_window(self.gui) self.gui.checkScreenConstraints() # We might as well show it. self.gui.show()
def test_switch_context_tab(self): """Checks tab switches.""" app = common.create_pitivi_mock() mainwindow = MainWindow(app) for expected_tab, b_element in [(2, GES.TitleClip()), (0, GES.SourceClip()), (1, GES.TransitionClip())]: mainwindow.switchContextTab(b_element) self.assertEqual(mainwindow.context_tabs.get_current_page(), expected_tab, b_element) # Make sure the tab does not change when using an invalid argument. mainwindow.switchContextTab("invalid") self.assertEqual(mainwindow.context_tabs.get_current_page(), expected_tab) mainwindow.destroy()
def create_main_window(self): if self.gui: return self.gui = MainWindow(self) self.gui.setup_ui() self.add_window(self.gui)