def test_scrape_process(self): urls = [ 'http://www.pythonic.me', 'http://www.onet.pl', 'http://www.wp.pl', 'http://www.allegro.pl', 'http://www.wykop.pl' ] urls_number = len(urls) self.form.show() QTest.qWaitForWindowShown(self.form) self.form.load_urls(urls) self.assertIn('urls in queue', self.form.statusBar().currentMessage()) self.assertEqual(urls_number, len(self.form.scraper_dialog.urls)) QTest.mouseClick(self.form.open_scraper_button, Qt.LeftButton) QTest.qWaitForWindowShown(self.form.scraper_dialog) QTest.mouseClick(self.form.scraper_dialog.start_button, Qt.LeftButton) while self.form.scraper_dialog.scraper_thread.isRunning(): QApplication.processEvents() self.assertIn( 'keep-alive', self.form.scraper_dialog.result_plain_text_edit.toPlainText())
def test_mouse_drag(self): """Test setting extents by dragging works. This currently fails as QTest does not properly do the mouse interactions with the canvas. """ # Imported here because it is not available in OSX QGIS bundle # pylint: disable=redefined-outer-name from PyQt4.QtTest import QTest # Click the capture button QTest.mouseClick(self.dialog.capture_button, Qt.LeftButton) # drag a rect on the canvas QTest.mousePress(CANVAS, Qt.LeftButton, pos=QPoint(0, 0), delay=500) QTest.mouseRelease( CANVAS, Qt.LeftButton, pos=QPoint(300, 300), delay=-1) # on drag the extents selector windows should appear again QTest.qWaitForWindowShown(self.dialog) # Click ok to dispose of the window again ok = self.dialog.button_box.button(QtGui.QDialogButtonBox.Ok) QTest.mouseClick(ok, Qt.LeftButton) # Check the extent emitted on closing teh dialog is correct expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0) self.assertEqual(self.extent.toString(), expected_extent.toString())
def test_mouse_drag(self): """Test setting extents by dragging works. This currently fails as QTest does not properly do the mouse interactions with the canvas. """ # Click the capture button QTest.mouseClick(self.dialog.capture_button, Qt.LeftButton) # drag a rect on the canvas QTest.mousePress(CANVAS, Qt.LeftButton, pos=QPoint(0, 0), delay=500) QTest.mouseRelease(CANVAS, Qt.LeftButton, pos=QPoint(300, 300), delay=-1) # on drag the extents selector windows should appear again QTest.qWaitForWindowShown(self.dialog) # Click ok to dispose of the window again ok = self.dialog.button_box.button(QtGui.QDialogButtonBox.Ok) QTest.mouseClick(ok, Qt.LeftButton) # Check the extent emitted on closing teh dialog is correct expected_extent = QgsRectangle(10.0, 10.0, 30.0, 20.0) self.assertEqual(self.extent.toString(), expected_extent.toString())
def setUp(self): self.d = Driver() self.d.show() self.d.raise_() self.debug = self.d.config.debug QTest.qWaitForWindowShown(self.d) if not utils.isMac(): self.d.working_dir = 'Z:\Windows\pyRouterJig\images'
def execWithArgs(): core.mainWindow().show() QTest.qWaitForWindowShown(core.mainWindow()) app = QApplication.instance() app.setActiveWindow(core.mainWindow()) assert app.focusWidget() is not None func(*args) # When done processing these events, exit the event loop. To do so, timer.start(0)
def execWithArgs(): self.qpart.show() QTest.qWaitForWindowShown(self.qpart) _processPendingEvents(self.app) try: func(*args) finally: _processPendingEvents(self.app) self.app.quit()
def execWithArgs(): core.mainWindow().show() QTest.qWaitForWindowShown(core.mainWindow()) while self.app.hasPendingEvents(): self.app.processEvents() try: func(*args) finally: self.app.quit()
def execWithArgs(): core.mainWindow().show() QTest.qWaitForWindowShown(core.mainWindow()) while self.app.hasPendingEvents(): self.app.processEvents() try: func(*args) finally: self.app.quit()
def execWithArgs(): self.qpart.show() QTest.qWaitForWindowShown(self.qpart) _processPendingEvents(self.app) try: func(*args) finally: _processPendingEvents(self.app) self.app.quit()
def test_window(self): parent = FakeParent() window = regexReferenceWindow.RegexReferenceWindow(parent) window.show() QTest.qWaitForWindowShown(window) item = window.referenceTreeWidget.topLevelItem(0) window.referenceTreeWidget.setItemSelected(item, True) window.editPaste() window.close()
def test_dialog(self): parent = FakeParent() msg = 'Error message' dialog = reportBugDialog.ReportBugDialog(parent, msg) dialog.show() QTest.qWaitForWindowShown(dialog) dialog.copyToClipboard() dialog.close() clipboard = QtGui.QApplication.clipboard() self.assertEqual(msg, clipboard.text())
def test_basic(self): # TODO: rewrite all this. slot = Mock() self.view.step_report_changed.connect(slot) # show the widget self.view.show() QTest.qWaitForWindowShown(self.view) # start the bisection self.view.model().started() self.view.model().step_started(Mock()) # a row is inserted index = self.view.model().index(0, 0) self.assertTrue(index.isValid()) # simulate a build found build_infos = {"build_type": 'nightly', 'build_date': 'date'} bisection = Mock() bisection.handler.find_fix = False bisection.handler.get_range.return_value = (1, 2) self.view.model().step_build_found(bisection, build_infos) # now we have two rows self.assertEquals(self.view.model().rowCount(), 2) # data is updated index2 = self.view.model().index(1, 0) self.assertIn('[1 - 2]', self.view.model().data(index)) self.assertIn('nightly', self.view.model().data(index2)) # simulate a build evaluation self.view.model().step_finished(None, 'g') # still two rows self.assertEquals(self.view.model().rowCount(), 2) # data is updated self.assertIn('g', self.view.model().data(index2)) # let's click on the index self.view.scrollTo(index) rect = self.view.visualRect(index) QTest.mouseClick(self.view.viewport(), Qt.LeftButton, pos=rect.center()) # signal has been emitted self.assertEquals(slot.call_count, 1) # let's simulate another bisection step bisection = Mock() bisection.handler.get_pushlog_url.return_value = "http://pl" self.view.model().step_started(bisection) self.assertEquals(self.view.model().rowCount(), 3) # then say that it's the end self.view.model().finished(bisection, None) # this last row is removed now self.assertEquals(self.view.model().rowCount(), 2)
def test_dialog(self): parent = FakeParent() dialog = importURLDialog.ImportURLDialog(parent, 'file://%s' % __file__) dialog.show() QTest.qWaitForWindowShown(dialog) dialog.importURL() qmessagebox = FakeMessageBox() importURLDialog.QMessageBox = qmessagebox dialog.URLTextEdit.setText('fake url') dialog.importURL() self.assertTrue(qmessagebox.informationCalled)
def execWithArgs(): self.qpart.show() QTest.qWaitForWindowShown(self.qpart) while self.app.hasPendingEvents(): self.app.processEvents() try: func(*args) finally: while self.app.hasPendingEvents(): self.app.processEvents() self.app.quit()
def test_basic(self): # TODO: rewrite all this. slot = Mock() self.view.step_report_changed.connect(slot) # show the widget self.view.show() QTest.qWaitForWindowShown(self.view) # start the bisection self.view.model().started() self.view.model().step_started(Mock()) # a row is inserted index = self.view.model().index(0, 0) self.assertTrue(index.isValid()) # simulate a build found build_infos = {"build_type": 'nightly', 'build_date': 'date'} bisection = Mock() bisection.handler.find_fix = False bisection.handler.get_range.return_value = (1, 2) self.view.model().step_build_found(bisection, build_infos) # now we have two rows self.assertEquals(self.view.model().rowCount(), 2) # data is updated index2 = self.view.model().index(1, 0) self.assertIn('[1 - 2]', self.view.model().data(index)) self.assertIn('nightly', self.view.model().data(index2)) # simulate a build evaluation self.view.model().step_finished(None, 'g') # still two rows self.assertEquals(self.view.model().rowCount(), 2) # data is updated self.assertIn('g', self.view.model().data(index2)) # let's click on the index self.view.scrollTo(index) rect = self.view.visualRect(index) QTest.mouseClick(self.view.viewport(), Qt.LeftButton, pos=rect.center()) # signal has been emitted self.assertEquals(slot.call_count, 1) # let's simulate another bisection step bisection = Mock() bisection.handler.get_pushlog_url.return_value = "http://pl" self.view.model().step_started(bisection) self.assertEquals(self.view.model().rowCount(), 3) # then say that it's the end self.view.model().finished(bisection, None) # this last row is removed now self.assertEquals(self.view.model().rowCount(), 2)
def test_window(self): parent = FakeParent() window = regexLibraryWindow.RegexLibraryWindow(parent) window.show() QTest.qWaitForWindowShown(window) window.descSelectedSlot(None) window.descSelectedSlot('just something') window.editPaste() window.close()
def setUp(self): self.qApp = QCoreApplication.instance() if not self.qApp: self.qApp = QApplication(sys.argv) # Set config directory self.dtmp = tempfile.mkdtemp() os.environ['XDG_CONFIG_HOME'] = self.dtmp cdir = util.getConfigDirectory() os.mkdir(cdir) self.filename1 = os.path.abspath(os.path.join(os.path.dirname(__file__), 'mwTest1.kng')) self.window = mainWindow.MainWindow() QTest.qWaitForWindowShown(self.window) self.window.preferences.askSave = False
def setUp(self): """Runs before each test.""" self.extent = QgsRectangle(10.0, 10.0, 20.0, 20.0) self.crs = QgsCoordinateReferenceSystem("EPSG:4326") CANVAS.setExtent(self.extent) self.dialog = ExtentSelectorDialog(IFACE, PARENT, self.extent, self.crs) self.signal_received = False self.dialog.extent_defined.connect(self.extent_defined) self.widget = QtGui.QWidget() self.widget.setGeometry(0, 0, 500, 500) layout = QtGui.QVBoxLayout(self.widget) layout.addWidget(CANVAS) self.widget.show() QTest.qWaitForWindowShown(self.widget) self.dialog.show() QTest.qWaitForWindowShown(self.dialog)
def setUp(self): ''' Prepare the tests. ''' # Delete any existing test database if os.path.exists(self.TEST_DB): os.remove(self.TEST_DB) # Delete any existing test configuration if os.path.exists(self.CONFIG_DB): os.remove(self.CONFIG_DB) # Patch the configuration so that the test config will be used. config.ConfigManager.the_config = None config.CONFIG_URL = self.CONFIG_URL # Start the actual Architecture Tool self.form = run.ArchitectureTool() self.form.onNew(self.TEST_DB) self.form.show() QTest.qWaitForWindowShown(self.form)
def setUp(self): """Runs before each test.""" self.extent = QgsRectangle(10.0, 10.0, 20.0, 20.0) self.crs = QgsCoordinateReferenceSystem('EPSG:4326') CANVAS.setExtent(self.extent) self.dialog = ExtentSelectorDialog(IFACE, PARENT, self.extent, self.crs) self.signal_received = False self.dialog.extent_defined.connect(self.extent_defined) self.widget = QtGui.QWidget() self.widget.setGeometry(0, 0, 500, 500) layout = QtGui.QVBoxLayout(self.widget) layout.addWidget(CANVAS) self.widget.show() QTest.qWaitForWindowShown(self.widget) self.dialog.show() QTest.qWaitForWindowShown(self.dialog)
def test_checkForKangDir(self): self.window.close() # Do not use the standard window mainWindow.NewUserDialog = FakeDialog mainWindow.QMessageBox = FakeMessageBox self.dtmp = tempfile.mkdtemp() os.environ['XDG_CONFIG_HOME'] = self.dtmp # here user configuration directory doesn't exist # checkForKangDir is called in the __init__ so it creates the directory window = mainWindow.MainWindow() QTest.qWaitForWindowShown(window) # here the user configuration directory exists window.checkForKangDir() # here the creation of user configuration directory will fail os.environ['XDG_CONFIG_HOME'] = '/' window.checkForKangDir() os.environ['XDG_CONFIG_HOME'] = self.dtmp window.close()
def qWaitForWindowActive(QWidget): OldQTest.qWaitForWindowShown(QWidget)
def execWithArgs(): core.mainWindow().show() QTest.qWaitForWindowShown(core.mainWindow()) func(*args) # When done processing these events, exit the event loop. QTimer.singleShot(0, self.app.quit)
def screenshot(self, do_screenshot=True): QTest.qWaitForWindowShown(self.d) QTest.qWait(100) self.d._on_save(do_screenshot)
def setUp(self): self.d = Driver() self.d.show() self.d.raise_() self.debug = self.d.config.debug QTest.qWaitForWindowShown(self.d)
def test_dialog(self): parent = FakeParent() dialog = newUserDialog.NewUserDialog(parent) QTest.qWaitForWindowShown(dialog)
def test_dialog(self): parent = FakeParent() dialog = aboutDialog.AboutDialog(parent) QTest.qWaitForWindowShown(dialog)