aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-03-23 01:00:08 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-03-25 10:13:23 +0100
commita1e38651ce245edcd8628bc8e2aad7e83184066e (patch)
tree27d3a68ac4204975faa6d0d427970fb1013e0ed4 /src/qmltest
parent3980ccf785462dc7b2cb53f72790638eb9e7b8c0 (diff)
parent42ed40cf0abd0155d6e6d1ef01faf9bded065588 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: .qmake.conf src/qmltest/quicktest.cpp tests/auto/qml/qmlcachegen/qmlcachegen.pro Change-Id: I70e96e8817d59647f876b8b77b30cdeede8f0662
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/doc/src/qtquicktest-index.qdoc13
-rw-r--r--src/qmltest/quicktest.cpp12
2 files changed, 18 insertions, 7 deletions
diff --git a/src/qmltest/doc/src/qtquicktest-index.qdoc b/src/qmltest/doc/src/qtquicktest-index.qdoc
index 4c0124689b..668d6c1417 100644
--- a/src/qmltest/doc/src/qtquicktest-index.qdoc
+++ b/src/qmltest/doc/src/qtquicktest-index.qdoc
@@ -149,11 +149,13 @@
\header
\li Name
\li Purpose
+ \li Since
\row
\li \c {void applicationAvailable()}
\li Called right after the QApplication object was instantiated.
- Use this function to setup everything that is not related
- to QML directly.
+ Use this function to perform setup that does not require a
+ \l QQmlEngine instance.
+ \li Qt 5.12
\row
\li \c {void qmlEngineAvailable(QQmlEngine *)}
\li Called when the QML engine is available.
@@ -161,10 +163,17 @@
\l {QQmlEngine::addPluginPath}{plugin paths},
and \l {QQmlFileSelector::setExtraSelectors}{extra file selectors}
will have been set on the engine by this point.
+
+ This function can be used to \l {Choosing the Correct Integration
+ Method Between C++ and QML}{register QML types} and
+ \l {QQmlEngine::addImportPath()}{add import paths},
+ amongst other things.
+ \li Qt 5.11
\row
\li \c {void cleanupTestCase()}
\li Called right after the test execution has finished.
Use this function to clean up before everything will start to be destructed.
+ \li Qt 5.12
\endtable
Each function will be called once for each \c {tst_*.qml} file, so any
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 9a73726797..9cddf61543 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -575,6 +575,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)
+ maybeInvokeSetupMethod(setup, "qmlEngineAvailable(QQmlEngine*)", Q_ARG(QQmlEngine*, &engine));
+
TestCaseCollector testCaseCollector(fi, &engine);
if (!testCaseCollector.errors().isEmpty()) {
for (const QQmlError &error : testCaseCollector.errors())
@@ -606,11 +613,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)
- maybeInvokeSetupMethod(setup, "qmlEngineAvailable(QQmlEngine*)", Q_ARG(QQmlEngine*, view.engine()));
-
view.setObjectName(fi.baseName());
view.setTitle(view.objectName());
QTestRootObject::instance()->init();