Remove the rest of qtquick 1.0 code from qmltest
authorCharles Yin <charles.yin@nokia.com>
Thu, 8 Mar 2012 04:04:25 +0000 (14:04 +1000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 01:02:49 +0000 (02:02 +0100)
Change-Id: I0d20583faf1a75f287dcd866b11457254d250354
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/qmltest/qmltest.pro
src/qmltest/quicktest.cpp
src/qmltest/quicktestevent.cpp

index d2e90c2..b1c99d2 100644 (file)
@@ -7,7 +7,7 @@ CONFIG += module
 CONFIG += dll warn_on declarative_debug
 MODULE_PRI += ../../modules/qt_qmltest.pri
 
-QT += testlib-private qml testlib quick widgets widgets-private gui
+QT +=  testlib testlib-private qml quick  gui
 DEFINES += QT_BUILD_QUICK_TEST_LIB QT_NO_URL_CAST_FROM_STRING
 
 load(qt_module_config)
@@ -34,4 +34,3 @@ HEADERS += \
 
 
 DEFINES += QT_BUILD_QUICK_TEST_LIB
-
index e6c27ee..2e32a60 100644 (file)
 #include "quicktestresult_p.h"
 #include <QtTest/qtestsystem.h>
 #include "qtestoptions_p.h"
-#include <QApplication>
 #include <QtQml/qqml.h>
 #include <QtQml/qqmlengine.h>
 #include <QtQml/qqmlcontext.h>
-#if defined(QML_VERSION) && QML_VERSION >= 0x020000
 #include <QtQuick/qquickview.h>
-#define QUICK_TEST_SCENEGRAPH 1
-#endif
 #include <QtQml/qjsvalue.h>
 #include <QtQml/qjsengine.h>
 #include <QtGui/qopengl.h>
@@ -160,12 +156,10 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
     // Look for QML-specific command-line options.
     //      -import dir         Specify an import directory.
     //      -input dir          Specify the input directory for test cases.
-    //      -qtquick1           Run with QtQuick 1 rather than QtQuick 2.
     //      -translation file   Specify the translation file.
     QStringList imports;
     QString testPath;
     QString translationFile;
-    bool qtQuick2 = true;
     int outargc = 1;
     int index = 1;
     while (index < argc) {
@@ -177,9 +171,6 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
             index += 2;
         } else if (strcmp(argv[index], "-opengl") == 0) {
             ++index;
-        } else if (strcmp(argv[index], "-qtquick1") == 0) {
-            qtQuick2 = false;
-            ++index;
         } else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
             translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
             index += 2;
@@ -255,57 +246,49 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
 
     // Scan through all of the "tst_*.qml" files and run each of them
     // in turn with a QQuickView.
-#ifdef QUICK_TEST_SCENEGRAPH
-    if (qtQuick2) {
-        QQuickView 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 (const QString &path, imports)
-            view.engine()->addImportPath(path);
+    QQuickView 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 (const QString &path, imports)
+        view.engine()->addImportPath(path);
 
-        foreach (QString file, files) {
-            QFileInfo fi(file);
-            if (!fi.exists())
-                continue;
+    foreach (QString file, files) {
+        QFileInfo fi(file);
+        if (!fi.exists())
+            continue;
 
-            rootobj.setHasTestCase(false);
-            rootobj.setWindowShown(false);
-            rootobj.hasQuit = false;
-            QString path = fi.absoluteFilePath();
-            if (path.startsWith(QLatin1String(":/")))
-                view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2)));
-            else
-                view.setSource(QUrl::fromLocalFile(path));
+        rootobj.setHasTestCase(false);
+        rootobj.setWindowShown(false);
+        rootobj.hasQuit = 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) {
-                handleCompileErrors(fi, view);
-                continue;
-            }
-            if (!rootobj.hasQuit) {
-                // If the test already quit, then it was performed
-                // synchronously during setSource().  Otherwise it is
-                // an asynchronous test and we need to show the window
-                // and wait for the quit indication.
-                view.show();
-                QTest::qWaitForWindowShown(&view);
-                rootobj.setWindowShown(true);
-                if (!rootobj.hasQuit && rootobj.hasTestCase())
-                    eventLoop.exec();
-            }
+        if (QTest::printAvailableFunctions)
+            continue;
+        if (view.status() == QQuickView::Error) {
+            handleCompileErrors(fi, view);
+            continue;
+        }
+        if (!rootobj.hasQuit) {
+            // If the test already quit, then it was performed
+            // synchronously during setSource().  Otherwise it is
+            // an asynchronous test and we need to show the window
+            // and wait for the quit indication.
+            view.show();
+            QTest::qWaitForWindowShown(&view);
+            rootobj.setWindowShown(true);
+            if (!rootobj.hasQuit && rootobj.hasTestCase())
+                eventLoop.exec();
         }
-    } else
-#endif
-    {
-        qWarning("No suitable QtQuick1 implementation is available!");
-        return 1;
     }
 
     // Flush the current logging stream.
index f996adb..9405171 100644 (file)
 #include "quicktestevent_p.h"
 #include <QtTest/qtestkeyboard.h>
 #include <QtQml/qqml.h>
-#if defined(QML_VERSION) && QML_VERSION >= 0x020000
 #include <QtQuick/qquickitem.h>
 #include <QtQuick/qquickcanvas.h>
-#define QUICK_TEST_SCENEGRAPH 1
-#endif
-#include <QtWidgets/qgraphicsscene.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -114,15 +110,9 @@ namespace QtQuickTest
         }
 
         QPoint pos;
-#ifdef QUICK_TEST_SCENEGRAPH
         QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
-        if (sgitem) {
+        if (sgitem)
             pos = sgitem->mapToScene(_pos).toPoint();
-        } else
-#endif
-        {
-            qWarning("No suitable QtQuick1 implementation is available!");
-        }
         QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
         QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
 
@@ -168,15 +158,10 @@ namespace QtQuickTest
             QTest::qWait(delay);
 
         QPoint pos;
-#ifdef QUICK_TEST_SCENEGRAPH
         QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
-        if (sgitem) {
+        if (sgitem)
             pos = sgitem->mapToScene(_pos).toPoint();
-        } else
-#endif
-        {
-            qWarning("No suitable QtQuick1 implementation is available!");
-        }
+
         QTEST_ASSERT(buttons == Qt::NoButton || buttons & Qt::MouseButtonMask);
         QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
 
@@ -272,24 +257,10 @@ bool QuickTestEvent::mouseMove
 
 QWindow *QuickTestEvent::eventWindow()
 {
-#ifdef QUICK_TEST_SCENEGRAPH
     QQuickItem *sgitem = qobject_cast<QQuickItem *>(parent());
     if (sgitem)
         return sgitem->canvas();
-#endif
     return 0;
-    /*
-    QQuickItem *item = qobject_cast<QQuickItem *>(parent());
-    if (!item)
-        return 0;
-    QGraphicsScene *s = item->scene();
-    if (!s)
-        return 0;
-    QList<QGraphicsView *> views = s->views();
-    if (views.isEmpty())
-        return 0;
-    return views.at(0)->windowHandle();
-    */
 }
 
 QT_END_NAMESPACE