--- a/tests/auto/qimagereader/tst_qimagereader.cpp Mon Mar 15 12:43:09 2010 +0200
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp Thu Apr 08 14:19:33 2010 +0300
@@ -142,6 +142,7 @@
void gifHandlerBugs();
void animatedGif();
void gifImageCount();
+ void gifLoopCount();
#endif
void readCorruptImage_data();
@@ -765,6 +766,8 @@
QVERIFY(io.canRead());
QImage greenFrame = io.read();
+ QVERIFY(io.imageCount() == 4);
+
QVERIFY(io.canRead());
QImage blueFrame = io.read();
@@ -876,7 +879,25 @@
QCOMPARE(blueFrame.size(), QSize(64,64));
QVERIFY(emptyFrame.isNull());
}
+ {
+ QImageReader io(":images/trolltech.gif");
+ QVERIFY(io.imageCount() == 34);
+ QVERIFY(io.size() == QSize(128,64));
+ }
}
+
+void tst_QImageReader::gifLoopCount()
+{
+ {
+ QImageReader io(":images/qt-gif-anim.gif");
+ QCOMPARE(io.loopCount(), -1); // infinite loop
+ }
+ {
+ QImageReader io(":images/qt-gif-noanim.gif");
+ QCOMPARE(io.loopCount(), 0); // no loop
+ }
+}
+
#endif
class Server : public QObject
@@ -1612,6 +1633,35 @@
QVERIFY(reader.canRead());
QVERIFY(!reader.read().isNull());
}
+
+#ifdef QTEST_HAVE_JPEG
+ {
+ QImageReader io(prefix + "YCbCr_rgb.jpg");
+ io.setAutoDetectImageFormat(false);
+ // This should fail since no format string is given
+ QImage image;
+ QVERIFY(!io.read(&image));
+ }
+ {
+ QImageReader io(prefix + "YCbCr_rgb.jpg", "jpg");
+ io.setAutoDetectImageFormat(false);
+ QImage image;
+ QVERIFY(io.read(&image));
+ }
+#endif
+ {
+ QImageReader io(prefix + "tst7.png");
+ io.setAutoDetectImageFormat(false);
+ // This should fail since no format string is given
+ QImage image;
+ QVERIFY(!io.read(&image));
+ }
+ {
+ QImageReader io(prefix + "tst7.png", "png");
+ io.setAutoDetectImageFormat(false);
+ QImage image;
+ QVERIFY(io.read(&image));
+ }
}
void tst_QImageReader::fileNameProbing()
@@ -1641,10 +1691,16 @@
{
QFETCH(QString, fileName);
+ static int enteredCount = 0; // Used for better error diagnostics if something fails. We
+ static int loadFailCount = 0; // don't know if the reason load() fails is that the plugin
+ // does not exist or because of a bug in the plugin. But if at
+ // least one file succeeded we know that the plugin was built.
+ // The other failures are then real failures.
QImage icoImg;
const QString inputFileName(QString::fromAscii("images/%1").arg(fileName));
QFileInfo fi(inputFileName);
+ ++enteredCount;
// might fail if the plugin does not exist, which is ok.
if (icoImg.load(inputFileName)) {
icoImg = icoImg.convertToFormat(QImage::Format_ARGB32_Premultiplied);
@@ -1658,6 +1714,13 @@
QCOMPARE(int(baseImg.format()), int(icoImg.format()));
QCOMPARE(baseImg, icoImg);
#endif
+ } else {
+ ++loadFailCount;
+ if (enteredCount != loadFailCount) {
+ QFAIL("Plugin is built, but some did not load properly");
+ } else {
+ qWarning("loading failed, check if ico plugin is built");
+ }
}
}