1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 28/08/2021
7 * Description : an unit-test to detect image quality level
8 *
9 * Copyright (C) 2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * Copyright (C) 2021 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com>
11 *
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General
14 * Public License as published by the Free Software Foundation;
15 * either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * ============================================================ */
24
25 #include "detectblur_utest.h"
26
27 // Qt includes
28
29 #include <QTest>
30 #include <QStringList>
31 #include <QFileInfoList>
32 #include <QDebug>
33 #include <QDir>
34
35 // Local includes
36
37 #include "digikam_globals.h"
38 #include "imagequalitycontainer.h"
39 #include "dpluginloader.h"
40 #include "digikam_debug.h"
41
42 using namespace Digikam;
43
QTEST_MAIN(ImgQSortTestDetectBlur)44 QTEST_MAIN(ImgQSortTestDetectBlur)
45
46 ImgQSortTestDetectBlur::ImgQSortTestDetectBlur(QObject* const parent)
47 : ImgQSortTest(parent)
48 {
49 m_dataTestCases = dataTestCases;
50 }
51
testParseTestImagesForBlurDetection()52 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection()
53 {
54 QHash<QString, bool> results = testParseTestImages(QLatin1String("blurDetection"),
55 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
56
57 for (const auto& test_case : results.keys())
58 {
59 QVERIFY(results.value(test_case));
60 }
61 }
62
testParseTestImagesForBlurDetection_SharpImage()63 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection_SharpImage()
64 {
65 QHash<QString, bool> results = testParseTestImages(QLatin1String("sharpImage"),
66 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
67
68 for (const auto& test_case : results.keys())
69 {
70 QVERIFY(results.value(test_case));
71 }
72 }
73
testParseTestImagesForBlurDetection_MotionBlurImage()74 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection_MotionBlurImage()
75 {
76 QHash<QString, bool> results = testParseTestImages(QLatin1String("motionBlurImage"),
77 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
78
79 for (const auto& test_case : results.keys())
80 {
81 QVERIFY(results.value(test_case));
82 }
83 }
84
testParseTestImagesForBlurDetection_DefocusImage()85 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection_DefocusImage()
86 {
87 QHash<QString, bool> results = testParseTestImages(QLatin1String("defocusImage"),
88 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
89
90 for (const auto& test_case : results.keys())
91 {
92 QVERIFY(results.value(test_case));
93 }
94 }
95
testParseTestImagesForBlurDetection_BlurBackGroundImage()96 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection_BlurBackGroundImage()
97 {
98 QHash<QString, bool> results = testParseTestImages(QLatin1String("blurBackGroundImage"),
99 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
100
101 for (const auto& test_case : results.keys())
102 {
103 QVERIFY(results.value(test_case));
104 }
105 }
106
testParseTestImagesForBlurDetection_FailCase()107 void ImgQSortTestDetectBlur::testParseTestImagesForBlurDetection_FailCase()
108 {
109 QHash<QString, bool> results = testParseTestImages(QLatin1String("blurDetectionFailTest"),
110 ImgQSortTest_ParseTestImagesDefautDetection, DETECTBLUR);
111
112 for (const auto& test_case : results.keys())
113 {
114 QEXPECT_FAIL("", "Will fix in the next release", Continue);
115
116 QVERIFY(results.value(test_case));
117 }
118 }
119