summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2022-04-21 13:14:36 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-26 19:17:35 +0000
commitb58bc98be3f70b0e2eb05ca6344971635dc6e65c (patch)
tree5cdc3697529ca5b437964bbab7e4877814c26925
parentcf8bcc0d95e7ecf1194da950aa3531c61e913349 (diff)
downloadqtapplicationmanager-b58bc98be3f70b0e2eb05ca6344971635dc6e65c.tar.gz
macos: Fix the appman-qmltestrunner
We cannot rely on the QTestRootObject::instance() method as this function is inlined by the compiler and because of that doesn't provide the same instance as used in QML. Instead we use the new singletonInstance() method to retrieve the instance from the QQmlEngine. This also enables the qml tests on macos again. Fixes: QTBUG-102736 Change-Id: Ia73bb9ce54236a30683c1fa9f5fd51a1e456aad4 Reviewed-by: Robert Griebl <robert.griebl@qt.io> (cherry picked from commit a58939de5c5a917efef77365e04a14669404de06) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/tools/appman/appman.cpp2
-rw-r--r--src/tools/testrunner/testrunner.cpp12
-rw-r--r--src/tools/testrunner/testrunner.h3
3 files changed, 10 insertions, 7 deletions
diff --git a/src/tools/appman/appman.cpp b/src/tools/appman/appman.cpp
index 3551ec20..151b91e9 100644
--- a/src/tools/appman/appman.cpp
+++ b/src/tools/appman/appman.cpp
@@ -111,7 +111,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qInfo().nospace().noquote() << "Verbose mode is " << (cfg.verbose() ? "on" : "off")
<< " (change by (un)setting $AM_VERBOSE_TEST)\n TEST: " << cfg.mainQmlFile()
<< " in " << (cfg.forceMultiProcess() ? "multi" : "single") << "-process mode";
- return TestRunner::exec();
+ return TestRunner::exec(a.qmlEngine());
#else
return MainBase::exec();
#endif
diff --git a/src/tools/testrunner/testrunner.cpp b/src/tools/testrunner/testrunner.cpp
index e6988ffe..f2a5d6e7 100644
--- a/src/tools/testrunner/testrunner.cpp
+++ b/src/tools/testrunner/testrunner.cpp
@@ -93,20 +93,22 @@ void TestRunner::initialize(const QString &testFile, const QStringList &testRunn
// Register the test object and application manager test add-on
qmlRegisterSingletonType<AmTest>("QtApplicationManager.SystemUI", 2, 0, "AmTest", amTest);
-
- QTestRootObject::instance()->init();
}
-int TestRunner::exec()
+int TestRunner::exec(QQmlEngine *qmlEngine)
{
QEventLoop eventLoop;
- QTestRootObject::instance()->setWindowShown(true);
+ int typeId = qmlTypeId("QtTest", 1, 2, "QTestRootObject");
+ QTestRootObject* inst = qmlEngine->singletonInstance<QTestRootObject*>(typeId);
+ inst->init();
+
+ inst->setWindowShown(true);
if (QTest::printAvailableFunctions)
return 0;
- if (QTestRootObject::instance()->hasTestCase())
+ if (inst->hasTestCase())
eventLoop.exec();
QuickTestResult::setProgramName(nullptr);
diff --git a/src/tools/testrunner/testrunner.h b/src/tools/testrunner/testrunner.h
index 271c02c5..15de10c5 100644
--- a/src/tools/testrunner/testrunner.h
+++ b/src/tools/testrunner/testrunner.h
@@ -34,6 +34,7 @@
#include <QtAppManCommon/global.h>
#include <QStringList>
+QT_FORWARD_DECLARE_CLASS(QQmlEngine)
QT_BEGIN_NAMESPACE_AM
@@ -41,7 +42,7 @@ class TestRunner
{
public:
static void initialize(const QString &testFile, const QStringList &testRunnerArguments);
- static int exec();
+ static int exec(QQmlEngine *qmlEngine);
};
QT_END_NAMESPACE_AM