File indexing completed on 2025-01-05 03:58:08

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2009-02-04
0007  * Description : an unit-test to load PGF file scaled to QImage
0008  *
0009  * SPDX-FileCopyrightText: 2011-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 "pgfscaled_utest.h"
0016 
0017 // Qt includes
0018 
0019 #include <QTest>
0020 #include <QFile>
0021 #include <QIODevice>
0022 #include <QImage>
0023 
0024 // Local includes
0025 
0026 #include "digikam_debug.h"
0027 #include "dtestdatadir.h"
0028 #include "pgfutils.h"
0029 
0030 using namespace Digikam;
0031 
0032 QTEST_GUILESS_MAIN(PGFScaledTest)
0033 
0034 PGFScaledTest::PGFScaledTest(QObject* const parent)
0035     : QObject(parent)
0036 {
0037 }
0038 
0039 void PGFScaledTest::testPGFScaled()
0040 {
0041     qCDebug(DIGIKAM_TESTS_LOG) << "Using LibPGF version: " << PGFUtils::libPGFVersion();
0042     QImage img;
0043 
0044     QString fname = DTestDataDir::TestData(QString::fromUtf8("core/tests/fileio"))
0045                        .root().path() + QLatin1String("/4324477432.pgf");
0046     qCDebug(DIGIKAM_TESTS_LOG) << "Test Data File:" << fname;
0047 
0048     QFile   file(fname);
0049 
0050     QVERIFY2(file.open(QIODevice::ReadOnly), "Cannot read Raw PGF file...");
0051 
0052     // PGF => QImage conversion
0053 
0054     QVERIFY2(PGFUtils::loadPGFScaled(img, file.fileName(), 1280), "Cannot load PGF scaled file");
0055 
0056     qCDebug(DIGIKAM_TESTS_LOG) << "PGF image size:"         << img.size();
0057     qCDebug(DIGIKAM_TESTS_LOG) << "PGF image color depth:"  << img.depth();
0058     qCDebug(DIGIKAM_TESTS_LOG) << "PGF image color format:" << img.format();
0059 
0060     QVERIFY2(!img.isNull(), "PGF image is null...");
0061     QVERIFY2(img.size()  == QSize(2016, 1512), "Incorrect PGF image size...");
0062     QVERIFY2(img.depth() == 32, "Incorrect PGF image color depth...");
0063     QVERIFY2(img.format() == QImage::Format_RGB32, "Incorrect PGF image color format...");
0064 }
0065 
0066 #include "moc_pgfscaled_utest.cpp"