diff options
author | Michal Klocek <michal.klocek@qt.io> | 2021-06-17 09:45:50 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2021-06-20 23:04:13 +0200 |
commit | 376d8ddbb1a9cc174a66aeb6e2d919b28c30887f (patch) | |
tree | c20202e29cf1129a63361332cc1a75c0709d8839 /tests/auto/quick | |
parent | e90adbb6cffda30c0041b215d71198cd016e0f09 (diff) |
Fix super weird flakiness of delegates tests
Our tests load mock delegates, however using QML2_IMPORT_PATH,
which is set in tst_qmltests (qputenv) to set import path does not
always seem to work and results sometimes in loading qqc2 delegates
plugin instead.
Add setup class to add import paths to qml engine.
Pick-to: 6.2
Change-Id: I31987041e922987254bc22866d4d78f9608daf6f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qmltests/tst_qmltests.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 67b64c237..653972dfd 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -45,6 +45,19 @@ #include <unistd.h> #endif +class Setup : public QObject +{ + Q_OBJECT +public: + Setup() { } + +public slots: + void qmlEngineAvailable(QQmlEngine *engine) + { + engine->addImportPath(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/mock-delegates"); + } +}; + #if defined(Q_OS_LINUX) && defined(QT_DEBUG) static bool debuggerPresent() { @@ -140,12 +153,9 @@ int main(int argc, char **argv) sigaction(SIGSEGV, &sigAction, 0); #endif - - qputenv("QML2_IMPORT_PATH", QString(QDir(QT_TESTCASE_SOURCEDIR).canonicalPath() + "/mock-delegates").toUtf8()); // TODO: temporary solution. Remove when Quick Controls 1 is removed. qputenv("QTWEBENGINE_DIALOG_SET", QByteArray("QtQuickControls2")); QScopedPointer<Application> app; - // Force to use English language for testing due to error message checks QLocale::setDefault(QLocale("en")); @@ -178,8 +188,10 @@ int main(int argc, char **argv) "Test.Shared", 1, 0, "HttpsServer", [&](QQmlEngine *, QJSEngine *) { return new HttpsServer(":/resources/server.pem",":/resources/server.key"); }); #endif - - int i = quick_test_main(argc, argv, "qmltests", qPrintable(QT_TESTCASE_BUILDDIR + QLatin1String("/webengine.qmltests"))); + Setup setup; + int i = quick_test_main_with_setup( + argc, argv, "qmltests", + qPrintable(QT_TESTCASE_BUILDDIR + QLatin1String("/webengine.qmltests")), &setup); return i; } |