aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/palette/tst_palette.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-09-22 10:53:01 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-09-22 11:20:35 +0000
commit4f78462e867925f1e5fd8c2a3411ebfcba0969db (patch)
treeb322480371dba5dacda3a19b372a17ac1230d171 /tests/auto/palette/tst_palette.cpp
parent5bfbe47f0fd20223e2185c68b4a7d12717cd5ecd (diff)
Fix tst_palette
The Default is being ported to use palettes. tst_palette starts failing as soon as QQuickDefaultTheme::palette() returns a custom palette, because the expected palette in tst_palette's comparison was the default platform palette, not the default style palette. First of all, the expected palette was constructed before any QtQuick Controls were imported. Secondly, it was not queried from the platform theme as appropriate. Change-Id: Ia28872fb2769c6cd5ff0159077769951def17f43 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/palette/tst_palette.cpp')
-rw-r--r--tests/auto/palette/tst_palette.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/auto/palette/tst_palette.cpp b/tests/auto/palette/tst_palette.cpp
index 9a9a0941..f74e358a 100644
--- a/tests/auto/palette/tst_palette.cpp
+++ b/tests/auto/palette/tst_palette.cpp
@@ -44,6 +44,7 @@
#include <QtQml/qqmlcomponent.h>
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
+#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
#include <QtQuickControls2/private/qquickproxytheme_p.h>
@@ -54,6 +55,8 @@ class tst_palette : public QQmlDataTest
Q_OBJECT
private slots:
+ void initTestCase();
+
void palette_data();
void palette();
@@ -67,12 +70,25 @@ private slots:
void listView();
};
+void tst_palette::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+
+ // Import QtQuick.Controls to initialize styles and themes so that
+ // QQuickControlPrivate::themePalette() returns a palette from the
+ // style's theme instead of the platform's theme.
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick.Controls 2.3; Control { }", QUrl());
+ delete component.create();
+}
+
void tst_palette::palette_data()
{
QTest::addColumn<QString>("testFile");
QTest::addColumn<QPalette>("expectedPalette");
- QPalette defaultPalette;
+ QPalette defaultPalette = QQuickControlPrivate::themePalette(QPlatformTheme::SystemPalette);
defaultPalette.setColor(QPalette::Base, QColor("#efefef"));
defaultPalette.setColor(QPalette::Text, QColor("#101010"));
@@ -156,7 +172,7 @@ void tst_palette::inheritance()
QObject *grandChild = window->property("grandChild").value<QObject *>();
QVERIFY(control && child && grandChild);
- QPalette defaultPalette;
+ QPalette defaultPalette = QQuickControlPrivate::themePalette(QPlatformTheme::SystemPalette);
defaultPalette.setColor(QPalette::Base, QColor("#efefef"));
defaultPalette.setColor(QPalette::Text, QColor("#101010"));