aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgor Nemtsev <enemtsev@luxoft.com>2020-02-28 17:58:48 +0300
committerEgor Nemtsev <enemtsev@luxoft.com>2020-03-03 07:20:19 +0000
commitdf3f17c18766bb8e6862b42a1a304adedf9d6b40 (patch)
tree3e7b379fb82ad3f10c39e7f4c0e8d0d32ca9f246
parent3839a89e5e896c2d49d24e409f8382f123d0471c (diff)
[tests] fix import styles for tests
- Qt Test allow only to import paths. Neptune components require Styles to work. Styles can only be set via env variables. In Neptune's qmlscene we add extra arguments: --style-conf and --styles-path. For testrunner we initialize evn varibles from defined in pro file paths pointing to build dir. We set QT_QUICK_CONTROLS_CONF and QT_QUICK_CONTROLS_STYLE_PATH Task-number: AUTOSUITE-1497 Change-Id: I1304063bc7628bb921c7c6ee9f7562202d3efbce Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
-rw-r--r--tests/neptune-qmlscene/neptune-qmlscene.cpp6
-rw-r--r--tests/qmltests/qmltests.pro7
-rw-r--r--tests/qmltests/testrunner.cpp4
3 files changed, 17 insertions, 0 deletions
diff --git a/tests/neptune-qmlscene/neptune-qmlscene.cpp b/tests/neptune-qmlscene/neptune-qmlscene.cpp
index 74c442e3..b3750875 100644
--- a/tests/neptune-qmlscene/neptune-qmlscene.cpp
+++ b/tests/neptune-qmlscene/neptune-qmlscene.cpp
@@ -361,6 +361,8 @@ static void usage()
puts(" -I <path> ........................ Add <path> to the list of import paths");
puts(" -P <path> ........................ Add <path> to the list of plugin paths");
puts(" -translation <translationfile> ... Set the language to run in");
+ puts(" --style-conf <style conf file> ... Sets QT_QUICK_CONTROLS_CONF");
+ puts(" --styles-path <styles path> ...... Sets QT_QUICK_CONTROLS_STYLE_PATH");
puts(" ");
exit(1);
@@ -529,6 +531,10 @@ int main(int argc, char ** argv)
imports.append(arguments.at(++i));
else if (lowerArgument == QLatin1String("-p") && i + 1 < size)
pluginPaths.append(arguments.at(++i));
+ else if (lowerArgument == QLatin1String("--style-conf") && i + 1 < size)
+ qputenv("QT_QUICK_CONTROLS_CONF", arguments.at(++i).toLocal8Bit());
+ else if (lowerArgument == QLatin1String("--styles-path") && i + 1 < size)
+ qputenv("QT_QUICK_CONTROLS_STYLE_PATH", arguments.at(++i).toLocal8Bit());
else if (lowerArgument == QLatin1String("--help")
|| lowerArgument == QLatin1String("-help")
|| lowerArgument == QLatin1String("--h")
diff --git a/tests/qmltests/qmltests.pro b/tests/qmltests/qmltests.pro
index 0f9768dc..1e90496d 100644
--- a/tests/qmltests/qmltests.pro
+++ b/tests/qmltests/qmltests.pro
@@ -16,6 +16,11 @@ win32 {
CONFIG += qmltestcase
+# these defines Styles for qml as it is not possible to set them via Qt Test
+# used to set env variables
+DEFINES *= STYLE_CONF_PATH=\""\\\"$$BUILD_DIR/styles/neptune/style.conf\\\""\"
+DEFINES *= STYLES_PATH=\""\\\"$$BUILD_DIR/styles\\\""\"
+
# TODO: Check what is the import precedence to ensure Qt looks for modules first in the
# build dir and only after in the installation dir.
IMPORTPATH = $$BUILD_DIR/imports_shared \
@@ -36,5 +41,7 @@ for(COMPONENT_NAME, COMPONENT_NAMES) {
!isEmpty(IMPORTPATH) {
for(import, IMPORTPATH): $${targetName}.commands += -I \"$$import\"
}
+ $${targetName}.commands += --style-conf $$BUILD_DIR/styles/neptune/style.conf
+ $${targetName}.commands += --styles-path $$BUILD_DIR/styles
$${targetName}.commands += $$PWD/tst_$${COMPONENT_NAME}.qml
}
diff --git a/tests/qmltests/testrunner.cpp b/tests/qmltests/testrunner.cpp
index 663febe9..1477c373 100644
--- a/tests/qmltests/testrunner.cpp
+++ b/tests/qmltests/testrunner.cpp
@@ -1,2 +1,6 @@
#include <QtQuickTest/quicktest.h>
+
+static bool s_styleConfig = qputenv("QT_QUICK_CONTROLS_CONF", STYLE_CONF_PATH);
+static bool s_stylesPath = qputenv("QT_QUICK_CONTROLS_STYLE_PATH", STYLES_PATH);
+
QUICK_TEST_MAIN(neptune-qmltests)