Example #1
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.ui.testcases.setSortingEnabled(True)
        self.ts = None

        self.aborted = False
Example #2
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.ui.testcases.setSortingEnabled(True)
        self.ts = None

        self.aborted = False
Example #3
0
class MyForm(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.ui.testcases.setSortingEnabled(True)
        self.ts = None

        self.aborted = False

    def _update_buttons(self, executing):
        self.ui.execute.setEnabled(not executing)
        self.ui.execute_all.setEnabled(not executing)
        self.ui.reload.setEnabled(not executing)
        self.ui.stop.setEnabled(executing)

    def add_log(self, message):
        self.ui.logs.append(message)

    def network_error(self):
        QtGui.QMessageBox.warning(
            None, QString(sys.argv[0]), QString("Can't connect to ManualMode. Check if ManualMode-XMLRPC is running.")
        )
        self.stop_event()

    def handle_execute(self, all=False):
        class Testing(QtCore.QThread):
            def __init__(self, form, all):
                QtCore.QThread.__init__(self)
                self.form = form
                self.all = all
                self.connect(self, SIGNAL("add_log"), form.add_log, QtCore.Qt.QueuedConnection)

            def run(self):
                litm = self.form.ui.testcases.currentItem()

                if litm or all:
                    self.form._update_buttons(True)
                    timeStart = time.clock()
                    self.form.aborted = False
                    if not self.all:
                        self.form.ts.execute(litm.text())
                    else:
                        for i in range(0, self.form.ui.testcases.count()):
                            if self.form.aborted:
                                break
                            litm = self.form.ui.testcases.item(i)
                            self.form.ts.execute(litm.text())
                    timeEnd = time.clock()
                    self.emit(SIGNAL("add_log"), "Total execution time: %.3f seconds" % (timeEnd - timeStart))
                    self.form._update_buttons(False)

        self.testing = Testing(self, all)
        self.testing.start()

    def execute_event(self):
        self.handle_execute()

    def execute_all_event(self):
        self.handle_execute(all=True)

    def stop_event(self):
        self.aborted = True
        self.ts.stop()
        self._update_buttons(False)

    def logs_event(self):
        c = self.ui.logs.textCursor()
        c.movePosition(QTextCursor.End)
        self.ui.logs.setTextCursor(c)

    def reload_event(self):
        if self.ui.directory.displayText():
            for i in range(0, self.ui.testcases.count()):
                self.ui.testcases.takeItem(0)

            self.ts = TestSuite(str(self.ui.directory.displayText()), self)
            for tcf in self.ts.tc_files:
                self.ui.testcases.addItem(unicode(tcf))

    def add_log(self, message):
        self.ui.logs.append(message)

    def get_directory_event(self):
        self.ui.directory.setText(QtGui.QFileDialog.getExistingDirectory())
        self.reload_event()
Example #4
0
class MyForm(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_Form()
        self.ui.setupUi(self)

        self.ui.testcases.setSortingEnabled(True)
        self.ts = None

        self.aborted = False

    def _update_buttons(self, executing):
        self.ui.execute.setEnabled(not executing)
        self.ui.execute_all.setEnabled(not executing)
        self.ui.reload.setEnabled(not executing)
        self.ui.stop.setEnabled(executing)

    def add_log(self, message):
        self.ui.logs.append(message)

    def network_error(self):
        QtGui.QMessageBox.warning(
            None, QString(sys.argv[0]),
            QString(
                'Can\'t connect to ManualMode. Check if ManualMode-XMLRPC is running.'
            ))
        self.stop_event()

    def handle_execute(self, all=False):
        class Testing(QtCore.QThread):
            def __init__(self, form, all):
                QtCore.QThread.__init__(self)
                self.form = form
                self.all = all
                self.connect(self, SIGNAL('add_log'), form.add_log,
                             QtCore.Qt.QueuedConnection)

            def run(self):
                litm = self.form.ui.testcases.currentItem()

                if litm or all:
                    self.form._update_buttons(True)
                    timeStart = time.clock()
                    self.form.aborted = False
                    if not self.all:
                        self.form.ts.execute(litm.text())
                    else:
                        for i in range(0, self.form.ui.testcases.count()):
                            if self.form.aborted:
                                break
                            litm = self.form.ui.testcases.item(i)
                            self.form.ts.execute(litm.text())
                    timeEnd = time.clock()
                    self.emit(
                        SIGNAL('add_log'),
                        'Total execution time: %.3f seconds' %
                        (timeEnd - timeStart))
                    self.form._update_buttons(False)

        self.testing = Testing(self, all)
        self.testing.start()

    def execute_event(self):
        self.handle_execute()

    def execute_all_event(self):
        self.handle_execute(all=True)

    def stop_event(self):
        self.aborted = True
        self.ts.stop()
        self._update_buttons(False)

    def logs_event(self):
        c = self.ui.logs.textCursor()
        c.movePosition(QTextCursor.End)
        self.ui.logs.setTextCursor(c)

    def reload_event(self):
        if self.ui.directory.displayText():
            for i in range(0, self.ui.testcases.count()):
                self.ui.testcases.takeItem(0)

            self.ts = TestSuite(str(self.ui.directory.displayText()), self)
            for tcf in self.ts.tc_files:
                self.ui.testcases.addItem(unicode(tcf))

    def add_log(self, message):
        self.ui.logs.append(message)

    def get_directory_event(self):
        self.ui.directory.setText(QtGui.QFileDialog.getExistingDirectory())
        self.reload_event()