From: Charles Yin Date: Fri, 14 Oct 2011 03:07:37 +0000 (+1000) Subject: only use one QSGView instance for all qml test cases X-Git-Tag: qt-v5.0.0-alpha1~1384 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8cbd59e253474899ffa2b7d3d04d8c5a6b09a099;p=profile%2Fivi%2Fqtdeclarative.git only use one QSGView instance for all qml test cases Change-Id: I9296e30d216b57d8cf2a11e94030781f03594aa6 Reviewed-on: http://codereview.qt-project.org/6646 Reviewed-by: Charles Yin --- diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 862da0c..1503040 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -175,21 +175,23 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport // in turn with a QDeclarativeView. #ifdef QUICK_TEST_SCENEGRAPH if (qtQuick2) { + QSGView view; + QTestRootObject rootobj; + QEventLoop eventLoop; + QObject::connect(view.engine(), SIGNAL(quit()), + &rootobj, SLOT(quit())); + QObject::connect(view.engine(), SIGNAL(quit()), + &eventLoop, SLOT(quit())); + view.rootContext()->setContextProperty + (QLatin1String("qtest"), &rootobj); + foreach (QString path, imports) + view.engine()->addImportPath(path); + foreach (QString file, files) { QFileInfo fi(file); if (!fi.exists()) continue; - QSGView view; - QTestRootObject rootobj; - QEventLoop eventLoop; - QObject::connect(view.engine(), SIGNAL(quit()), - &rootobj, SLOT(quit())); - QObject::connect(view.engine(), SIGNAL(quit()), - &eventLoop, SLOT(quit())); - view.rootContext()->setContextProperty - (QLatin1String("qtest"), &rootobj); - foreach (QString path, imports) - view.engine()->addImportPath(path); + QString path = fi.absoluteFilePath(); if (path.startsWith(QLatin1String(":/"))) view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2))); @@ -220,8 +222,7 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport // an asynchronous test and we need to show the window // and wait for the quit indication. view.show(); - //QTest::qWaitForWindowShown(&view); - QTest::qWait(50); + QTest::qWaitForWindowShown(&view); rootobj.setWindowShown(true); if (!rootobj.hasQuit) eventLoop.exec();