only use one QSGView instance for all qml test cases
authorCharles Yin <charles.yin@nokia.com>
Fri, 14 Oct 2011 03:07:37 +0000 (13:07 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 14 Oct 2011 03:08:43 +0000 (05:08 +0200)
Change-Id: I9296e30d216b57d8cf2a11e94030781f03594aa6
Reviewed-on: http://codereview.qt-project.org/6646
Reviewed-by: Charles Yin <charles.yin@nokia.com>
src/qmltest/quicktest.cpp

index 862da0c..1503040 100644 (file)
@@ -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();