aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmltest/quicktest.cpp')
-rw-r--r--src/qmltest/quicktest.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 1a5cad5d5a..5288bb34f1 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -503,6 +503,13 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
qmlFileSelector->setExtraSelectors(fileSelectors);
}
+ // Do this down here so that import paths, plugin paths, file selectors, etc. are available
+ // in case the user needs access to them. Do it _before_ the TestCaseCollector parses the
+ // QML files though, because it attempts to import modules, which might not be available
+ // if qmlRegisterType()/QQmlEngine::addImportPath() are called in qmlEngineAvailable().
+ if (setup)
+ QMetaObject::invokeMethod(setup, "qmlEngineAvailable", Q_ARG(QQmlEngine*, &engine));
+
TestCaseCollector testCaseCollector(fi, &engine);
if (!testCaseCollector.errors().isEmpty()) {
for (const QQmlError &error : testCaseCollector.errors())
@@ -534,14 +541,6 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
view.rootContext()->setContextProperty
(QLatin1String("qtest"), QTestRootObject::instance()); // Deprecated. Use QTestRootObject from Qt.test.qtestroot instead
- // Do this down here so that import paths, plugin paths,
- // file selectors, etc. are available in case the user needs access to them.
- if (setup) {
- // Don't check the return value; it's OK if it doesn't exist.
- // If we add more callbacks in the future, it makes sense if the user only implements one of them.
- QMetaObject::invokeMethod(setup, "qmlEngineAvailable", Q_ARG(QQmlEngine*, view.engine()));
- }
-
view.setObjectName(fi.baseName());
view.setTitle(view.objectName());
QTestRootObject::instance()->init();