diff options
Diffstat (limited to 'tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp')
-rw-r--r-- | tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp index 17d1ea6d..72136445 100644 --- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp +++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp @@ -36,6 +36,7 @@ #include <qtest.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtQuickControls2/private/qquickstyle_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" @@ -49,6 +50,8 @@ public: private slots: void conf(); + void variants_data(); + void variants(); }; void tst_qquickmaterialstyleconf::conf() @@ -73,6 +76,45 @@ void tst_qquickmaterialstyleconf::conf() QCOMPARE(label->property("font").value<QFont>(), customFont); } +void tst_qquickmaterialstyleconf::variants_data() +{ + QTest::addColumn<QByteArray>("confPath"); + QTest::addColumn<int>("expectedButtonHeight"); + // Just to ensure that the correct conf is loaded. + QTest::addColumn<QColor>("expectedColor"); + + // (36 button height + 12 touchable area) + QTest::newRow("normal") << QByteArray(":/variant-normal.conf") << 48 << QColor::fromRgb(0x123456); + // We specified a custom variant (dense), so the button should be small. + // (32 button height + 12 touchable area) + QTest::newRow("dense") << QByteArray(":/variant-dense.conf") << 44 << QColor::fromRgb(0x789abc); +} + +void tst_qquickmaterialstyleconf::variants() +{ + QFETCH(QByteArray, confPath); + QFETCH(int, expectedButtonHeight); + QFETCH(QColor, expectedColor); + + qmlClearTypeRegistrations(); + QQuickStylePrivate::reset(); + qputenv("QT_QUICK_CONTROLS_CONF", confPath); + + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *label = window->property("label").value<QQuickItem*>(); + QVERIFY(label); + QCOMPARE(label->property("color").value<QColor>(), expectedColor); + + QQuickItem *button = window->property("button").value<QQuickItem*>(); + QVERIFY(button); + QCOMPARE(button->height(), expectedButtonHeight); +} + QTEST_MAIN(tst_qquickmaterialstyleconf) #include "tst_qquickmaterialstyleconf.moc" |