diff options
Diffstat (limited to 'src/imports/testlib/main.cpp')
-rw-r--r-- | src/imports/testlib/main.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 3c28000e35..c625c87db7 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -54,13 +54,6 @@ QML_DECLARE_TYPE(QuickTestEvent) #include <QtDebug> -static void initResources() -{ -#ifdef QT_STATIC - Q_INIT_RESOURCE(qmake_QtTest); -#endif -} - QT_BEGIN_NAMESPACE class QuickTestUtil : public QObject @@ -69,11 +62,11 @@ class QuickTestUtil : public QObject Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged) Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged) public: - QuickTestUtil(QObject *parent = 0) + QuickTestUtil(QObject *parent = nullptr) :QObject(parent) {} - ~QuickTestUtil() + ~QuickTestUtil() override {} bool printAvailableFunctions() const { @@ -91,19 +84,19 @@ public Q_SLOTS: { QString name(v.typeName()); if (v.canConvert<QObject*>()) { - QQmlType *type = 0; + QQmlType type; const QMetaObject *mo = v.value<QObject*>()->metaObject(); - while (!type && mo) { + while (!type.isValid() && mo) { type = QQmlMetaType::qmlType(mo); mo = mo->superClass(); } - if (type) { - name = type->qmlTypeName(); + if (type.isValid()) { + name = type.qmlTypeName(); } } QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *v4 = engine->handle(); QV4::Scope scope(v4); QV4::ScopedValue s(scope, v4->newString(name)); return QQmlV4Handle(s); @@ -116,7 +109,7 @@ public Q_SLOTS: QQmlV4Handle callerFile(int frameIndex = 0) const { QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *v4 = engine->handle(); QV4::Scope scope(v4); QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2); @@ -129,7 +122,7 @@ public Q_SLOTS: int callerLine(int frameIndex = 0) const { QQmlEngine *engine = qmlEngine(this); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine->handle()); + QV4::ExecutionEngine *v4 = engine->handle(); QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2); if (stack.size() > frameIndex + 1) @@ -150,15 +143,20 @@ class QTestQmlModule : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: - QTestQmlModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } - void registerTypes(const char *uri) Q_DECL_OVERRIDE + QTestQmlModule(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } + void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); qmlRegisterType<QuickTestResult, 0>(uri,1,0,"TestResult"); qmlRegisterType<QuickTestResult, 1>(uri,1,1,"TestResult"); + qmlRegisterType<QuickTestResult, 13>(uri,1,13,"TestResult"); qmlRegisterType<QuickTestEvent>(uri,1,0,"TestEvent"); + qmlRegisterType<QuickTestEvent>(uri,1,2,"TestEvent"); qmlRegisterType<QuickTestUtil>(uri,1,0,"TestUtil"); qmlRegisterType<QQuickTouchEventSequence>(); + + // Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward + qmlRegisterModule(uri, 1, QT_VERSION_MINOR); } }; |