diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qimagereader/images/test-flag-rle.tga | bin | 0 -> 7971 bytes | |||
-rw-r--r-- | tests/auto/qimagereader/images/test-flag.tga | bin | 0 -> 480044 bytes | |||
-rw-r--r-- | tests/auto/qimagereader/qimagereader.pro | 1 | ||||
-rw-r--r-- | tests/auto/qimagereader/qimagereader.qrc | 2 | ||||
-rw-r--r-- | tests/auto/qimagereader/tst_qimagereader.cpp | 51 |
5 files changed, 50 insertions, 4 deletions
diff --git a/tests/auto/qimagereader/images/test-flag-rle.tga b/tests/auto/qimagereader/images/test-flag-rle.tga Binary files differnew file mode 100644 index 0000000..c14c712 --- /dev/null +++ b/tests/auto/qimagereader/images/test-flag-rle.tga diff --git a/tests/auto/qimagereader/images/test-flag.tga b/tests/auto/qimagereader/images/test-flag.tga Binary files differnew file mode 100644 index 0000000..c6d0c89 --- /dev/null +++ b/tests/auto/qimagereader/images/test-flag.tga diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro index 827819d..a9bfa1d 100644 --- a/tests/auto/qimagereader/qimagereader.pro +++ b/tests/auto/qimagereader/qimagereader.pro @@ -10,6 +10,7 @@ RESOURCES += qimagereader.qrc !contains(QT_CONFIG, no-mng):DEFINES += QTEST_HAVE_MNG !contains(QT_CONFIG, no-tiff):DEFINES += QTEST_HAVE_TIFF !contains(QT_CONFIG, no-svg):DEFINES += QTEST_HAVE_SVG +!contains(QT_CONFIG, no-tga):DEFINES += QTEST_HAVE_TGA win32-msvc:QMAKE_CXXFLAGS -= -Zm200 win32-msvc:QMAKE_CXXFLAGS += -Zm800 diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index 2c70652..03c03d6 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -67,5 +67,7 @@ <file>images/corrupt.svgz</file> <file>images/qtbug13653-no_eoi.jpg</file> <file>images/txts.png</file> + <file>images/test-flag.tga</file> + <file>images/test-flag-rle.tga</file> </qresource> </RCC> diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 5d958d7..2b867c3 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -168,6 +168,10 @@ private slots: void tiffGrayscale(); #endif +#if defined QTEST_HAVE_TGA + void tgaTestImages(); +#endif + void autoDetectImageFormat(); void fileNameProbing(); @@ -569,6 +573,10 @@ void tst_QImageReader::imageFormat_data() QTest::newRow("mng-2") << QString("fire.mng") << QByteArray("mng") << QImage::Format_Invalid; QTest::newRow("svg") << QString("rect.svg") << QByteArray("svg") << QImage::Format_ARGB32_Premultiplied; QTest::newRow("svgz") << QString("rect.svgz") << QByteArray("svgz") << QImage::Format_ARGB32_Premultiplied; +#if defined QTEST_HAVE_TGA + QTest::newRow("tga") << QString("test-flag.tga") << QByteArray("tga") << QImage::Format_ARGB32; + QTest::newRow("tga-rle") << QString("test-flag-rle.tga") << QByteArray("tga") << QImage::Format_ARGB32; +#endif } void tst_QImageReader::imageFormat() @@ -578,22 +586,31 @@ void tst_QImageReader::imageFormat() QFETCH(QImage::Format, imageFormat); if (QImageReader::imageFormat(prefix + fileName).isEmpty()) { - if (QByteArray("jpeg") == format) + if (QByteArray("jpeg") == format) { #ifndef QTEST_HAVE_JPEG return; #endif // !QTEST_HAVE_JPEG - if (QByteArray("gif") == format) + } + if (QByteArray("gif") == format) { #ifndef QTEST_HAVE_GIF return; #endif // !QTEST_HAVE_GIF - if (QByteArray("mng") == format) + } + if (QByteArray("mng") == format) { #ifndef QTEST_HAVE_MNG return; #endif // !QTEST_HAVE_MNG - if (QByteArray("svg") == format || QByteArray("svgz") == format) + } + if (QByteArray("svg") == format || QByteArray("svgz") == format) { #ifndef QTEST_HAVE_SVG return; #endif // !QTEST_HAVE_SVG + } + if (QByteArray("tga") == format) { +#ifndef QTEST_HAVE_TGA + return; +#endif // !QTEST_HAVE_TGA + } QSKIP(("Qt does not support the " + format + " format.").constData(), SkipSingle); } else { QCOMPARE(QImageReader::imageFormat(prefix + fileName), format); @@ -734,6 +751,11 @@ void tst_QImageReader::sizeBeforeRead() { QFETCH(QString, fileName); QFETCH(QByteArray, format); + + if (fileName == QLatin1String("test-flag-rle.tga")) { + QSKIP("Qt does not support reading RLE compressed TGA files", SkipSingle); + } + QImageReader reader(prefix + fileName); QVERIFY(reader.canRead()); if (format == "mng") { @@ -1711,6 +1733,27 @@ void tst_QImageReader::tiffGrayscale() } #endif +#if defined QTEST_HAVE_TGA +void tst_QImageReader::tgaTestImages() +{ + QImage tgaTest(prefix + "test-flag.tga"); + + // Test image is 400x400 of a "flag" with a blue circle in the middle + // and a green square top left, and red rectangle on the bottom so + // so we test for pixels in those areas to ensure the image is not + // inverted or the palette is not messed up. + QVERIFY(!tgaTest.isNull()); + QCOMPARE(tgaTest.size().width(), 400); + QCOMPARE(tgaTest.size().height(), 400); + QRgb pixel = tgaTest.pixel(200,200); + QCOMPARE(qRgb(0, 0, 255), pixel); + pixel = tgaTest.pixel(0, 0); + QCOMPARE(qRgb(0, 255, 0), pixel); + pixel = tgaTest.pixel(0, 399); + QCOMPARE(qRgb(255, 0, 0), pixel); +} +#endif + void tst_QImageReader::dotsPerMeter_data() { QTest::addColumn<QString>("fileName"); |