From 5f018216f680e8226b46aa3939abec52047eaee7 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Thu, 8 Mar 2012 14:04:25 +1000 Subject: [PATCH] Remove the rest of qtquick 1.0 code from qmltest Change-Id: I0d20583faf1a75f287dcd866b11457254d250354 Reviewed-by: Matthew Vogt Reviewed-by: Michael Brasser --- src/qmltest/qmltest.pro | 3 +- src/qmltest/quicktest.cpp | 95 +++++++++++++++++------------------------- src/qmltest/quicktestevent.cpp | 35 ++-------------- 3 files changed, 43 insertions(+), 90 deletions(-) diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index d2e90c2..b1c99d2 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -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 - diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index e6c27ee..2e32a60 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -43,14 +43,10 @@ #include "quicktestresult_p.h" #include #include "qtestoptions_p.h" -#include #include #include #include -#if defined(QML_VERSION) && QML_VERSION >= 0x020000 #include -#define QUICK_TEST_SCENEGRAPH 1 -#endif #include #include #include @@ -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. diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index f996adb..9405171 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -42,12 +42,8 @@ #include "quicktestevent_p.h" #include #include -#if defined(QML_VERSION) && QML_VERSION >= 0x020000 #include #include -#define QUICK_TEST_SCENEGRAPH 1 -#endif -#include QT_BEGIN_NAMESPACE @@ -114,15 +110,9 @@ namespace QtQuickTest } QPoint pos; -#ifdef QUICK_TEST_SCENEGRAPH QQuickItem *sgitem = qobject_cast(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(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(parent()); if (sgitem) return sgitem->canvas(); -#endif return 0; - /* - QQuickItem *item = qobject_cast(parent()); - if (!item) - return 0; - QGraphicsScene *s = item->scene(); - if (!s) - return 0; - QList views = s->views(); - if (views.isEmpty()) - return 0; - return views.at(0)->windowHandle(); - */ } QT_END_NAMESPACE -- 2.7.4