Commit 8cc06c36 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Small fix on test helper

Make sure we don't register tests twice
exit(0) when the test succeeds
parent 7df184af
......@@ -53,6 +53,9 @@ void CoronaTestHelper::processApplet(Plasma::Applet* applet)
void CoronaTestHelper::integrateTest(QObject* testObject)
{
if (m_registeredTests.contains(testObject))
return;
const int signal = testObject->metaObject()->indexOfSignal("done()");
if (signal < 0) {
qCWarning(PLASMASHELL) << "the test object should offer a 'done()' signal" << testObject;
......@@ -65,6 +68,7 @@ void CoronaTestHelper::integrateTest(QObject* testObject)
qCDebug(PLASMASHELL) << "Test registered" << testObject;
m_tests.insert(testObject);
m_registeredTests << testObject;
connect(testObject, SIGNAL(done()), this, SLOT(testFinished()));
}
......@@ -73,8 +77,11 @@ void CoronaTestHelper::testFinished()
{
QObject* testObject = sender();
m_exitcode += testObject->property("failed").toBool();
const bool result = testObject->property("failed").toBool();
m_exitcode += !result;
m_tests.remove(testObject);
qCWarning(PLASMASHELL) << "test finished" << testObject << result << "remaining" << m_tests;
if (m_tests.isEmpty()) {
qGuiApp->exit(m_exitcode);
}
......
......@@ -39,6 +39,7 @@ private:
void integrateTest(QObject* testObject);
Plasma::Corona* m_corona;
QSet<QObject*> m_registeredTests;
QSet<QObject*> m_tests;
int m_exitcode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment