Commit eda53c7f authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

autotests: Fix testWindowmanagement

Currently, testIcon fails because the actual and the expected pixmaps
have mismatching formats.

The root cause is that images with an alpha channel will loose the alpha
channel if they are converted to QPixmap using QPixmap::fromImage().

The >> stream operator for the QPixmap class will deserialize pixel data
in a temporary QImage and then use QPixmap::fromImage() to get a pixmap

The >> stream operator for the QIcon class will delegate the task of
reading the icon from a QDataStream to QPixmapIconEngine, which uses the
>> stream operator under the hood to deserialize icon data.

In order to fix testIcon, this change constructs a dummy icon from a
pixmap object returned by QPixmap::fromImage().
parent 33301a94
......@@ -586,12 +586,13 @@ void TestWindowManagement::testIcon()
QCOMPARE(m_window->icon().name(), QStringLiteral("wayland"));
// create an icon with a pixmap
QPixmap p(32, 32);
QImage p(32, 32, QImage::Format_ARGB32_Premultiplied);
const QIcon dummyIcon(QPixmap::fromImage(p));
QCOMPARE(iconChangedSpy.count(), 3);
QCOMPARE(m_window->icon().pixmap(32, 32), p);
QCOMPARE(m_window->icon().pixmap(32, 32), dummyIcon.pixmap(32, 32));
// let's set a themed icon
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment