File indexing completed on 2024-04-14 04:47:43

0001 /*
0002     SPDX-FileCopyrightText: 2017-2019 Nicolas Carion <french.ebook.lover@gmail.com>
0003     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 */
0005 
0006 #include "test_utils.hpp"
0007 // test specific headers
0008 #include "doc/documentchecker.h"
0009 
0010 TEST_CASE("Basic tests of the document checker parts", "[DocumentChecker]")
0011 {
0012     QString path = sourcesPath + "/dataset/test-mix.kdenlive";
0013 
0014     SECTION("Asset functions")
0015     {
0016         QDomDocument doc;
0017         Xml::docContentFromFile(doc, path, false);
0018 
0019         QStringList filters = DocumentChecker::getAssetsServiceIds(doc, QStringLiteral("filter"));
0020         CHECK(filters == QStringList({"volume", "panner", "audiolevel", "avfilter.fieldorder"}));
0021         qDebug() << filters;
0022 
0023         DocumentChecker::removeAssetsById(doc, QStringLiteral("filter"), QStringList({"volume"}));
0024         filters = DocumentChecker::getAssetsServiceIds(doc, QStringLiteral("filter"));
0025 
0026         CHECK(filters == QStringList({"panner", "audiolevel", "avfilter.fieldorder"}));
0027 
0028         QStringList transitions = DocumentChecker::getAssetsServiceIds(doc, QStringLiteral("transition"));
0029         CHECK(transitions == QStringList{"luma", "mix", "frei0r.cairoblend"});
0030 
0031         qDebug() << filters;
0032         qDebug() << transitions;
0033     }
0034 
0035     SECTION("Check build-in luma detection")
0036     {
0037         CHECK(DocumentChecker::isMltBuildInLuma(QStringLiteral("luma05.pgm")));
0038         CHECK_FALSE(DocumentChecker::isMltBuildInLuma(QStringLiteral("luma05.png")));
0039         CHECK_FALSE(DocumentChecker::isMltBuildInLuma(QStringLiteral("my-luma05.pgm")));
0040         CHECK_FALSE(DocumentChecker::isMltBuildInLuma(QStringLiteral("luma87.pgm")));
0041     }
0042 }
0043 
0044 TEST_CASE("Missing project items", "[DocumentChecker]")
0045 {
0046     QString path = sourcesPath + "/dataset/missing-proxy.kdenlive";
0047 
0048     SECTION("Missing proxy detection")
0049     {
0050         QDomDocument doc;
0051         Xml::docContentFromFile(doc, path, false);
0052         DocumentChecker d(QUrl::fromLocalFile(path), doc);
0053         d.hasErrorInProject();
0054         QMap<DocumentChecker::MissingType, int> results = d.getCheckResults();
0055         if (results.contains(DocumentChecker::MissingType::Clip)) {
0056             qDebug() << "::: MISSING CLIP: " << results.value(DocumentChecker::MissingType::Clip);
0057         }
0058         CHECK_FALSE(results.contains(DocumentChecker::MissingType::Clip));
0059         CHECK(results.contains(DocumentChecker::MissingType::Proxy));
0060         CHECK(results.value(DocumentChecker::MissingType::Proxy) == 1);
0061     }
0062 }