summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimagereader
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2010-11-23 11:26:54 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-11-23 11:26:54 (GMT)
commit802498fcd43558a10bb7477d3957cdd27fd8ec09 (patch)
treec40ddd859b032ffa7ed9c6df1173312c0bb1947d /tests/auto/qimagereader
parent901fee7e610ec53f744416aeeca89c4605923120 (diff)
parent538e7b8ddf45936bb274ed3230b591b3459edfa7 (diff)
downloadQt-802498fcd43558a10bb7477d3957cdd27fd8ec09.zip
Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.gz
Qt-802498fcd43558a10bb7477d3957cdd27fd8ec09.tar.bz2
Merge remote branch 'qt/master' into file-engine-refactor
Conflicts: demos/declarative/minehunt/minehunt.pro src/corelib/io/io.pri src/corelib/io/qfsfileengine.cpp src/corelib/io/qfsfileengine_unix.cpp src/corelib/io/qfsfileengine_win.cpp src/s60installs/bwins/QtCoreu.def src/s60installs/bwins/QtDeclarativeu.def src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtDeclarativeu.def src/s60installs/eabi/QtGuiu.def tests/auto/qapplication/test/test.pro tests/auto/qaudioinput/qaudioinput.pro tests/auto/qaudiooutput/qaudiooutput.pro tests/auto/qchar/qchar.pro tests/auto/qdiriterator/qdiriterator.pro tests/auto/qsound/qsound.pro
Diffstat (limited to 'tests/auto/qimagereader')
-rw-r--r--tests/auto/qimagereader/qimagereader.pro8
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp98
2 files changed, 87 insertions, 19 deletions
diff --git a/tests/auto/qimagereader/qimagereader.pro b/tests/auto/qimagereader/qimagereader.pro
index f8fc7fa..827819d 100644
--- a/tests/auto/qimagereader/qimagereader.pro
+++ b/tests/auto/qimagereader/qimagereader.pro
@@ -17,10 +17,10 @@ win32-msvc.net:QMAKE_CXXFLAGS -= -Zm300
win32-msvc.net:QMAKE_CXXFLAGS += -Zm1100
wince*: {
- images.sources = images
+ images.files = images
images.path = .
- imagePlugins.sources = $$QT_BUILD_TREE/plugins/imageformats/*.dll
+ imagePlugins.files = $$QT_BUILD_TREE/plugins/imageformats/*.dll
imagePlugins.path = imageformats
DEPLOYMENT += images imagePlugins
@@ -28,13 +28,13 @@ wince*: {
}
symbian: {
- images.sources = images
+ images.files = images
images.path = .
DEPLOYMENT += images
qt_not_deployed {
- imagePlugins.sources = qjpeg.dll qgif.dll qmng.dll
+ imagePlugins.files = qjpeg.dll qgif.dll qmng.dll
imagePlugins.path = imageformats
DEPLOYMENT += imagePlugins
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index a6fb886..5742a97 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -55,6 +55,8 @@
#include <QTcpServer>
#include <QTimer>
+#include "../platformquirks.h"
+
#if defined(Q_OS_SYMBIAN)
# define SRCDIR "."
#endif
@@ -180,6 +182,9 @@ private slots:
void saveFormat_data();
void saveFormat();
+
+ void preserveTexts_data();
+ void preserveTexts();
};
static const QLatin1String prefix(SRCDIR "/images/");
@@ -315,23 +320,27 @@ void tst_QImageReader::jpegRgbCmyk()
QImage image1(prefix + QLatin1String("YCbCr_cmyk.jpg"));
QImage image2(prefix + QLatin1String("YCbCr_cmyk.png"));
- // first, do some obvious tests
- QCOMPARE(image1.height(), image2.height());
- QCOMPARE(image1.width(), image2.width());
- QCOMPARE(image1.format(), image2.format());
- QCOMPARE(image1.format(), QImage::Format_RGB32);
-
- // compare all the pixels with a slack of 3. This ignores rounding errors in libjpeg/libpng
- for (int h = 0; h < image1.height(); ++h) {
- const uchar *s1 = image1.constScanLine(h);
- const uchar *s2 = image2.constScanLine(h);
- for (int w = 0; w < image1.width() * 4; ++w) {
- if (*s1 != *s2) {
- QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16)));
+ if (PlatformQuirks::isImageLoaderImprecise()) {
+ // first, do some obvious tests
+ QCOMPARE(image1.height(), image2.height());
+ QCOMPARE(image1.width(), image2.width());
+ QCOMPARE(image1.format(), image2.format());
+ QCOMPARE(image1.format(), QImage::Format_RGB32);
+
+ // compare all the pixels with a slack of 3. This ignores rounding errors in libjpeg/libpng
+ for (int h = 0; h < image1.height(); ++h) {
+ const uchar *s1 = image1.constScanLine(h);
+ const uchar *s2 = image2.constScanLine(h);
+ for (int w = 0; w < image1.width() * 4; ++w) {
+ if (*s1 != *s2) {
+ QVERIFY2(qAbs(*s1 - *s2) <= 3, qPrintable(QString("images differ in line %1, col %2 (image1: %3, image2: %4)").arg(h).arg(w).arg(*s1, 0, 16).arg(*s2, 0, 16)));
+ }
+ s1++;
+ s2++;
}
- s1++;
- s2++;
}
+ } else {
+ QCOMPARE(image1, image2);
}
}
@@ -1956,5 +1965,64 @@ void tst_QImageReader::saveFormat()
}
+void tst_QImageReader::preserveTexts_data()
+{
+ QTest::addColumn<QString>("text");
+
+ QTest::newRow("Simple") << "simpletext";
+ QTest::newRow("Whitespace") << " A text with whitespace ";
+ QTest::newRow("Newline") << "A text\nwith newlines\n";
+ QTest::newRow("Double newlines") << "A text\n\nwith double newlines\n\n";
+ QTest::newRow("Long") << QString("A rather long text, at least after many repetitions. ").repeated(100);
+ QString latin1set;
+ int c;
+ for(c = 0x20; c <= 0x7e; c++)
+ latin1set.append(QLatin1Char(c));
+ for(c = 0xa0; c <= 0xff; c++)
+ latin1set.append(QLatin1Char(c));
+ QTest::newRow("All Latin1 chars") << latin1set;
+
+#if 0
+ // Depends on iTXt support in libpng
+ QTest::newRow("Multibyte string") << QString::fromUtf8("\341\233\222\341\233\226\341\232\251\341\232\271\341\232\242\341\233\232\341\232\240");
+#endif
+}
+
+
+void tst_QImageReader::preserveTexts()
+{
+ QFETCH(QString, text);
+ QString key("testkey");
+ QString key2("testkey2");
+ QString text2("Some other text.");
+ QString key3("testkey3");
+ QString text3("Some more other text.");
+
+ QImage img(":/images/kollada.png");
+ img.setText(key, text);
+ img.setText(key2, text2);
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ QVERIFY(img.save(&buf, "png"));
+ buf.close();
+ QImage stored = QImage::fromData(buf.buffer(), "png");
+ QCOMPARE(stored.text(key), text);
+ QCOMPARE(stored.text(key2), text2);
+
+ QImage img2(":/images/kollada.png");
+ img2.setText(key3, text3);
+ QBuffer buf2;
+ QImageWriter w(&buf2, "png");
+ w.setText(key, text);
+ w.setText(key2, text2);
+ QVERIFY(w.write(img2));
+ buf2.close();
+ QImageReader r(&buf2, "png");
+ QCOMPARE(r.text(key), text.simplified());
+ QCOMPARE(r.text(key2), text2.simplified());
+ QCOMPARE(r.text(key3), text3.simplified());
+}
+
+
QTEST_MAIN(tst_QImageReader)
#include "tst_qimagereader.moc"