From a1314799a70db18d54123956b92a239bd50387a9 Mon Sep 17 00:00:00 2001 From: miniak Date: Mon, 20 Jul 2009 18:47:40 +0200 Subject: Adding test case for PNG compression icon loading Merge-request: 431 Reviewed-by: Joerg Bornemann --- tests/auto/qicoimageformat/icons/valid/Qt.ico | Bin 0 -> 31371 bytes .../auto/qicoimageformat/tst_qticoimageformat.cpp | 33 +++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/auto/qicoimageformat/icons/valid/Qt.ico diff --git a/tests/auto/qicoimageformat/icons/valid/Qt.ico b/tests/auto/qicoimageformat/icons/valid/Qt.ico new file mode 100644 index 0000000..fef1dee Binary files /dev/null and b/tests/auto/qicoimageformat/icons/valid/Qt.ico differ diff --git a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp b/tests/auto/qicoimageformat/tst_qticoimageformat.cpp index 51ee4aa..fbd3821 100644 --- a/tests/auto/qicoimageformat/tst_qticoimageformat.cpp +++ b/tests/auto/qicoimageformat/tst_qticoimageformat.cpp @@ -70,6 +70,8 @@ private slots: void loopCount(); void nextImageDelay_data(); void nextImageDelay(); + void pngCompression_data(); + void pngCompression(); private: QString m_IconPath; @@ -130,6 +132,7 @@ void tst_QtIcoImageFormat::canRead_data() QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0; QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1; + QTest::newRow("PNG compression") << "valid/Qt.ico" << 1; } void tst_QtIcoImageFormat::canRead() @@ -199,6 +202,7 @@ void tst_QtIcoImageFormat::imageCount_data() QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3; QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; + QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; } @@ -226,6 +230,7 @@ void tst_QtIcoImageFormat::jumpToNextImage_data() QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLD.ico" << 3; QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; + QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; } void tst_QtIcoImageFormat::jumpToNextImage() @@ -275,6 +280,7 @@ void tst_QtIcoImageFormat::nextImageDelay_data() QTest::newRow("16px16c, 32px32c, 32px256c") << "valid/WORLDH.ico" << 3; QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; + QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; } void tst_QtIcoImageFormat::nextImageDelay() @@ -294,5 +300,32 @@ void tst_QtIcoImageFormat::nextImageDelay() } } +void tst_QtIcoImageFormat::pngCompression_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("index"); + QTest::addColumn("width"); + QTest::addColumn("height"); + + QTest::newRow("PNG compression") << "valid/Qt.ico" << 4 << 256 << 256; +} + +void tst_QtIcoImageFormat::pngCompression() +{ + QFETCH(QString, fileName); + QFETCH(int, index); + QFETCH(int, width); + QFETCH(int, height); + + QImageReader reader(m_IconPath + "/" + fileName); + + QImage image; + reader.jumpToImage(index); + reader.read(&image); + + QCOMPARE(image.width(), width); + QCOMPARE(image.height(), height); +} + QTEST_MAIN(tst_QtIcoImageFormat) #include "tst_qticoimageformat.moc" -- cgit v0.12