diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-02-19 15:52:44 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-02-20 09:49:54 +0000 |
commit | 48dd6b7e4a03811a9a113aef2687d34db726a856 (patch) | |
tree | 33e91e3b4e8f0c1556501ab20e25330505041f8a /tests/auto/qquickstyle/tst_qquickstyle.cpp | |
parent | 1ceb8efeef7cf2f32ab069e0939a96e26ba1a9f6 (diff) |
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 <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qquickstyle/tst_qquickstyle.cpp')
-rw-r--r-- | tests/auto/qquickstyle/tst_qquickstyle.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
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 <QtQuickControls2/private/qquickstyle_p.h> #include <QtGui/private/qguiapplication_p.h> -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<QString>("fileName"); + QTest::addColumn<QString>("expectedStyle"); + QTest::addColumn<QString>("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"; |