From a23a23cbcfa27366da9d12e535899864f6eb4cbd Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 28 May 2013 11:31:56 +0000 Subject: Remove QUICK_TEST_SCENEGRAPH. This is outdated (QSGView and friends are long gone) and not really needed given that Qt 5 has its own copy of this code living in qtdeclarative. Change-Id: I947366ce280a87c59c9e60f6665f8c6ab52b832f Reviewed-by: Matthew Vogt --- src/quicktestlib/quicktest.cpp | 193 +++++++++++------------------------- src/quicktestlib/quicktestevent.cpp | 30 ++---- 2 files changed, 65 insertions(+), 158 deletions(-) (limited to 'src') diff --git a/src/quicktestlib/quicktest.cpp b/src/quicktestlib/quicktest.cpp index b7c42dc..029b8d7 100644 --- a/src/quicktestlib/quicktest.cpp +++ b/src/quicktestlib/quicktest.cpp @@ -48,10 +48,6 @@ #include #include #include -#if defined(QML_VERSION) && QML_VERSION >= 0x020000 -#include -#define QUICK_TEST_SCENEGRAPH 1 -#endif #include #include #include @@ -119,11 +115,9 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport // -import dir Specify an import directory. // -input dir Specify the input directory for test cases. // -translation file Specify a .qm file to load - // -qtquick2 Run with QtQuick 2 rather than QtQuick 1. QStringList imports; QStringList qmfiles; QString testPath; - bool qtQuick2 = false; int outargc = 1; int index = 1; while (index < argc) { @@ -135,9 +129,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], "-qtquick2") == 0) { - qtQuick2 = true; - ++index; } else if (strcmp(argv[index], "-translation") == 0) { qmfiles += stripQuotes(QString::fromLocal8Bit(argv[index + 1])); index += 2; @@ -191,132 +182,66 @@ 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 QDeclarativeView. -#ifdef QUICK_TEST_SCENEGRAPH - if (qtQuick2) { - 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); - QScriptEngine *engine; - engine = QDeclarativeDebugHelper::getScriptEngine(view.engine()); - QScriptValue qtObject - = engine->globalObject().property(QLatin1String("Qt")); - qtObject.setProperty - (QLatin1String("qtest_wrapper"), QScriptValue(true)); - qtObject.setProperty - (QLatin1String("qtest_printAvailableFunctions"), - QScriptValue(QTest::printAvailableFunctions)); - foreach (QString path, imports) - view.engine()->addImportPath(path); - 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() == QSGView::Error) { - // Error compiling the test - flag failure in the log and continue. - QList errors = view.errors(); - QuickTestResult results; - results.setTestCaseName(fi.baseName()); - results.startLogging(); - results.setFunctionName(QLatin1String("compile")); - results.setFunctionType(QuickTestResult::Func); - results.fail(errors.at(0).description(), - errors.at(0).url().toString(), - errors.at(0).line()); - results.finishTestFunction(); - results.setFunctionName(QString()); - results.setFunctionType(QuickTestResult::NoWhere); - results.stopLogging(); - 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) - eventLoop.exec(); - } + foreach (QString file, files) { + QFileInfo fi(file); + if (!fi.exists()) + continue; + QDeclarativeView view; + QTestRootObject rootobj; + QEventLoop eventLoop; + QObject::connect(view.engine(), SIGNAL(quit()), + &rootobj, SLOT(quit())); + QObject::connect(view.engine(), SIGNAL(quit()), + &eventLoop, SLOT(quit())); + if (createViewport) + view.setViewport((*createViewport)()); + view.rootContext()->setContextProperty + (QLatin1String("qtest"), &rootobj); + QScriptEngine *engine; + engine = QDeclarativeDebugHelper::getScriptEngine(view.engine()); + QScriptValue qtObject + = engine->globalObject().property(QLatin1String("Qt")); + qtObject.setProperty + (QLatin1String("qtest_wrapper"), QScriptValue(true)); + qtObject.setProperty + (QLatin1String("qtest_printAvailableFunctions"), + QScriptValue(QTest::printAvailableFunctions)); + foreach (QString path, imports) + view.engine()->addImportPath(path); + 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() == QDeclarativeView::Error) { + // Error compiling the test - flag failure in the log and continue. + QList errors = view.errors(); + QuickTestResult results; + results.setTestCaseName(fi.baseName()); + results.startLogging(); + results.setFunctionName(QLatin1String("compile")); + results.setFunctionType(QuickTestResult::Func); + results.fail(errors.at(0).description(), + errors.at(0).url().toString(), + errors.at(0).line()); + results.finishTestFunction(); + results.setFunctionName(QString()); + results.setFunctionType(QuickTestResult::NoWhere); + results.stopLogging(); + continue; } - } else -#endif - { - foreach (QString file, files) { - QFileInfo fi(file); - if (!fi.exists()) - continue; - QDeclarativeView view; - QTestRootObject rootobj; - QEventLoop eventLoop; - QObject::connect(view.engine(), SIGNAL(quit()), - &rootobj, SLOT(quit())); - QObject::connect(view.engine(), SIGNAL(quit()), - &eventLoop, SLOT(quit())); - if (createViewport) - view.setViewport((*createViewport)()); - view.rootContext()->setContextProperty - (QLatin1String("qtest"), &rootobj); - QScriptEngine *engine; - engine = QDeclarativeDebugHelper::getScriptEngine(view.engine()); - QScriptValue qtObject - = engine->globalObject().property(QLatin1String("Qt")); - qtObject.setProperty - (QLatin1String("qtest_wrapper"), QScriptValue(true)); - qtObject.setProperty - (QLatin1String("qtest_printAvailableFunctions"), - QScriptValue(QTest::printAvailableFunctions)); - foreach (QString path, imports) - view.engine()->addImportPath(path); - 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() == QDeclarativeView::Error) { - // Error compiling the test - flag failure in the log and continue. - QList errors = view.errors(); - QuickTestResult results; - results.setTestCaseName(fi.baseName()); - results.startLogging(); - results.setFunctionName(QLatin1String("compile")); - results.setFunctionType(QuickTestResult::Func); - results.fail(errors.at(0).description(), - errors.at(0).url().toString(), - errors.at(0).line()); - results.finishTestFunction(); - results.setFunctionName(QString()); - results.setFunctionType(QuickTestResult::NoWhere); - results.stopLogging(); - 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) - eventLoop.exec(); - } + 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) + eventLoop.exec(); } } diff --git a/src/quicktestlib/quicktestevent.cpp b/src/quicktestlib/quicktestevent.cpp index fe66cbb..163e5a9 100644 --- a/src/quicktestlib/quicktestevent.cpp +++ b/src/quicktestlib/quicktestevent.cpp @@ -44,11 +44,6 @@ #include #include #include -#if defined(QML_VERSION) && QML_VERSION >= 0x020000 -#include -#include -#define QUICK_TEST_SCENEGRAPH 1 -#endif #include QT_BEGIN_NAMESPACE @@ -123,21 +118,13 @@ namespace QtQuickTest QPoint pos; QDeclarativeView *view = qobject_cast(widget); QWidget *eventWidget = widget; -#ifdef QUICK_TEST_SCENEGRAPH - QSGItem *sgitem = qobject_cast(item); - if (sgitem) { - pos = sgitem->mapToScene(_pos).toPoint(); - } else -#endif - { - QDeclarativeItem *ditem = qobject_cast(item); - if (!ditem) { - qWarning("Mouse event target is not an Item"); - return; - } - pos = view->mapFromScene(ditem->mapToScene(_pos)); - eventWidget = view->viewport(); + QDeclarativeItem *ditem = qobject_cast(item); + if (!ditem) { + qWarning("Mouse event target is not an Item"); + return; } + pos = view->mapFromScene(ditem->mapToScene(_pos)); + eventWidget = view->viewport(); QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); @@ -250,11 +237,6 @@ bool QuickTestEvent::mouseMove QWidget *QuickTestEvent::eventWidget() { -#ifdef QUICK_TEST_SCENEGRAPH - QSGItem *sgitem = qobject_cast(parent()); - if (sgitem) - return sgitem->canvas(); -#endif QDeclarativeItem *item = qobject_cast(parent()); if (!item) return 0; -- cgit v1.2.3