示例#1
0
    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())
示例#3
0
    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())
示例#4
0
 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'
示例#5
0
文件: base.py 项目: MagSec-Arts/enki
 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)
示例#6
0
        def execWithArgs():
            self.qpart.show()
            QTest.qWaitForWindowShown(self.qpart)
            _processPendingEvents(self.app)

            try:
                func(*args)
            finally:
                _processPendingEvents(self.app)
                self.app.quit()
示例#7
0
文件: base.py 项目: y0no/enki
 def execWithArgs():
     core.mainWindow().show()
     QTest.qWaitForWindowShown(core.mainWindow())
     while self.app.hasPendingEvents():
         self.app.processEvents()
     
     try:
         func(*args)
     finally:
         self.app.quit()
示例#8
0
        def execWithArgs():
            core.mainWindow().show()
            QTest.qWaitForWindowShown(core.mainWindow())
            while self.app.hasPendingEvents():
                self.app.processEvents()

            try:
                func(*args)
            finally:
                self.app.quit()
示例#9
0
        def execWithArgs():
            self.qpart.show()
            QTest.qWaitForWindowShown(self.qpart)
            _processPendingEvents(self.app)

            try:
                func(*args)
            finally:
                _processPendingEvents(self.app)
                self.app.quit()
示例#10
0
    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()
示例#11
0
    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)
示例#13
0
    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)
示例#14
0
文件: base.py 项目: cmpitg/qutepart
 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()
示例#15
0
    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)
示例#16
0
    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()
示例#17
0
    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)
示例#19
0
  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)
示例#20
0
    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)
示例#21
0
    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()
示例#22
0
 def qWaitForWindowActive(QWidget):
     OldQTest.qWaitForWindowShown(QWidget)
示例#23
0
文件: base.py 项目: emiola/enki
 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)
示例#24
0
 def screenshot(self, do_screenshot=True):
     QTest.qWaitForWindowShown(self.d)
     QTest.qWait(100)
     self.d._on_save(do_screenshot)
示例#25
0
 def setUp(self):
     self.d = Driver()
     self.d.show()
     self.d.raise_()
     self.debug = self.d.config.debug
     QTest.qWaitForWindowShown(self.d)
示例#26
0
 def test_dialog(self):
     parent = FakeParent()
     dialog = newUserDialog.NewUserDialog(parent)
     QTest.qWaitForWindowShown(dialog)
示例#27
0
 def test_dialog(self):
     parent = FakeParent()
     dialog = aboutDialog.AboutDialog(parent)
     QTest.qWaitForWindowShown(dialog)