File indexing completed on 2024-05-12 04:19:57
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2012 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA. 0019 0020 */ 0021 // Self 0022 #include "cmsprofiletest.h" 0023 0024 // Local 0025 #include <lib/cms/cmsprofile.h> 0026 #include <lib/exiv2imageloader.h> 0027 #include <testutils.h> 0028 0029 // KF 0030 0031 // Qt 0032 #include <QTest> 0033 0034 QTEST_MAIN(CmsProfileTest) 0035 0036 using namespace Gwenview; 0037 0038 void CmsProfileTest::testLoadFromImageData() 0039 { 0040 QFETCH(QString, fileName); 0041 QFETCH(QByteArray, format); 0042 QByteArray data; 0043 { 0044 QString path = pathForTestFile(fileName); 0045 QFile file(path); 0046 QVERIFY(file.open(QIODevice::ReadOnly)); 0047 data = file.readAll(); 0048 } 0049 Cms::Profile::Ptr ptr = Cms::Profile::loadFromImageData(data, format); 0050 QVERIFY(ptr); 0051 } 0052 0053 #define NEW_ROW(fileName, format) QTest::newRow(fileName) << fileName << QByteArray(format) 0054 void CmsProfileTest::testLoadFromImageData_data() 0055 { 0056 QTest::addColumn<QString>("fileName"); 0057 QTest::addColumn<QByteArray>("format"); 0058 NEW_ROW("cms/colourTestFakeBRG.png", "png"); 0059 NEW_ROW("cms/colourTestsRGB.png", "png"); 0060 NEW_ROW("cms/Upper_Left.jpg", "jpeg"); 0061 NEW_ROW("cms/Upper_Right.jpg", "jpeg"); 0062 NEW_ROW("cms/Lower_Left.jpg", "jpeg"); 0063 NEW_ROW("cms/Lower_Right.jpg", "jpeg"); 0064 } 0065 #undef NEW_ROW 0066 0067 #if 0 0068 0069 void CmsProfileTest::testLoadFromExiv2Image() 0070 { 0071 QFETCH(QString, fileName); 0072 std::unique_ptr<Exiv2::Image> image; 0073 { 0074 QByteArray data; 0075 QString path = pathForTestFile(fileName); 0076 qWarning() << path; 0077 QFile file(path); 0078 QVERIFY(file.open(QIODevice::ReadOnly)); 0079 data = file.readAll(); 0080 0081 Exiv2ImageLoader loader; 0082 QVERIFY(loader.load(data)); 0083 image.reset(loader.popImage().release()); 0084 } 0085 Cms::Profile::Ptr ptr = Cms::Profile::loadFromExiv2Image(image.get()); 0086 QVERIFY(!ptr.isNull()); 0087 } 0088 0089 #define NEW_ROW(fileName) QTest::newRow(fileName) << fileName 0090 void CmsProfileTest::testLoadFromExiv2Image_data() 0091 { 0092 QTest::addColumn<QString>("fileName"); 0093 } 0094 #undef NEW_ROW 0095 0096 #endif 0097 0098 #include "moc_cmsprofiletest.cpp"