summaryrefslogtreecommitdiffstats
path: root/tests/auto/qicon
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2009-05-28 15:07:01 +0200
committerTrond Kjernåsen <trond@trolltech.com>2009-05-28 15:11:25 +0200
commit408ca46193f70ff66d060f7b7c506a97fee945e2 (patch)
tree09cc5fa79d63d6c34b569a63234066bc648e82e4 /tests/auto/qicon
parent8e2d3cc2e84b6d8109c30a853ea40ff9cfa29bcc (diff)
Fixed a problem with streaming QIcons containing multiple pixmaps.
If pixmaps were added through QIcon::addFile() with different sizes than the sizes of the pixmaps themselves, streaming the icon in didn't work properly. Task-number: 254374 Reviewed-by: Kim
Diffstat (limited to 'tests/auto/qicon')
-rw-r--r--tests/auto/qicon/tst_qicon.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qicon/tst_qicon.cpp b/tests/auto/qicon/tst_qicon.cpp
index 4e9a880b45..1dd223f46e 100644
--- a/tests/auto/qicon/tst_qicon.cpp
+++ b/tests/auto/qicon/tst_qicon.cpp
@@ -72,6 +72,8 @@ private slots:
void svg();
void addFile();
void availableSizes();
+ void streamAvailableSizes_data();
+ void streamAvailableSizes();
void task184901_badCache();
void task223279_inconsistentAddFile();
@@ -540,6 +542,47 @@ void tst_QIcon::availableSizes()
}
}
+void tst_QIcon::streamAvailableSizes_data()
+{
+ QTest::addColumn<QIcon>("icon");
+
+ QIcon icon;
+ icon.addFile(":/image.png", QSize(32,32));
+ QTest::newRow( "32x32" ) << icon;
+ icon.addFile(":/image.png", QSize(64,64));
+ QTest::newRow( "64x64" ) << icon;
+ icon.addFile(":/image.png", QSize(128,128));
+ QTest::newRow( "128x128" ) << icon;
+ icon.addFile(":/image.png", QSize(256,256));
+ QTest::newRow( "256x256" ) << icon;
+}
+
+void tst_QIcon::streamAvailableSizes()
+{
+ QFETCH(QIcon, icon);
+
+ QByteArray ba;
+ // write to QByteArray
+ {
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ QDataStream stream(&buffer);
+ stream << icon;
+ }
+
+ // read from QByteArray
+ {
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::ReadOnly);
+ QDataStream stream(&buffer);
+ QIcon i;
+ stream >> i;
+ QCOMPARE(i.isNull(), icon.isNull());
+ QCOMPARE(i.availableSizes(), icon.availableSizes());
+ }
+}
+
+
static inline bool operator<(const QSize &lhs, const QSize &rhs)
{
if (lhs.width() < rhs.width())