File indexing completed on 2024-05-26 08:45:43

0001 /*
0002     SPDX-FileCopyrightText: 2018-2022 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003     SPDX-FileCopyrightText: 2017-2019 Nicolas Carion <french.ebook.lover@gmail.com>
0004     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 #pragma once
0007 #include "abortutil.hpp"
0008 #include "catch.hpp"
0009 #include "tests_definitions.h"
0010 #include <QString>
0011 #include <iostream>
0012 #include <memory>
0013 #include <random>
0014 #include <string>
0015 
0016 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
0017 #pragma GCC diagnostic push
0018 #include "fakeit.hpp"
0019 #include <mlt++/MltFactory.h>
0020 #include <mlt++/MltProducer.h>
0021 #include <mlt++/MltProfile.h>
0022 #include <mlt++/MltRepository.h>
0023 #define private public
0024 #define protected public
0025 #include "assets/keyframes/model/keyframemodel.hpp"
0026 #include "assets/model/assetparametermodel.hpp"
0027 #include "bin/clipcreator.hpp"
0028 #include "bin/model/markerlistmodel.hpp"
0029 #include "bin/model/subtitlemodel.hpp"
0030 #include "bin/projectclip.h"
0031 #include "bin/projectfolder.h"
0032 #include "bin/projectitemmodel.h"
0033 #include "core.h"
0034 #include "doc/docundostack.hpp"
0035 #include "effects/effectsrepository.hpp"
0036 #include "effects/effectstack/model/effectitemmodel.hpp"
0037 #include "effects/effectstack/model/effectstackmodel.hpp"
0038 #include "project/projectmanager.h"
0039 #include "timeline2/model/clipmodel.hpp"
0040 #include "timeline2/model/compositionmodel.hpp"
0041 #include "timeline2/model/groupsmodel.hpp"
0042 #include "timeline2/model/timelinefunctions.hpp"
0043 #include "timeline2/model/timelineitemmodel.hpp"
0044 #include "timeline2/model/timelinemodel.hpp"
0045 #include "timeline2/model/trackmodel.hpp"
0046 #include "transitions/transitionsrepository.hpp"
0047 
0048 using namespace fakeit;
0049 #define RESET(mock)                                                                                                                                            \
0050     mock.Reset();                                                                                                                                              \
0051     Fake(Method(mock, adjustAssetRange));                                                                                                                      \
0052     Spy(Method(mock, _beginInsertRows));                                                                                                                       \
0053     Spy(Method(mock, _beginRemoveRows));                                                                                                                       \
0054     Spy(Method(mock, _endInsertRows));                                                                                                                         \
0055     Spy(Method(mock, _endRemoveRows));                                                                                                                         \
0056     Spy(OverloadedMethod(mock, notifyChange, void(const QModelIndex &, const QModelIndex &, bool, bool, bool)));                                               \
0057     Spy(OverloadedMethod(mock, notifyChange, void(const QModelIndex &, const QModelIndex &, const QVector<int> &)));                                           \
0058     Spy(OverloadedMethod(mock, notifyChange, void(const QModelIndex &, const QModelIndex &, int)));
0059 
0060 #define NO_OTHERS()                                                                                                                                            \
0061     VerifyNoOtherInvocations(Method(timMock, _beginRemoveRows));                                                                                               \
0062     VerifyNoOtherInvocations(Method(timMock, _beginInsertRows));                                                                                               \
0063     VerifyNoOtherInvocations(Method(timMock, _endRemoveRows));                                                                                                 \
0064     VerifyNoOtherInvocations(Method(timMock, _endInsertRows));                                                                                                 \
0065     VerifyNoOtherInvocations(OverloadedMethod(timMock, notifyChange, void(const QModelIndex &, const QModelIndex &, bool, bool, bool)));                       \
0066     VerifyNoOtherInvocations(OverloadedMethod(timMock, notifyChange, void(const QModelIndex &, const QModelIndex &, const QVector<int> &)));                   \
0067     RESET(timMock);
0068 
0069 #define CHECK_MOVE(times)                                                                                                                                      \
0070     Verify(Method(timMock, _beginRemoveRows) + Method(timMock, _endRemoveRows) + Method(timMock, _beginInsertRows) + Method(timMock, _endInsertRows))          \
0071         .Exactly(times);                                                                                                                                       \
0072     NO_OTHERS();
0073 
0074 #define CHECK_INSERT(times)                                                                                                                                    \
0075     Verify(Method(timMock, _beginInsertRows) + Method(timMock, _endInsertRows)).Exactly(times);                                                                \
0076     NO_OTHERS();
0077 
0078 #define CHECK_REMOVE(times)                                                                                                                                    \
0079     Verify(Method(timMock, _beginRemoveRows) + Method(timMock, _endRemoveRows)).Exactly(times);                                                                \
0080     NO_OTHERS();
0081 
0082 #define CHECK_RESIZE(times)                                                                                                                                    \
0083     Verify(OverloadedMethod(timMock, notifyChange, void(const QModelIndex &, const QModelIndex &, const QVector<int> &))).Exactly(times);                      \
0084     NO_OTHERS();
0085 
0086 #define CHECK_UPDATE(role)                                                                                                                                     \
0087     Verify(OverloadedMethod(timMock, notifyChange, void(const QModelIndex &, const QModelIndex &, int))                                                        \
0088                .Matching([](const QModelIndex &, const QModelIndex &, int c) { return c == role; }))                                                           \
0089         .Exactly(1);                                                                                                                                           \
0090     NO_OTHERS();
0091 
0092 QString createProducer(Mlt::Profile &prof, std::string color, std::shared_ptr<ProjectItemModel> binModel, int length = 20, bool limited = true);
0093 
0094 QString createProducerWithSound(Mlt::Profile &prof, std::shared_ptr<ProjectItemModel> binModel, int length = 10);
0095 
0096 QString createTextProducer(Mlt::Profile &prof, std::shared_ptr<ProjectItemModel> binModel, const QString &xmldata, const QString &clipname, int length = 10);
0097 
0098 QString createAVProducer(Mlt::Profile &prof, std::shared_ptr<ProjectItemModel> binModel);
0099 
0100 std::unique_ptr<QDomElement> getProperty(const QDomElement& element, const QString& name);