aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-10-24 10:44:16 +1000
committerQt by Nokia <qt-info@nokia.com>2011-10-24 03:02:19 +0200
commitec0402116c20a2121619199a7fa34c61265d8acc (patch)
tree46cf07be5b8fc2259a60a808b03cfba80f81b5ff /src/qmltest
parent19a520265317373754a158456fe3739dc8399bc5 (diff)
Fix qmltestrunner hang bug when no TestCase item
Add a hasTestCase property to the global qtest object, set it to true in each TestCase's onCompleted handler. qmltestrunner only enter the event loop if this property is true to avoid infinite waiting. Task-number:QTBUG-22281 Change-Id: Id609432210ae795d8c128901e64ba0aef4551f01 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Charles Yin <charles.yin@nokia.com>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/quicktest.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 3c726d43d1..601f5dcdbd 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -72,23 +72,28 @@ class QTestRootObject : public QObject
{
Q_OBJECT
Q_PROPERTY(bool windowShown READ windowShown NOTIFY windowShownChanged)
+ Q_PROPERTY(bool hasTestCase READ hasTestCase WRITE setHasTestCase NOTIFY hasTestCaseChanged)
public:
QTestRootObject(QObject *parent = 0)
- : QObject(parent), hasQuit(false), m_windowShown(false) {}
+ : QObject(parent), hasQuit(false), m_hasTestCase(false), m_windowShown(false) {}
- bool hasQuit;
+ bool hasQuit:1;
+ bool hasTestCase() const { return m_hasTestCase; }
+ void setHasTestCase(bool value) { m_hasTestCase = value; emit hasTestCaseChanged(); }
bool windowShown() const { return m_windowShown; }
void setWindowShown(bool value) { m_windowShown = value; emit windowShownChanged(); }
Q_SIGNALS:
void windowShownChanged();
+ void hasTestCaseChanged();
private Q_SLOTS:
void quit() { hasQuit = true; }
private:
- bool m_windowShown;
+ bool m_windowShown : 1;
+ bool m_hasTestCase :1;
};
static inline QString stripQuotes(const QString &s)
@@ -192,11 +197,14 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
if (!fi.exists())
continue;
+ rootobj.setHasTestCase(false);
+
QString path = fi.absoluteFilePath();
if (path.startsWith(QLatin1String(":/")))
view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2)));
else
view.setSource(QUrl::fromLocalFile(path));
+
if (QTest::printAvailableFunctions)
continue;
if (view.status() == QQuickView::Error) {
@@ -224,7 +232,7 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
view.show();
QTest::qWaitForWindowShown(&view);
rootobj.setWindowShown(true);
- if (!rootobj.hasQuit)
+ if (!rootobj.hasQuit && rootobj.hasTestCase())
eventLoop.exec();
}
}