aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2023-04-02 09:40:00 +0200
committerSamuel Gaist <samuel.gaist@idiap.ch>2023-04-05 12:47:16 +0200
commit10d5066983e909e29e4bbf96ca35925b6470264a (patch)
tree130e3f3cef4a0cfaed8251e73aec5508ece1ae7a /src/qmltest
parent90da1cfc1a79f8194b6e9ce101aecb9bb84a093b (diff)
Improve QUICK_TEST_MAIN_WITH_SETUP snippet
The current snippet does not provide all the methods that are available to customize the setup and teardown of the test. This patch adds the two other methods that are called in the implementation. Pick-to: 6.5 Change-Id: Icfd298c9b987bd2a3fc6d05e588ae0962ea8ceff Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp b/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp
index 1486e26696..32e5c984ac 100644
--- a/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp
+++ b/src/qmltest/doc/snippets/src_qmltest_qquicktest.cpp
@@ -6,6 +6,7 @@
#include <QtQuickTest>
#include <QQmlEngine>
#include <QQmlContext>
+#include <QGuiApplication>
class Setup : public QObject
{
@@ -15,10 +16,21 @@ public:
Setup() {}
public slots:
+ void applicationAvailable()
+ {
+ // Initialization that only requires the QGuiApplication object to be available
+ }
+
void qmlEngineAvailable(QQmlEngine *engine)
{
+ // Initialization requiring the QQmlEngine to be constructed
engine->rootContext()->setContextProperty("myContextProperty", QVariant(true));
}
+
+ void cleanupTestCase()
+ {
+ // Implement custom resource cleanup
+ }
};
QUICK_TEST_MAIN_WITH_SETUP(mytest, Setup)