File indexing completed on 2024-06-16 04:16:56

0001 /*
0002  * SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "kis_jpeg_test.h"
0008 
0009 #include <simpletest.h>
0010 #include <QCoreApplication>
0011 
0012 #include "filestest.h"
0013 #include "jpeglib.h"
0014 #include <kis_meta_data_backend_registry.h>
0015 #include <testui.h>
0016 
0017 #ifndef FILES_DATA_DIR
0018 #error "FILES_DATA_DIR not set. A directory with the data used for testing the importing of files in krita"
0019 #endif
0020 
0021 #ifndef JPEG_LIB_VERSION
0022 #error "JPEG_LIB_VERSION not set. libjpeg should set it."
0023 #endif
0024 
0025 const QString JpegMimetype = "image/jpeg";
0026 
0027 void KisJpegTest::testFiles()
0028 {
0029     KisMetadataBackendRegistry::instance();
0030     /**
0031      * Different versions of JPEG library may produce a bit different
0032      * result, so just compare in a weak way, i.e, only the size for real
0033      */
0034     const int fuzziness = 1;
0035     const int maxNumFailingPixels = 2592 * 1952; // All pixels can be different...
0036     const bool showDebug = false; // No need to write down all pixels that are different since all of them can be.
0037 
0038     if (JPEG_LIB_VERSION == 80){
0039         TestUtil::testFiles(QString(FILES_DATA_DIR) + "/sources", QStringList(), "_80", fuzziness, maxNumFailingPixels, showDebug);
0040     }else {
0041         TestUtil::testFiles(QString(FILES_DATA_DIR) + "/sources", QStringList(), QString(), fuzziness, maxNumFailingPixels, showDebug);
0042     }
0043 }
0044 
0045 void KisJpegTest::testImportFromWriteonly()
0046 {
0047     TestUtil::testImportFromWriteonly(JpegMimetype);
0048 }
0049 
0050 
0051 void KisJpegTest::testExportToReadonly()
0052 {
0053     TestUtil::testExportToReadonly(JpegMimetype);
0054 }
0055 
0056 
0057 void KisJpegTest::testImportIncorrectFormat()
0058 {
0059     TestUtil::testImportIncorrectFormat(JpegMimetype);
0060 }
0061 KISTEST_MAIN(KisJpegTest)
0062