1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
#include <QtGui/QtGui>
class tst_qtiff: public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void readImage_data();
void readImage();
void readCorruptImage_data();
void readCorruptImage();
private:
QString prefix;
};
void tst_qtiff::initTestCase()
{
prefix = ":/tiff/";
}
void tst_qtiff::readImage_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn<QSize>("size");
QTest::newRow("grayscale-ref") << QString("grayscale-ref.tif") << QSize(320, 200);
QTest::newRow("grayscale") << QString("grayscale.tif") << QSize(320, 200);
QTest::newRow("image_100dpi") << QString("image_100dpi.tif") << QSize(22, 22);
QTest::newRow("image") << QString("image.tif") << QSize(22, 22);
QTest::newRow("indexed_orientation_1") << QString("indexed_orientation_1.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_2") << QString("indexed_orientation_2.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_3") << QString("indexed_orientation_3.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_4") << QString("indexed_orientation_4.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_5") << QString("indexed_orientation_5.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_6") << QString("indexed_orientation_6.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_7") << QString("indexed_orientation_7.tiff") << QSize(64, 64);
QTest::newRow("indexed_orientation_8") << QString("indexed_orientation_8.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_1") << QString("mono_orientation_1.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_2") << QString("mono_orientation_2.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_3") << QString("mono_orientation_3.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_4") << QString("mono_orientation_4.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_5") << QString("mono_orientation_5.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_6") << QString("mono_orientation_6.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_7") << QString("mono_orientation_7.tiff") << QSize(64, 64);
QTest::newRow("mono_orientation_8") << QString("mono_orientation_8.tiff") << QSize(64, 64);
QTest::newRow("original_indexed") << QString("original_indexed.tiff") << QSize(64, 64);
QTest::newRow("original_mono") << QString("original_mono.tiff") << QSize(64, 64);
QTest::newRow("original_rgb") << QString("original_rgb.tiff") << QSize(64, 64);
QTest::newRow("rgba_adobedeflate_littleendian") << QString("rgba_adobedeflate_littleendian.tif") << QSize(200, 200);
QTest::newRow("rgba_lzw_littleendian") << QString("rgba_lzw_littleendian.tif") << QSize(200, 200);
QTest::newRow("rgba_nocompression_bigendian") << QString("rgba_nocompression_bigendian.tif") << QSize(200, 200);
QTest::newRow("rgba_nocompression_littleendian") << QString("rgba_nocompression_littleendian.tif") << QSize(200, 200);
QTest::newRow("rgba_packbits_littleendian") << QString("rgba_packbits_littleendian.tif") << QSize(200, 200);
QTest::newRow("rgba_zipdeflate_littleendian") << QString("rgba_zipdeflate_littleendian.tif") << QSize(200, 200);
QTest::newRow("rgb_orientation_1") << QString("rgb_orientation_1.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_2") << QString("rgb_orientation_2.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_3") << QString("rgb_orientation_3.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_4") << QString("rgb_orientation_4.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_5") << QString("rgb_orientation_5.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_6") << QString("rgb_orientation_6.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_7") << QString("rgb_orientation_7.tiff") << QSize(64, 64);
QTest::newRow("rgb_orientation_8") << QString("rgb_orientation_8.tiff") << QSize(64, 64);
QTest::newRow("teapot") << QString("teapot.tiff") << QSize(256, 256);
}
void tst_qtiff::readImage()
{
QFETCH(QString, fileName);
QFETCH(QSize, size);
QString path = prefix + fileName;
QBENCHMARK {
QImageReader reader(path);
QVERIFY(reader.canRead());
QImage image = reader.read();
QVERIFY(!image.isNull());
QCOMPARE(image.size(), size);
}
}
void tst_qtiff::readCorruptImage_data()
{
QTest::addColumn<QString>("fileName");
QTest::addColumn<QString>("message");
QTest::newRow("corrupt-data") << QString("corrupt-data.tif") << QString();
}
void tst_qtiff::readCorruptImage()
{
QFETCH(QString, fileName);
QFETCH(QString, message);
QString path = prefix + fileName;
QBENCHMARK {
QImageReader reader(path);
if (!message.isEmpty())
QTest::ignoreMessage(QtWarningMsg, message.toLatin1());
QVERIFY(reader.canRead());
QImage image = reader.read();
QVERIFY(image.isNull());
}
}
QTEST_MAIN(tst_qtiff)
#include "tst_qtiff.moc"
|