aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
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:51 +0000
commit1ceb8efeef7cf2f32ab069e0939a96e26ba1a9f6 (patch)
tree30d560639e302e20cd427d220b0ae50301b74289 /tests/auto
parentc924a94fb5077028965e2c6343e1bafabc0e69f8 (diff)
Reset QQuickStyle when the QtQuick.Controls 2 plugin is unloaded
Cleanup global static data in QQuickStyle when the controls plugin is unloaded (qmlClearTypeRegistrations()). This ensures that the style is resolved as appropriate when the controls plugin is reloaded. Change-Id: Icebb835e057e6063e4fc0ca035c6836560bc7c14 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp
index 1ce2a034..9de947a6 100644
--- a/tests/auto/qquickstyle/tst_qquickstyle.cpp
+++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp
@@ -46,21 +46,41 @@ class tst_QQuickStyle : public QObject
Q_OBJECT
private slots:
- void init();
+ void cleanup();
void lookup();
void commandLineArgument();
void environmentVariables();
void availableStyles();
+
+private:
+ void loadControls();
+ void unloadControls();
};
-void tst_QQuickStyle::init()
+void tst_QQuickStyle::cleanup()
{
- QQuickStylePrivate::reset();
+ unloadControls();
+
QGuiApplicationPrivate::styleOverride.clear();
qunsetenv("QT_QUICK_CONTROLS_STYLE");
qunsetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE");
}
+void tst_QQuickStyle::loadControls()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Control { }", QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
+}
+
+void tst_QQuickStyle::unloadControls()
+{
+ qmlClearTypeRegistrations();
+}
+
void tst_QQuickStyle::lookup()
{
QVERIFY(QQuickStyle::name().isEmpty());
@@ -70,12 +90,7 @@ void tst_QQuickStyle::lookup()
QCOMPARE(QQuickStyle::name(), QString("Material"));
QVERIFY(!QQuickStyle::path().isEmpty());
- QQmlEngine engine;
- QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0; import QtQuick.Controls 2.1; Control { }", QUrl());
-
- QScopedPointer<QObject> object(component.create());
- QVERIFY(!object.isNull());
+ loadControls();
QCOMPARE(QQuickStyle::name(), QString("Material"));
QVERIFY(!QQuickStyle::path().isEmpty());
@@ -84,6 +99,9 @@ void tst_QQuickStyle::lookup()
void tst_QQuickStyle::commandLineArgument()
{
QGuiApplicationPrivate::styleOverride = "CmdLineArgStyle";
+
+ loadControls();
+
QCOMPARE(QQuickStyle::name(), QString("CmdLineArgStyle"));
}