diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-08 17:33:17 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-10-07 13:31:10 +0200 |
commit | 8b534487044dfb3b464431ecb91ef4e0864af4ed (patch) | |
tree | c801af7dc290a1108764bc54659ab2e417bb9cef /tests/auto/palette | |
parent | 280b7526d41244912ce89d3be1e3d47329453658 (diff) |
Default to the most appropriate built-in style if none is specified
[ChangeLog][Styles] An appropriate built-in style is now used as the
default style if one is available for the target platform. For example,
when running a Qt Quick Controls application on macOS, the macOS style
will be used. On Android, the Material style will be used. When running
on e.g. an embedded device, where no native style is available, use the
Basic (formerly "Default") style.
Change-Id: Ie61d1a8a1a83fbeba63387c7ca3671084f47bc04
Fixes: QTBUG-86403
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/palette')
-rw-r--r-- | tests/auto/palette/palette.pro | 2 | ||||
-rw-r--r-- | tests/auto/palette/tst_palette.cpp | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/tests/auto/palette/palette.pro b/tests/auto/palette/palette.pro index c7d55d07..afe9efa7 100644 --- a/tests/auto/palette/palette.pro +++ b/tests/auto/palette/palette.pro @@ -4,7 +4,7 @@ SOURCES += tst_palette.cpp macos:CONFIG -= app_bundle -QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private quickcontrols2-private +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private quickcontrols2 quickcontrols2-private include (../shared/util.pri) diff --git a/tests/auto/palette/tst_palette.cpp b/tests/auto/palette/tst_palette.cpp index c42b17a3..6e41ca49 100644 --- a/tests/auto/palette/tst_palette.cpp +++ b/tests/auto/palette/tst_palette.cpp @@ -52,6 +52,12 @@ using namespace QQuickVisualTestUtil; +// Need a more descriptive failure message: QTBUG-87039 +#define COMPARE_PALETTES(actualPalette, expectedPalette) \ + QVERIFY2(actualPalette == expectedPalette, \ + qPrintable(QString::fromLatin1("\n Actual: %1\n Expected: %2") \ + .arg(QDebug::toString(actualPalette)).arg(QDebug::toString(expectedPalette)))); + class tst_palette : public QQmlDataTest { Q_OBJECT @@ -80,6 +86,8 @@ void tst_palette::initTestCase() { QQmlDataTest::initTestCase(); + QQuickStyle::setStyle("Basic"); + // 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. @@ -143,7 +151,7 @@ void tst_palette::palette() QVariant var = object->property("palette"); QVERIFY(var.isValid()); - QCOMPARE(var.value<QQuickPalette*>()->toQPalette(), expectedPalette); + COMPARE_PALETTES(var.value<QQuickPalette*>()->toQPalette(), expectedPalette); } void tst_palette::inheritance_data() |