1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
SPDX-FileCopyrightText: 2017-2019 Nicolas Carion <french.ebook.lover@gmail.com>
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "catch.hpp"
#include "test_utils.hpp"
// test specific headers
#include "doc/docundostack.hpp"
#include "doc/kdenlivedoc.h"
#include <cmath>
#include <iostream>
#include <tuple>
#include <unordered_set>
#include "core.h"
#include "definitions.h"
#include "effects/effectsrepository.hpp"
#include "effects/effectstack/model/effectitemmodel.hpp"
#include "effects/effectstack/model/effectstackmodel.hpp"
QString anEffect;
TEST_CASE("Effects stack", "[Effects]")
{
// Create timeline
auto binModel = pCore->projectItemModel();
std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);
// Here we do some trickery to enable testing.
// We mock the project class so that the undoStack function returns our undoStack
KdenliveDoc document(undoStack);
pCore->projectManager()->testSetDocument(&document);
QDateTime documentDate = QDateTime::currentDateTime();
KdenliveTests::updateTimeline(false, QString(), QString(), documentDate, 0);
auto timeline = document.getTimeline(document.uuid());
pCore->projectManager()->testSetActiveTimeline(timeline);
// Create a request
int tid1;
REQUIRE(timeline->requestTrackInsertion(-1, tid1));
// Create clip
QString binId = KdenliveTests::createProducer(pCore->getProjectProfile(), "red", binModel);
int cid1;
REQUIRE(timeline->requestClipInsertion(binId, tid1, 100, cid1));
std::shared_ptr<ProjectClip> clip = binModel->getClipByBinID(binId);
auto model = clip->getEffectStack();
REQUIRE(model->checkConsistency());
REQUIRE(model->rowCount() == 0);
// Check whether repo works
QVector<QPair<QString, QString>> effects = EffectsRepository::get()->getNames();
REQUIRE(!effects.isEmpty());
anEffect = QStringLiteral("sepia"); // effects.first().first;
REQUIRE(!anEffect.isEmpty());
SECTION("Create and delete effects")
{
REQUIRE(model->appendEffect(anEffect));
REQUIRE(model->checkConsistency());
REQUIRE(model->rowCount() == 1);
REQUIRE(model->appendEffect(anEffect));
REQUIRE(model->checkConsistency());
REQUIRE(model->rowCount() == 2);
undoStack->undo();
REQUIRE(model->checkConsistency());
REQUIRE(model->rowCount() == 1);
}
SECTION("Create cut with fade in")
{
auto clipModel = timeline->getClipEffectStackModel(cid1);
REQUIRE(clipModel->rowCount() == 0);
clipModel->appendEffect("fade_from_black");
REQUIRE(clipModel->checkConsistency());
REQUIRE(clipModel->rowCount() == 1);
int l = timeline->getClipPlaytime(cid1);
REQUIRE(TimelineFunctions::requestClipCut(timeline, cid1, 100 + l - 10));
int splitted = timeline->getClipByPosition(tid1, 100 + l - 9);
auto splitModel = timeline->getClipEffectStackModel(splitted);
REQUIRE(clipModel->rowCount() == 1);
REQUIRE(splitModel->rowCount() == 0);
}
SECTION("Create cut with fade out")
{
auto clipModel = timeline->getClipEffectStackModel(cid1);
REQUIRE(clipModel->rowCount() == 0);
clipModel->appendEffect("fade_to_black");
REQUIRE(clipModel->checkConsistency());
REQUIRE(clipModel->rowCount() == 1);
int l = timeline->getClipPlaytime(cid1);
REQUIRE(TimelineFunctions::requestClipCut(timeline, cid1, 100 + l - 10));
int splitted = timeline->getClipByPosition(tid1, 100 + l - 9);
auto splitModel = timeline->getClipEffectStackModel(splitted);
REQUIRE(clipModel->rowCount() == 0);
REQUIRE(splitModel->rowCount() == 1);
}
timeline.reset();
clip.reset();
pCore->projectManager()->closeCurrentDocument(false, false);
}
|