Commit 5c8ec91f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

File loading: better separate model from ui to make testing easier

parent 81ee8a0e
Pipeline #215608 passed with stage
in 13 minutes and 50 seconds
......@@ -2270,6 +2270,28 @@ void MainWindow::connectDocument()
connect(project, &KdenliveDoc::startAutoSave, pCore->projectManager(), &ProjectManager::slotStartAutoSave);
connect(project, &KdenliveDoc::reloadEffects, this, &MainWindow::slotReloadEffects);
KdenliveSettings::setProject_fps(pCore->getCurrentFps());
slotSwitchTimelineZone(project->getDocumentProperty(QStringLiteral("enableTimelineZone")).toInt() == 1);
// update track compositing
bool compositing = project->getDocumentProperty(QStringLiteral("compositing"), QStringLiteral("1")).toInt() > 0;
emit project->updateCompositionMode(compositing);
getMainTimeline()->controller()->switchCompositing(compositing);
connect(getMainTimeline()->controller(), &TimelineController::durationChanged, pCore->projectManager(), &ProjectManager::adjustProjectDuration);
slotUpdateProjectDuration(getMainTimeline()->model()->duration() - 1);
getMainTimeline()->controller()->setZone(project->zone(), false);
getMainTimeline()->controller()->setScrollPos(project->getDocumentProperty(QStringLiteral("scrollPos")).toInt());
int activeTrackPosition = project->getDocumentProperty(QStringLiteral("activeTrack"), QString::number(-1)).toInt();
if (activeTrackPosition == -2) {
// Subtitle model track always has ID == -2
getMainTimeline()->controller()->setActiveTrack(-2);
} else if (activeTrackPosition > -1 && activeTrackPosition < getMainTimeline()->model()->getTracksCount()) {
// otherwise, convert the position to a track ID
getMainTimeline()->controller()->setActiveTrack(getMainTimeline()->model()->getTrackIndexFromPosition(activeTrackPosition));
} else {
qWarning() << "[BUG] \"activeTrack\" property is" << activeTrackPosition << "but track count is only" << getMainTimeline()->model()->getTracksCount();
// set it to some valid track instead
getMainTimeline()->controller()->setActiveTrack(getMainTimeline()->model()->getTrackIndexFromPosition(0));
}
m_projectMonitor->slotLoadClipZone(project->zone());
m_clipMonitor->updateDocumentUuid();
connect(m_projectMonitor, &Monitor::multitrackView, getMainTimeline()->controller(), &TimelineController::slotMultitrackView, Qt::UniqueConnection);
......
......@@ -267,6 +267,11 @@ void ProjectManager::testSetActiveDocument(KdenliveDoc *doc, std::shared_ptr<Tim
m_mainTimelineModel = timeline;
}
std::shared_ptr<TimelineItemModel> ProjectManager::getTimeline()
{
return m_mainTimelineModel;
}
bool ProjectManager::testSaveFileAs(const QString &outputFileName)
{
QString saveFolder = QFileInfo(outputFileName).absolutePath();
......@@ -705,6 +710,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale, bool isBa
m_project = doc;
m_project->loadDocumentGuides();
QDateTime documentDate = QFileInfo(m_project->url().toLocalFile()).lastModified();
if (!updateTimeline(m_project->getDocumentProperty(QStringLiteral("position")).toInt(), m_project->getDocumentProperty(QStringLiteral("previewchunks")),
m_project->getDocumentProperty(QStringLiteral("dirtypreviewchunks")), documentDate,
m_project->getDocumentProperty(QStringLiteral("disablepreview")).toInt())) {
......@@ -1041,11 +1047,8 @@ void ProjectManager::requestBackup(const QString &errorMessage)
bool ProjectManager::updateTimeline(int pos, const QString &chunks, const QString &dirty, const QDateTime &documentDate, int enablePreview)
{
pCore->taskManager.slotCancelJobs();
pCore->window()->getMainTimeline()->loading = true;
pCore->window()->slotSwitchTimelineZone(m_project->getDocumentProperty(QStringLiteral("enableTimelineZone")).toInt() == 1);
QScopedPointer<Mlt::Producer> xmlProd(
new Mlt::Producer(pCore->getCurrentProfile()->profile(), "xml-string", m_project->getAndClearProjectXml().constData()));
QScopedPointer<Mlt::Producer> xmlProd(new Mlt::Producer(*pCore->getProjectProfile(), "xml-string", m_project->getAndClearProjectXml().constData()));
Mlt::Service s(*xmlProd);
Mlt::Tractor tractor(s);
......@@ -1057,7 +1060,9 @@ bool ProjectManager::updateTimeline(int pos, const QString &chunks, const QStrin
m_mainTimelineModel = TimelineItemModel::construct(pCore->getProjectProfile(), m_project->getGuideModel(), m_project->commandStack());
// Add snap point at project start
m_mainTimelineModel->addSnap(0);
pCore->window()->getMainTimeline()->setModel(m_mainTimelineModel, pCore->monitorManager()->projectMonitor()->getControllerProxy());
if (pCore->window()) {
pCore->window()->getMainTimeline()->setModel(m_mainTimelineModel, pCore->monitorManager()->projectMonitor()->getControllerProxy());
}
bool projectErrors = false;
m_project->cleanupTimelinePreview(documentDate);
if (!constructTimelineFromMelt(m_mainTimelineModel, tractor, m_progressDialog, m_project->modifiedDecimalPoint(), chunks, dirty, enablePreview,
......@@ -1071,34 +1076,16 @@ bool ProjectManager::updateTimeline(int pos, const QString &chunks, const QStrin
xmlProd->clear();
xmlProd.reset(nullptr);
const QString groupsData = m_project->getDocumentProperty(QStringLiteral("groups"));
// update track compositing
bool compositing = pCore->currentDoc()->getDocumentProperty(QStringLiteral("compositing"), QStringLiteral("1")).toInt() > 0;
emit pCore->currentDoc()->updateCompositionMode(compositing);
pCore->window()->getMainTimeline()->controller()->switchCompositing(compositing);
if (!groupsData.isEmpty()) {
m_mainTimelineModel->loadGroups(groupsData);
}
connect(pCore->window()->getMainTimeline()->controller(), &TimelineController::durationChanged, this, &ProjectManager::adjustProjectDuration);
emit pCore->monitorManager()->updatePreviewScaling();
pCore->monitorManager()->projectMonitor()->slotActivateMonitor();
pCore->monitorManager()->projectMonitor()->setProducer(m_mainTimelineModel->producer(), pos);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_mainTimelineModel->duration() - 1, m_project->getGuideModel());
pCore->window()->slotUpdateProjectDuration(m_mainTimelineModel->duration() - 1);
pCore->window()->getMainTimeline()->controller()->setZone(m_project->zone(), false);
pCore->window()->getMainTimeline()->controller()->setScrollPos(m_project->getDocumentProperty(QStringLiteral("scrollPos")).toInt());
int activeTrackPosition = m_project->getDocumentProperty(QStringLiteral("activeTrack"), QString::number(-1)).toInt();
if (activeTrackPosition == -2) {
// Subtitle model track always has ID == -2
pCore->window()->getMainTimeline()->controller()->setActiveTrack(-2);
} else if (activeTrackPosition > -1 && activeTrackPosition < m_mainTimelineModel->getTracksCount()) {
// otherwise, convert the position to a track ID
pCore->window()->getMainTimeline()->controller()->setActiveTrack(m_mainTimelineModel->getTrackIndexFromPosition(activeTrackPosition));
} else {
qWarning() << "[BUG] \"activeTrack\" property is" << activeTrackPosition <<
"but track count is only" << m_mainTimelineModel->getTracksCount();
// set it to some valid track instead
pCore->window()->getMainTimeline()->controller()->setActiveTrack(m_mainTimelineModel->getTrackIndexFromPosition(0));
if (pCore->monitorManager()) {
emit pCore->monitorManager()->updatePreviewScaling();
pCore->monitorManager()->projectMonitor()->slotActivateMonitor();
pCore->monitorManager()->projectMonitor()->setProducer(m_mainTimelineModel->producer(), pos);
pCore->monitorManager()->projectMonitor()->adjustRulerSize(m_mainTimelineModel->duration() - 1, m_project->getGuideModel());
}
m_mainTimelineModel->setUndoStack(m_project->commandStack());
// Reset locale to C to ensure numbers are serialised correctly
......
......@@ -99,6 +99,9 @@ public:
/** @brief This method is only there for tests, do not use in real app.
*/
bool testSaveFileAs(const QString &outputFileName);
/** @brief Retrieve the current timeline (mostly used for testing.
*/
std::shared_ptr<TimelineItemModel> getTimeline();
public slots:
void newFile(QString profileName, bool showProjectSettings = true);
......
......@@ -748,6 +748,7 @@ Fun TrackModel::requestClipResize_lambda(int clipId, int in, int out, bool right
err = m_playlists[target_track].resize_clip(blank, 0, blank_length + delta - 1);
}
if (err == 0) {
// m_track->block();
QScopedPointer<Mlt::Producer> clip(m_playlists[target_track].get_clip(target_clip_mutable));
if (out >= clip->get_length()) {
clip->parent().set("length", out + 1);
......@@ -756,6 +757,7 @@ Fun TrackModel::requestClipResize_lambda(int clipId, int in, int out, bool right
clip->set("out", out);
}
err = m_playlists[target_track].resize_clip(target_clip_mutable, in, out);
// m_track->unblock();
}
if (!right && err == 0) {
m_allClips[clipId]->setPosition(m_playlists[target_track].clip_start(target_clip_mutable));
......
......@@ -147,6 +147,7 @@ void TimelineWidget::unsetModel()
void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, MonitorProxy *proxy)
{
loading = true;
m_sortModel->setSourceModel(model.get());
m_sortModel->setSortRole(TimelineItemModel::SortRole);
m_sortModel->sort(0, Qt::DescendingOrder);
......
......@@ -23,7 +23,7 @@ add_executable(runTests
trimmingtest.cpp
cachetest.cpp
movetest.cpp
subtitlestest.cpp
#subtitlestest.cpp
)
set_property(TARGET runTests PROPERTY CXX_STANDARD 14)
target_link_libraries(runTests kdenliveLib)
......
<?xml version='1.0' encoding='utf-8'?>
<mlt LC_NUMERIC="C" producer="main_bin" version="7.9.0">
<profile frame_rate_num="25" sample_aspect_num="16" display_aspect_den="3" colorspace="601" progressive="0" description="DV/DVD PAL" display_aspect_num="4" frame_rate_den="1" width="720" height="576" sample_aspect_den="15"/>
<producer id="producer0" in="00:00:00.000" out="00:00:18.800">
<property name="length">471</property>
<property name="eof">pause</property>
<property name="resource">0x80ff80ff</property>
<property name="aspect_ratio">1.06667</property>
<property name="mlt_service">color</property>
<property name="kdenlive:clipname">Color Clip</property>
<property name="kdenlive:duration">00:00:05.000</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:clip_type">2</property>
<property name="kdenlive:id">2</property>
<property name="mlt_image_format">rgb</property>
<property name="kdenlive:file_hash">e41d2d5aa7fe00585e597a92e0ac1bbd</property>
</producer>
<producer id="producer1" in="00:00:00.000" out="00:00:14.960">
<property name="length">375</property>
<property name="eof">pause</property>
<property name="resource">0xff8080ff</property>
<property name="aspect_ratio">1.06667</property>
<property name="mlt_service">color</property>
<property name="kdenlive:clipname">Color Clip</property>
<property name="kdenlive:duration">00:00:05.000</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:clip_type">2</property>
<property name="kdenlive:id">3</property>
<property name="mlt_image_format">rgb</property>
<property name="kdenlive:file_hash">17fc70539c5356a67cd8cc241da1f3e2</property>
</producer>
<producer id="producer2" in="00:00:00.000" out="00:00:04.960">
<property name="length">00:00:05.000</property>
<property name="eof">pause</property>
<property name="resource">0xffffffff</property>
<property name="aspect_ratio">1.06667</property>
<property name="mlt_service">color</property>
<property name="kdenlive:clipname">Color Clip</property>
<property name="kdenlive:duration">00:00:05.000</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:clip_type">2</property>
<property name="kdenlive:id">4</property>
<property name="mlt_image_format">rgb</property>
<property name="kdenlive:file_hash">039b56a692cd66eefeea44a17539e5a2</property>
</producer>
<playlist id="main_bin">
<property name="kdenlive:docproperties.activeTrack">2</property>
<property name="kdenlive:docproperties.audioChannels">2</property>
<property name="kdenlive:docproperties.audioTarget">-1</property>
<property name="kdenlive:docproperties.compositing">1</property>
<property name="kdenlive:docproperties.disablepreview">0</property>
<property name="kdenlive:docproperties.documentid">1660053376306</property>
<property name="kdenlive:docproperties.enableTimelineZone">0</property>
<property name="kdenlive:docproperties.enableexternalproxy">0</property>
<property name="kdenlive:docproperties.enableproxy">0</property>
<property name="kdenlive:docproperties.externalproxyparams">./;GL;.LRV;./;GX;.MP4;./;GP;.LRV;./;GP;.MP4</property>
<property name="kdenlive:docproperties.generateimageproxy">0</property>
<property name="kdenlive:docproperties.generateproxy">0</property>
<property name="kdenlive:docproperties.groups">[
]
</property>
<property name="kdenlive:docproperties.kdenliveversion">22.11.70</property>
<property name="kdenlive:docproperties.position">464</property>
<property name="kdenlive:docproperties.previewextension"/>
<property name="kdenlive:docproperties.previewparameters"/>
<property name="kdenlive:docproperties.profile">dv_pal</property>
<property name="kdenlive:docproperties.proxyextension"/>
<property name="kdenlive:docproperties.proxyimageminsize">2000</property>
<property name="kdenlive:docproperties.proxyimagesize">800</property>
<property name="kdenlive:docproperties.proxyminsize">1000</property>
<property name="kdenlive:docproperties.proxyparams"/>
<property name="kdenlive:docproperties.proxyresize">640</property>
<property name="kdenlive:docproperties.scrollPos">0</property>
<property name="kdenlive:docproperties.seekOffset">30000</property>
<property name="kdenlive:docproperties.version">1.04</property>
<property name="kdenlive:docproperties.verticalzoom">1</property>
<property name="kdenlive:docproperties.videoTarget">2</property>
<property name="kdenlive:docproperties.zonein">0</property>
<property name="kdenlive:docproperties.zoneout">75</property>
<property name="kdenlive:docproperties.zoom">7</property>
<property name="kdenlive:expandedFolders"/>
<property name="kdenlive:documentnotes"/>
<property name="xml_retain">1</property>
<entry producer="producer0" in="00:00:00.000" out="00:00:18.800"/>
<entry producer="producer1" in="00:00:00.000" out="00:00:14.960"/>
<entry producer="producer2" in="00:00:00.000" out="00:00:04.960"/>
</playlist>
<producer id="black_track" in="00:00:00.000" out="00:20:38.920">
<property name="length">2147483647</property>
<property name="eof">continue</property>
<property name="resource">black</property>
<property name="aspect_ratio">1</property>
<property name="mlt_service">color</property>
<property name="mlt_image_format">rgba</property>
<property name="set.test_audio">0</property>
</producer>
<playlist id="playlist0">
<property name="kdenlive:audio_track">1</property>
</playlist>
<playlist id="playlist1">
<property name="kdenlive:audio_track">1</property>
</playlist>
<tractor id="tractor0" in="00:00:00.000">
<property name="kdenlive:audio_track">1</property>
<property name="kdenlive:trackheight">67</property>
<property name="kdenlive:timeline_active">1</property>
<property name="kdenlive:collapsed">0</property>
<property name="kdenlive:thumbs_format"/>
<property name="kdenlive:audio_rec"/>
<track hide="video" producer="playlist0"/>
<track hide="video" producer="playlist1"/>
<filter id="filter0">
<property name="window">75</property>
<property name="max_gain">20dB</property>
<property name="mlt_service">volume</property>
<property name="internal_added">237</property>
<property name="disable">1</property>
</filter>
<filter id="filter1">
<property name="channel">-1</property>
<property name="mlt_service">panner</property>
<property name="internal_added">237</property>
<property name="start">0.5</property>
<property name="disable">1</property>
</filter>
<filter id="filter2">
<property name="iec_scale">0</property>
<property name="mlt_service">audiolevel</property>
<property name="peak">1</property>
<property name="disable">1</property>
</filter>
</tractor>
<playlist id="playlist2">
<property name="kdenlive:audio_track">1</property>
</playlist>
<playlist id="playlist3">
<property name="kdenlive:audio_track">1</property>
</playlist>
<tractor id="tractor1" in="00:00:00.000">
<property name="kdenlive:audio_track">1</property>
<property name="kdenlive:trackheight">67</property>
<property name="kdenlive:timeline_active">1</property>
<property name="kdenlive:collapsed">0</property>
<property name="kdenlive:thumbs_format"/>
<property name="kdenlive:audio_rec"/>
<track hide="video" producer="playlist2"/>
<track hide="video" producer="playlist3"/>
<filter id="filter3">
<property name="window">75</property>
<property name="max_gain">20dB</property>
<property name="mlt_service">volume</property>
<property name="internal_added">237</property>
<property name="disable">1</property>
</filter>
<filter id="filter4">
<property name="channel">-1</property>
<property name="mlt_service">panner</property>
<property name="internal_added">237</property>
<property name="start">0.5</property>
<property name="disable">1</property>
</filter>
<filter id="filter5">
<property name="iec_scale">0</property>
<property name="mlt_service">audiolevel</property>
<property name="peak">1</property>
<property name="disable">1</property>
</filter>
</tractor>
<playlist id="playlist4">
<blank length="00:00:05.080"/>
<entry producer="producer0" in="00:00:00.000" out="00:00:05.440">
<property name="kdenlive:id">2</property>
</entry>
<blank length="00:00:04.000"/>
<entry producer="producer0" in="00:00:00.000" out="00:00:03.960">
<property name="kdenlive:id">2</property>
</entry>
</playlist>
<playlist id="playlist5">
<blank length="00:00:05.080"/>
<entry producer="producer1" in="00:00:00.000" out="00:00:13.440">
<property name="kdenlive:id">3</property>
</entry>
</playlist>
<tractor id="tractor2" in="00:00:00.000" out="00:00:18.520">
<property name="kdenlive:trackheight">67</property>
<property name="kdenlive:timeline_active">1</property>
<property name="kdenlive:collapsed">0</property>
<property name="kdenlive:thumbs_format"/>
<property name="kdenlive:audio_rec"/>
<track hide="audio" producer="playlist4"/>
<track hide="audio" producer="playlist5"/>
<transition id="transition1" in="00:00:14.560" out="00:00:18.560">
<property name="a_track">0</property>
<property name="b_track">1</property>
<property name="factory">loader</property>
<property name="resource"/>
<property name="mlt_service">luma</property>
<property name="kdenlive_id">luma</property>
<property name="kdenlive:mixcut">87</property>
<property name="reverse">1</property>
<property name="softness">0</property>
<property name="alpha_over">1</property>
<property name="invert">0</property>
</transition>
<transition id="transition0" in="00:00:05.080" out="00:00:10.560">
<property name="a_track">0</property>
<property name="b_track">1</property>
<property name="factory">loader</property>
<property name="resource"/>
<property name="mlt_service">luma</property>
<property name="kdenlive_id">luma</property>
<property name="kdenlive:mixcut">12</property>
<property name="softness">0</property>
<property name="alpha_over">1</property>
<property name="invert">0</property>
<property name="reverse">0</property>
</transition>
</tractor>
<playlist id="playlist6">
<blank length="00:00:21.440"/>
<entry producer="producer0" in="00:00:00.000" out="00:00:17.440">
<property name="kdenlive:id">2</property>
</entry>
</playlist>
<playlist id="playlist7">
<blank length="00:00:21.440"/>
<entry producer="producer1" in="00:00:00.000" out="00:00:12.920">
<property name="kdenlive:id">3</property>
</entry>
</playlist>
<tractor id="tractor3" in="00:00:00.000" out="00:00:38.880">
<property name="kdenlive:trackheight">67</property>
<property name="kdenlive:timeline_active">1</property>
<property name="kdenlive:collapsed">0</property>
<property name="kdenlive:thumbs_format"/>
<property name="kdenlive:audio_rec"/>
<track hide="audio" producer="playlist6"/>
<track hide="audio" producer="playlist7"/>
<transition id="transition2" in="00:00:21.440" out="00:00:34.400">
<property name="a_track">0</property>
<property name="b_track">1</property>
<property name="factory">loader</property>
<property name="resource"/>
<property name="mlt_service">luma</property>
<property name="kdenlive_id">luma</property>
<property name="kdenlive:mixcut">12</property>
<property name="reverse">1</property>
<property name="softness">0</property>
<property name="alpha_over">1</property>
<property name="invert">0</property>
</transition>
</tractor>
<tractor id="tractor4" in="00:00:00.000" out="00:20:38.920">
<track producer="black_track"/>
<track producer="tractor0"/>
<track producer="tractor1"/>
<track producer="tractor2"/>
<track producer="tractor3"/>
<transition id="transition3">
<property name="a_track">0</property>
<property name="b_track">1</property>
<property name="mlt_service">mix</property>
<property name="kdenlive_id">mix</property>
<property name="internal_added">237</property>
<property name="always_active">1</property>
<property name="accepts_blanks">1</property>
<property name="sum">1</property>
</transition>
<transition id="transition4">
<property name="a_track">0</property>
<property name="b_track">2</property>
<property name="mlt_service">mix</property>
<property name="kdenlive_id">mix</property>
<property name="internal_added">237</property>
<property name="always_active">1</property>
<property name="accepts_blanks">1</property>
<property name="sum">1</property>
</transition>
<transition id="transition5">
<property name="a_track">0</property>
<property name="b_track">3</property>
<property name="version">0.1</property>
<property name="mlt_service">frei0r.cairoblend</property>
<property name="always_active">1</property>
<property name="internal_added">237</property>
</transition>
<transition id="transition6">
<property name="a_track">0</property>
<property name="b_track">4</property>
<property name="version">0.1</property>
<property name="mlt_service">frei0r.cairoblend</property>
<property name="always_active">1</property>
<property name="internal_added">237</property>
</transition>
<filter id="filter6">
<property name="window">75</property>
<property name="max_gain">20dB</property>
<property name="mlt_service">volume</property>
<property name="internal_added">237</property>
<property name="disable">1</property>
</filter>
<filter id="filter7">
<property name="channel">-1</property>
<property name="mlt_service">panner</property>
<property name="internal_added">237</property>
<property name="start">0.5</property>
<property name="disable">1</property>
</filter>
<filter id="filter9">
<property name="mlt_service">avfilter.fieldorder</property>
<property name="internal_added">237</property>
<property name="av.order">tff</property>
</filter>
<filter id="filter8">
<property name="iec_scale">0</property>
<property name="mlt_service">audiolevel</property>
<property name="peak">1</property>
<property name="disable">1</property>
</filter>
</tractor>
</mlt>
......@@ -431,3 +431,60 @@ TEST_CASE("Non-BMP Unicode", "[NONBMP]")
binModel->clean();
pCore->m_projectManager = nullptr;
}
TEST_CASE("Opening Mix", "[OPENMIX]")
{
auto binModel = pCore->projectItemModel();
binModel->clean();
// Check that mixes (and reverse mixes) load correctly
const QString emojiTestString = QString::fromUtf8("test\xF0\x9F\x8D\x99test");
std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);
std::shared_ptr<MarkerListModel> guideModel = std::make_shared<MarkerListModel>(undoStack);
SECTION("Load file with a mix")
{
// We mock the project class so that the undoStack function returns our undoStack, and our mocked document
Mock<ProjectManager> pmMock;
When(Method(pmMock, undoStack)).AlwaysReturn(undoStack);
When(Method(pmMock, cacheDir)).AlwaysReturn(QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)));
ProjectManager &mocked = pmMock.get();
// We also mock timeline object to spy few functions and mock others
// try opening the file as a Kdenlivedoc
QUrl openURL = QUrl::fromLocalFile(sourcesPath + "/dataset/test-mix.kdenlive");
QUndoGroup *undoGroup = new QUndoGroup();
undoGroup->addStack(undoStack.get());
DocOpenResult openResults = KdenliveDoc::Open(openURL, QDir::temp().path(), undoGroup, false, nullptr);
REQUIRE(openResults.isSuccessful() == true);
std::unique_ptr<KdenliveDoc> openedDoc = openResults.getDocument();
When(Method(pmMock, current)).AlwaysReturn(openedDoc.get());
/*TimelineItemModel tim(&profile_file, undoStack);
Mock<TimelineItemModel> timMock(tim);
auto timeline = std::shared_ptr<TimelineItemModel>(&timMock.get(), [](...) {});
TimelineItemModel::finishConstruct(timeline, guideModel);
mocked.testSetActiveDocument(openedDoc.get(), timeline);*/
pCore->m_projectManager = &mocked;
pCore->m_projectManager->m_project = openedDoc.get();
pCore->m_projectManager->m_project->m_guideModel = guideModel;
QDateTime documentDate = QFileInfo(openURL.toLocalFile()).lastModified();
pCore->m_projectManager->updateTimeline(0, QString(), QString(), documentDate, 0);
std::shared_ptr<TimelineItemModel> timeline = pCore->m_projectManager->getTimeline();
REQUIRE(timeline->getTracksCount() == 4);
int mixtrackId = timeline->getTrackIndexFromPosition(2);
REQUIRE(timeline->getTrackById_const(mixtrackId)->mixCount() == 2);
int mixtrackId2 = timeline->getTrackIndexFromPosition(3);
REQUIRE(timeline->getTrackById_const(mixtrackId2)->mixCount() == 1);
QDomDocument *newDoc = &openedDoc->m_document;
auto producers = newDoc->elementsByTagName(QStringLiteral("producer"));
}
binModel->clean();
pCore->m_projectManager = nullptr;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment