File: hidetest.cpp

package info (click to toggle)
kdenlive 25.12.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 125,912 kB
  • sloc: cpp: 206,648; xml: 11,857; python: 1,139; ansic: 1,054; javascript: 578; sh: 389; makefile: 15
file content (87 lines) | stat: -rw-r--r-- 3,337 bytes parent folder | download | duplicates (2)
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
/*
    SPDX-FileCopyrightText: 2022 Jean-Baptiste Mardelle <jb@kdenlive.org>
    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 "core.h"

using namespace fakeit;

TEST_CASE("Show/hide tracks", "[HideTracks]")
{
    // Create timeline
    auto binModel = pCore->projectItemModel();
    binModel->clean();
    std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);

    // Create document
    KdenliveDoc document(undoStack);
    pCore->projectManager()->testSetDocument(&document);
    std::function<bool(void)> undo = []() { return true; };
    std::function<bool(void)> redo = []() { return true; };
    QDateTime documentDate = QDateTime::currentDateTime();
    KdenliveTests::updateTimeline(false, QString(), QString(), documentDate, 0);
    auto timeline = document.getTimeline(document.uuid());
    pCore->projectManager()->testSetActiveTimeline(timeline);

    // Audio tracks
    /*int tid1 =*/timeline->getTrackIndexFromPosition(0);
    int tid2 = timeline->getTrackIndexFromPosition(1);
    // Video tracks
    int tid3 = timeline->getTrackIndexFromPosition(2);
    int tid4 = timeline->getTrackIndexFromPosition(3);

    // Create clip with audio (100 frames long)
    QString binId = KdenliveTests::createProducerWithSound(pCore->getProjectProfile(), binModel, 100);
    // Create color clip (50 frames long)
    QString binId2 = KdenliveTests::createProducer(pCore->getProjectProfile(), "red", binModel, 50, false);

    // Setup insert stream data
    QMap<int, QString> audioInfo;
    audioInfo.insert(1, QStringLiteral("stream1"));
    KdenliveTests::setAudioTargets(timeline, audioInfo);

    int cid1;
    int cid2;

    // Create AV clip 1
    REQUIRE(timeline->requestClipInsertion(binId, tid3, 10, cid1));
    cid2 = timeline->getClipSplitPartner(cid1);

    // Remove video part
    timeline->requestClipUngroup(cid2, undo, redo);
    timeline->requestItemDeletion(cid1);

    SECTION("Disable, enable audio track and check length")
    {
        REQUIRE(timeline->duration() == 110);
        timeline->setTrackProperty(tid2, QStringLiteral("hide"), "3");
        REQUIRE(timeline->duration() == 0);
        timeline->setTrackProperty(tid2, QStringLiteral("hide"), "1");
        REQUIRE(timeline->duration() == 110);
    }

    SECTION("Disable, add clip, enable audio track and check length")
    {
        REQUIRE(timeline->duration() == 110);
        timeline->setTrackProperty(tid2, QStringLiteral("hide"), "3");
        REQUIRE(timeline->duration() == 0);
        REQUIRE(timeline->requestClipInsertion(binId2, tid4, 10, cid1));
        REQUIRE(timeline->duration() == 60);
        timeline->setTrackProperty(tid2, QStringLiteral("hide"), "1");
        REQUIRE(timeline->duration() == 110);
        timeline->setTrackProperty(tid4, QStringLiteral("hide"), "3");
        REQUIRE(timeline->duration() == 110);
        timeline->setTrackProperty(tid4, QStringLiteral("hide"), "2");
        REQUIRE(timeline->duration() == 110);
        timeline->setTrackProperty(tid2, QStringLiteral("hide"), "3");
        REQUIRE(timeline->duration() == 60);
    }

    pCore->projectManager()->closeCurrentDocument(false, false);
}