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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 28/08/2021
0007  * Description : an unit-test to detect image quality level
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2021-2022 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "detectnoise_utest.h"
0017 
0018 // Qt includes
0019 
0020 #include <QTest>
0021 #include <QStringList>
0022 #include <QFileInfoList>
0023 #include <QDebug>
0024 #include <QDir>
0025 
0026 // Local includes
0027 
0028 #include "digikam_debug.h"
0029 
0030 using namespace Digikam;
0031 
0032 QTEST_MAIN(ImgQSortTestDetectNoise)
0033 
0034 ImgQSortTestDetectNoise::ImgQSortTestDetectNoise(QObject* const parent)
0035     : ImgQSortTest(parent)
0036 {
0037     m_dataTestCases = dataTestCases;
0038 }
0039 
0040 void ImgQSortTestDetectNoise::testParseTestImagesForNoiseDetection()
0041 {
0042     QHash<QString, bool> results = testParseTestImages(QLatin1String("noiseDetection"),
0043                                                        ImgQSortTest_ParseTestImagesDefautDetection, DETECTNOISE);
0044 
0045     for (const auto& test_case : results.keys())
0046     {
0047         QVERIFY(results.value(test_case));
0048     }
0049 }
0050 
0051 void ImgQSortTestDetectNoise::testParseTestImagesForImageHighSO()
0052 {
0053     QHash<QString, bool> results = testParseTestImages(QLatin1String("highISO"),
0054                                                        ImgQSortTest_ParseTestImagesDefautDetection, DETECTNOISE);
0055 
0056     for (const auto& test_case : results.keys())
0057     {
0058         QVERIFY(results.value(test_case));
0059     }
0060 }
0061 
0062 void ImgQSortTestDetectNoise::testParseTestImagesForVariousTypeNoise()
0063 {
0064     QHash<QString, bool> results = testParseTestImages(QLatin1String("variousTypesNoise"),
0065                                                        ImgQSortTest_ParseTestImagesDefautDetection, DETECTNOISE);
0066 
0067     for (const auto& test_case : results.keys())
0068     {
0069         QVERIFY(results.value(test_case));
0070     }
0071 }
0072 
0073 void ImgQSortTestDetectNoise::testParseTestImagesForVariousTypeNoiseFailCase()
0074 {
0075     QHash<QString, bool> results = testParseTestImages(QLatin1String("variousTypesNoiseFailCase"),
0076                                                        ImgQSortTest_ParseTestImagesDefautDetection, DETECTNOISE);
0077 
0078     for (const auto& test_case : results.keys())
0079     {
0080         QEXPECT_FAIL("", "Will fix in the next release", Continue);
0081 
0082         QVERIFY(results.value(test_case));
0083     }
0084 }
0085 
0086 #include "moc_detectnoise_utest.cpp"