Gui: make unit tests working from command line if Gui is up
This commit is contained in:
@@ -121,6 +121,7 @@ public:
|
||||
add_varargs_method("UnitTest",&Module::new_UnitTest,"UnitTest");
|
||||
add_varargs_method("setTest",&Module::setTest,"setTest");
|
||||
add_varargs_method("addTest",&Module::addTest,"addTest");
|
||||
add_varargs_method("runTest",&Module::runTest,"runTest");
|
||||
add_varargs_method("testILoggerBlocker",&Module::testILoggerBlocker,"testILoggerBlocker");
|
||||
initialize("This module is the QtUnitGui module"); // register with Python
|
||||
}
|
||||
@@ -160,6 +161,15 @@ private:
|
||||
dlg->raise();
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object runTest(const Py::Tuple& args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args.ptr(), ""))
|
||||
throw Py::Exception();
|
||||
|
||||
TestGui::UnitTestDialog* dlg = TestGui::UnitTestDialog::instance();
|
||||
bool success = dlg->runCurrentTest();
|
||||
return Py::Boolean(success);
|
||||
}
|
||||
Py::Object testILoggerBlocker(const Py::Tuple& args) {
|
||||
(void) args;
|
||||
ILoggerBlockerTest iltest;
|
||||
|
||||
@@ -274,6 +274,19 @@ QString UnitTestDialog::getUnitTest() const
|
||||
return ui->comboTests->currentText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the currently selected test and closes the dialog afterwards.
|
||||
* It returns true if all tests have passed and false otherwise.
|
||||
*/
|
||||
bool UnitTestDialog::runCurrentTest()
|
||||
{
|
||||
clearErrorList();
|
||||
on_startButton_clicked();
|
||||
int count = ui->treeViewFailure->topLevelItemCount();
|
||||
reject();
|
||||
return (count == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text in the status bar.
|
||||
*/
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
void setUnitTest(const QString& unit);
|
||||
void clearUnitTests();
|
||||
QString getUnitTest() const;
|
||||
bool runCurrentTest();
|
||||
void setStatusText(const QString& text);
|
||||
void setProgressFraction(float fraction, const QString& = QString());
|
||||
void clearErrorList();
|
||||
|
||||
Reference in New Issue
Block a user