aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest
diff options
context:
space:
mode:
authorJan Murawski <jan.murawski@governikus.de>2017-11-24 16:50:03 +0100
committerJan Murawski <jan.murawski@governikus.de>2017-12-05 10:42:24 +0000
commit184c5470f534119b27c1a4caec29d699aba9c234 (patch)
tree23f5afbf8fc10111bc28657dc8c179227ca7917c /src/qmltest
parent14599af2f27292710e68a6e500aa9f9cf3a30789 (diff)
Allow adding file selectors for QUICK_TEST_MAIN tests
This patch allows adding file selectors for QUICK_TEST_MAIN tests via the command line switch "-file-selector". Adding such a selector allows the test of platform specific QML components. E.g. one can test an Android component on Linux. Change-Id: I556ad7211ed4a0881150686270a9a4e69f68d1ee Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/qmltest')
-rw-r--r--src/qmltest/quicktest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index 3cd1694dd0..463833a100 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -62,6 +62,7 @@
#include <QtGui/QGuiApplication>
#include <QtCore/QTranslator>
#include <QtTest/QSignalSpy>
+#include <QtQml/QQmlFileSelector>
#include <private/qqmlcomponent_p.h>
@@ -354,10 +355,12 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
// -plugins dir Specify a directory where to search for plugins.
// -input dir Specify the input directory for test cases.
// -translation file Specify the translation file.
+ // -file-selector Specify a file selector
QStringList imports;
QStringList pluginPaths;
QString testPath;
QString translationFile;
+ QStringList fileSelectors;
int index = 1;
QScopedArrayPointer<char *> testArgV(new char *[argc + 1]);
testArgV[0] = argv[0];
@@ -382,6 +385,9 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
} else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
index += 2;
+ } else if (strcmp(argv[index], "-file-selector") == 0 && (index + 1) < argc) {
+ fileSelectors += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
+ index += 2;
} else {
testArgV[testArgC++] = argv[index++];
}
@@ -474,6 +480,11 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD
for (const QString &path : qAsConst(pluginPaths))
engine.addPluginPath(path);
+ if (!fileSelectors.isEmpty()) {
+ QQmlFileSelector* const qmlFileSelector = new QQmlFileSelector(&engine, &engine);
+ qmlFileSelector->setExtraSelectors(fileSelectors);
+ }
+
TestCaseCollector testCaseCollector(fi, &engine);
if (!testCaseCollector.errors().isEmpty()) {
for (const QQmlError &error : testCaseCollector.errors())