diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-05-15 16:09:11 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-05-15 14:33:13 +0000 |
commit | 7c52e1d6e318a8874913e484d2f1481f21458c9e (patch) | |
tree | 6f94f4ac1056723e7dbe0f713ef5c31d4ff5009b /tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp | |
parent | 8290b876b6f0673cbaf5119bf737873af4fde928 (diff) |
QQuickIconLabel: ensure that icon color changes are respected
updateIcon() is no longer called, so we can move its contents into
syncImage(), which is called by updateOrSyncImage(), which is called by
QQuickIconLabel::setIcon().. which is called each time any of the icon
properties change (now that it's a value type).
Task-number: QTBUG-60807
Change-Id: Id1ff875e0855bd76755d49466f82c2eac36ffd09
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp')
-rw-r--r-- | tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp index e311b8ac..a251b471 100644 --- a/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp +++ b/tests/auto/qquickiconlabel/tst_qquickiconlabel.cpp @@ -32,6 +32,7 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> +#include <QtQuick/qquickitemgrabresult.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuickTemplates2/private/qquickicon_p.h> #include <QtQuickControls2/private/qquickiconimage_p.h> @@ -54,6 +55,7 @@ private slots: void spacingWithOneDelegate_data(); void spacingWithOneDelegate(); void emptyIconSource(); + void colorChanges(); }; tst_qquickiconlabel::tst_qquickiconlabel() @@ -291,6 +293,34 @@ void tst_qquickiconlabel::emptyIconSource() QCOMPARE(text->x(), horizontalCenter - text->width() / 2); } +void tst_qquickiconlabel::colorChanges() +{ + QQuickView view(testFileUrl("colorChanges.qml")); + QCOMPARE(view.status(), QQuickView::Ready); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QQuickItem *rootItem = view.rootObject(); + QVERIFY(rootItem); + + QQuickIconLabel *label = rootItem->findChild<QQuickIconLabel *>(); + QVERIFY(label); + QCOMPARE(label->spacing(), 0.0); + QCOMPARE(label->display(), QQuickIconLabel::TextBesideIcon); + QCOMPARE(label->isMirrored(), false); + + QSharedPointer<QQuickItemGrabResult> grabResult = label->grabToImage(); + QTRY_VERIFY(!grabResult->image().isNull()); + const QImage enabledImageGrab = grabResult->image(); + + // The color should change to "red" when the item is disabled. + rootItem->setEnabled(false); + + grabResult = label->grabToImage(); + QTRY_VERIFY(!grabResult->image().isNull()); + QVERIFY(grabResult->image() != enabledImageGrab); +} + QTEST_MAIN(tst_qquickiconlabel) #include "tst_qquickiconlabel.moc" |