From 48dd6b7e4a03811a9a113aef2687d34db726a856 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 19 Feb 2018 15:52:44 +0100 Subject: QQuickStyle: fix and test QT_QUICK_CONTROLS_CONF Reset QT_QUICK_CONTROLS_CONF when appropriate, and add some tests too since the environment variable is now public and documented. Change-Id: I09fba950de7c34f22c4cf802ea5c0a337c84f0bd Reviewed-by: Mitch Curtis --- tests/auto/qquickstyle/data/custom.conf | 2 ++ tests/auto/qquickstyle/data/default.conf | 2 ++ tests/auto/qquickstyle/data/fusion.conf | 2 ++ tests/auto/qquickstyle/data/imagine.conf | 2 ++ tests/auto/qquickstyle/data/material.conf | 2 ++ tests/auto/qquickstyle/data/universal.conf | 2 ++ tests/auto/qquickstyle/qquickstyle.pro | 2 ++ tests/auto/qquickstyle/tst_qquickstyle.cpp | 36 +++++++++++++++++++++++++++++- 8 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qquickstyle/data/custom.conf create mode 100644 tests/auto/qquickstyle/data/default.conf create mode 100644 tests/auto/qquickstyle/data/fusion.conf create mode 100644 tests/auto/qquickstyle/data/imagine.conf create mode 100644 tests/auto/qquickstyle/data/material.conf create mode 100644 tests/auto/qquickstyle/data/universal.conf (limited to 'tests') diff --git a/tests/auto/qquickstyle/data/custom.conf b/tests/auto/qquickstyle/data/custom.conf new file mode 100644 index 00000000..4e17d1dc --- /dev/null +++ b/tests/auto/qquickstyle/data/custom.conf @@ -0,0 +1,2 @@ +[Controls] +Style=:/Custom diff --git a/tests/auto/qquickstyle/data/default.conf b/tests/auto/qquickstyle/data/default.conf new file mode 100644 index 00000000..caace6db --- /dev/null +++ b/tests/auto/qquickstyle/data/default.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Default diff --git a/tests/auto/qquickstyle/data/fusion.conf b/tests/auto/qquickstyle/data/fusion.conf new file mode 100644 index 00000000..9cd14111 --- /dev/null +++ b/tests/auto/qquickstyle/data/fusion.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Fusion diff --git a/tests/auto/qquickstyle/data/imagine.conf b/tests/auto/qquickstyle/data/imagine.conf new file mode 100644 index 00000000..add378d4 --- /dev/null +++ b/tests/auto/qquickstyle/data/imagine.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Imagine diff --git a/tests/auto/qquickstyle/data/material.conf b/tests/auto/qquickstyle/data/material.conf new file mode 100644 index 00000000..b6c7c87e --- /dev/null +++ b/tests/auto/qquickstyle/data/material.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Material diff --git a/tests/auto/qquickstyle/data/universal.conf b/tests/auto/qquickstyle/data/universal.conf new file mode 100644 index 00000000..8c6dd807 --- /dev/null +++ b/tests/auto/qquickstyle/data/universal.conf @@ -0,0 +1,2 @@ +[Controls] +Style=Universal diff --git a/tests/auto/qquickstyle/qquickstyle.pro b/tests/auto/qquickstyle/qquickstyle.pro index e56ee854..da74b6cd 100644 --- a/tests/auto/qquickstyle/qquickstyle.pro +++ b/tests/auto/qquickstyle/qquickstyle.pro @@ -7,4 +7,6 @@ macos:CONFIG -= app_bundle QT += quickcontrols2 testlib QT_PRIVATE += core-private gui-private quickcontrols2-private +include (../shared/util.pri) + TESTDATA = $$PWD/data/* diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index 9de947a6..4a34f24a 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -41,13 +41,17 @@ #include #include -class tst_QQuickStyle : public QObject +#include "../shared/util.h" + +class tst_QQuickStyle : public QQmlDataTest { Q_OBJECT private slots: void cleanup(); void lookup(); + void configurationFile_data(); + void configurationFile(); void commandLineArgument(); void environmentVariables(); void availableStyles(); @@ -64,6 +68,7 @@ void tst_QQuickStyle::cleanup() QGuiApplicationPrivate::styleOverride.clear(); qunsetenv("QT_QUICK_CONTROLS_STYLE"); qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE"); + qunsetenv("QT_QUICK_CONTROLS_CONF"); } void tst_QQuickStyle::loadControls() @@ -96,6 +101,35 @@ void tst_QQuickStyle::lookup() QVERIFY(!QQuickStyle::path().isEmpty()); } +void tst_QQuickStyle::configurationFile_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("expectedStyle"); + QTest::addColumn("expectedPath"); + + QTest::newRow("Default") << "default.conf" << "Default" << ""; + QTest::newRow("Fusion") << "fusion.conf" << "Fusion" << ""; + QTest::newRow("Imagine") << "imagine.conf" << "Imagine" << ""; + QTest::newRow("Material") << "material.conf" << "Material" << ""; + QTest::newRow("Universal") << "universal.conf" << "Universal" << ""; + QTest::newRow("Custom") << "custom.conf" << "Custom" << ":/"; +} + +void tst_QQuickStyle::configurationFile() +{ + QFETCH(QString, fileName); + QFETCH(QString, expectedStyle); + QFETCH(QString, expectedPath); + + qputenv("QT_QUICK_CONTROLS_CONF", testFile(fileName).toLocal8Bit()); + + loadControls(); + + QCOMPARE(QQuickStyle::name(), expectedStyle); + if (!expectedPath.isEmpty()) + QCOMPARE(QQuickStyle::path(), expectedPath); +} + void tst_QQuickStyle::commandLineArgument() { QGuiApplicationPrivate::styleOverride = "CmdLineArgStyle"; -- cgit v1.2.3