File indexing completed on 2025-01-05 03:58:04
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2012-10-23 0007 * Description : an unit-test to check DImg image loader 0008 * 0009 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "dimgloader_utest.h" 0016 0017 // Qt includes 0018 0019 #include <QApplication> 0020 #include <QTest> 0021 #include <QFileInfo> 0022 #include <QList> 0023 #include <QDir> 0024 0025 // Local includes 0026 0027 #include "digikam_debug.h" 0028 #include "metaengine.h" 0029 #include "dpluginloader.h" 0030 #include "dtestdatadir.h" 0031 #include "drawdecoding.h" 0032 0033 QTEST_GUILESS_MAIN(DImgLoaderTest) 0034 0035 DImgLoaderTest::DImgLoaderTest(QObject* const parent) 0036 : QObject(parent) 0037 { 0038 } 0039 0040 void DImgLoaderTest::testDImgLoader() 0041 { 0042 MetaEngine::initializeExiv2(); 0043 QDir dir(qApp->applicationDirPath()); 0044 qputenv("DK_PLUGIN_PATH", dir.canonicalPath().toUtf8()); 0045 DPluginLoader::instance()->init(); 0046 0047 QVERIFY2(!DPluginLoader::instance()->allPlugins().isEmpty(), 0048 "Not able to found digiKam plugin in standard paths. Test is aborted..."); 0049 0050 QString fname = DTestDataDir::TestData(QString::fromUtf8("core/tests/dimg")) 0051 .root().path() + QLatin1String("/DSC00636.JPG"); 0052 qCDebug(DIGIKAM_TESTS_LOG) << "Test Data File:" << fname; 0053 0054 DRawDecoderSettings settings; 0055 settings.halfSizeColorImage = false; 0056 settings.sixteenBitsImage = false; 0057 settings.RGBInterpolate4Colors = false; 0058 settings.RAWQuality = DRawDecoderSettings::BILINEAR; 0059 0060 DImg img(fname, nullptr, DRawDecoding(settings)); 0061 0062 QVERIFY2(!img.isNull(), "Cannot load JPEG image with DImg plugin"); 0063 QVERIFY2(img.size() == QSize(100, 67), "Incorrect JPEG image size..."); 0064 QVERIFY2(img.save(fname + QLatin1String(".png"), QLatin1String("PNG")), 0065 "Cannot save PNG image with DImg plugin"); 0066 0067 DPluginLoader::instance()->cleanUp(); 0068 } 0069 0070 #include "moc_dimgloader_utest.cpp"