diff options
author | Jason Erb <erb@suitabletech.com> | 2015-03-23 21:58:09 -0400 |
---|---|---|
committer | Albert Astals Cid <albert.astals@canonical.com> | 2015-03-30 18:14:58 +0000 |
commit | 20f9ab60cfc2609b42a900b0aa7b0d27ae156761 (patch) | |
tree | ff5b360968e847a7206b44d78ba001f969dab1c1 /src/qmltest | |
parent | 6e6a2166bad585fcd2f2c26aaf0b2a7ba41e8cd4 (diff) |
Improved QML test robustness and logging.
Added logging to quick_test_main and reordered for robustness
(e.g. moved "wait for load" to before error check).
Change-Id: Ifd48b5bdd1efee4301e5c4e571241762dca176ad
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/qmltest')
-rw-r--r-- | src/qmltest/quicktest.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 0c8bfab1fa..74732ee3c2 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -343,6 +343,8 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD if (QTest::printAvailableFunctions) continue; + while (view->status() == QQuickView::Loading) + QTest::qWait(10); if (view->status() == QQuickView::Error) { handleCompileErrors(fi, view); continue; @@ -361,14 +363,22 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD view->resize(200, 200); } view->show(); + if (!QTest::qWaitForWindowExposed(view)) { + qWarning().nospace() + << "Test '" << QDir::toNativeSeparators(path) << "' window not exposed after show()."; + } view->requestActivate(); - - while (view->status() == QQuickView::Loading) - QTest::qWait(10); - - QTest::qWaitForWindowActive(view); - if (view->isExposed()) + if (!QTest::qWaitForWindowActive(view)) { + qWarning().nospace() + << "Test '" << QDir::toNativeSeparators(path) << "' window not active after requestActivate()."; + } + if (view->isExposed()) { QTestRootObject::instance()->setWindowShown(true); + } else { + qWarning().nospace() + << "Test '" << QDir::toNativeSeparators(path) << "' window was never exposed! " + << "If the test case was expecting windowShown, it will hang."; + } if (!QTestRootObject::instance()->hasQuit && QTestRootObject::instance()->hasTestCase()) eventLoop.exec(); // view->hide(); Causes a crash in Qt 3D due to deletion of the GL context, see QTBUG-27696 |