From 184c5470f534119b27c1a4caec29d699aba9c234 Mon Sep 17 00:00:00 2001 From: Jan Murawski Date: Fri, 24 Nov 2017 16:50:03 +0100 Subject: 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 --- src/qmltest/quicktest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/qmltest') 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 #include #include +#include #include @@ -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 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()) -- cgit v1.2.3