aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-02-19 15:52:44 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-02-20 09:49:54 +0000
commit48dd6b7e4a03811a9a113aef2687d34db726a856 (patch)
tree33e91e3b4e8f0c1556501ab20e25330505041f8a /tests
parent1ceb8efeef7cf2f32ab069e0939a96e26ba1a9f6 (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')
-rw-r--r--tests/auto/qquickstyle/data/custom.conf2
-rw-r--r--tests/auto/qquickstyle/data/default.conf2
-rw-r--r--tests/auto/qquickstyle/data/fusion.conf2
-rw-r--r--tests/auto/qquickstyle/data/imagine.conf2
-rw-r--r--tests/auto/qquickstyle/data/material.conf2
-rw-r--r--tests/auto/qquickstyle/data/universal.conf2
-rw-r--r--tests/auto/qquickstyle/qquickstyle.pro2
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp36
8 files changed, 49 insertions, 1 deletions
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 <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";