1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Copyright (C) 2016 Petroules Corporation. |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the MNG autotests in the Qt ImageFormats module. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU |
20 | ** General Public License version 3 as published by the Free Software |
21 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #include <QtTest/QtTest> |
31 | #include <QtGui/QtGui> |
32 | |
33 | class tst_qjp2: public QObject |
34 | { |
35 | Q_OBJECT |
36 | |
37 | private slots: |
38 | void initTestCase(); |
39 | void readImage_data(); |
40 | void readImage(); |
41 | }; |
42 | |
43 | void tst_qjp2::initTestCase() |
44 | { |
45 | if (!QImageReader::supportedImageFormats().contains(t: "jp2")) |
46 | QSKIP("The image format handler is not installed."); |
47 | } |
48 | |
49 | void tst_qjp2::readImage_data() |
50 | { |
51 | QTest::addColumn<QString>(name: "fileName"); |
52 | QTest::addColumn<QString>(name: "referenceFileName"); |
53 | QTest::addColumn<QSize>(name: "size"); |
54 | |
55 | QTest::newRow(dataTag: "logo") << QString( "logo.jp2") << QString( "logo.bmp") << QSize(498, 80); |
56 | } |
57 | |
58 | void tst_qjp2::readImage() |
59 | { |
60 | QFETCH(QString, fileName); |
61 | QFETCH(QString, referenceFileName); |
62 | QFETCH(QSize, size); |
63 | |
64 | QString path = QString(":/jp2/") + fileName; |
65 | QImageReader reader(path); |
66 | QVERIFY(reader.canRead()); |
67 | QImage image = reader.read(); |
68 | QVERIFY(!image.isNull()); |
69 | QCOMPARE(image.size(), size); |
70 | |
71 | path = QString(":jp2/") + referenceFileName; |
72 | QImageReader referenceReader(path); |
73 | QVERIFY(referenceReader.canRead()); |
74 | QImage referenceImage = referenceReader.read(); |
75 | QVERIFY(!referenceImage.isNull()); |
76 | QCOMPARE(referenceImage.size(), size); |
77 | } |
78 | |
79 | QTEST_MAIN(tst_qjp2) |
80 | #include "tst_qjp2.moc" |
81 |