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

Add test for recent audio breaking regression

parent 76e4b839
Pipeline #191823 passed with stage
in 6 minutes and 27 seconds
......@@ -174,8 +174,8 @@ public slots:
void activateAsset(const QVariantMap &effectData);
/** @brief insert current timeline timecode in notes widget and focus widget to allow entering quick note */
void slotAddProjectNote();
/** @brief insert license text in notes widget and focus widget to allow entering quick note */
void slotAddTextNote(const QString &text);
/** @brief insert license text in notes widget and focus widget to allow entering quick note. Virtual to allow Mocking */
virtual void slotAddTextNote(const QString &text);
private slots:
void slotRevert();
......
......@@ -267,18 +267,21 @@ bool constructTimelineFromMelt(const std::shared_ptr<TimelineItemModel> &timelin
undo();
return false;
}
if (!m_notesLog.isEmpty()) {
m_notesLog.prepend(i18n("Errors found when opening project file (%1)", QDateTime::currentDateTime().toString()));
pCore->projectManager()->slotAddTextNote(m_notesLog.join("<br/>"));
if (projectErrors) {
*projectErrors = true;
if (!qEnvironmentVariableIsSet("MLT_TESTS")) {
if (!m_notesLog.isEmpty()) {
m_notesLog.prepend(i18n("Errors found when opening project file (%1)", QDateTime::currentDateTime().toString()));
pCore->projectManager()->slotAddTextNote(m_notesLog.join("<br/>"));
if (projectErrors) {
*projectErrors = true;
}
KMessageBox::detailedSorry(
qApp->activeWindow(),
i18n("Some errors were detected in the project file.\nThe project was modified to fix the conflicts. Changes made to the "
"project have been listed in the Project Notes tab,\nplease review them to ensure your project integrity."),
m_errorMessage.join("\n"), i18n("Problems found in your project file"));
} else if (!m_errorMessage.isEmpty()) {
KMessageBox::sorry(qApp->activeWindow(), m_errorMessage.join("\n"), i18n("Problems found in your project file"));
}
KMessageBox::detailedSorry(qApp->activeWindow(),
i18n("Some errors were detected in the project file.\nThe project was modified to fix the conflicts. Changes made to the "
"project have been listed in the Project Notes tab,\nplease review them to ensure your project integrity."),
m_errorMessage.join("\n"), i18n("Problems found in your project file"));
} else if (!m_errorMessage.isEmpty()) {
KMessageBox::sorry(qApp->activeWindow(), m_errorMessage.join("\n"), i18n("Problems found in your project file"));
}
return true;
}
......
<?xml version='1.0' encoding='utf-8'?>
<mlt LC_NUMERIC="C" producer="main_bin" version="7.7.0" root="/home/six/git/kdenlive/tests/dataset">
<profile frame_rate_num="25" sample_aspect_num="1" display_aspect_den="9" colorspace="709" progressive="1" description="HD 1080p 25 fps" display_aspect_num="16" frame_rate_den="1" width="1920" height="1080" sample_aspect_den="1"/>
<producer id="producer0" in="00:00:00.000" out="00:00:20.000">
<property name="length">15000</property>
<property name="eof">pause</property>
<property name="resource">&lt;producer&gt;</property>
<property name="aspect_ratio">1.06667</property>
<property name="period">1</property>
<property name="offset">0</property>
<property name="mlt_service">blipflash</property>
<property name="kdenlive:clip_type">0</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:id">2</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.disablepreview">0</property>
<property name="kdenlive:docproperties.documentid">1655361074367</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"/>
<property name="kdenlive:docproperties.generateimageproxy">0</property>
<property name="kdenlive:docproperties.generateproxy">0</property>
<property name="kdenlive:docproperties.kdenliveversion">22.07.70</property>
<property name="kdenlive:docproperties.position">0</property>
<property name="kdenlive:docproperties.previewextension"/>
<property name="kdenlive:docproperties.previewparameters"/>
<property name="kdenlive:docproperties.profile">atsc_1080p_25</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">8</property>
<property name="kdenlive:expandedFolders"/>
<property name="kdenlive:documentnotes"/>
<property name="kdenlive:docproperties.groups">[
{
"children": [
{
"data": "2:0",
"leaf": "clip",
"type": "Leaf"
},
{
"data": "1:0",
"leaf": "clip",
"type": "Leaf"
}
],
"type": "AVSplit"
}
]
</property>
<property name="xml_retain">1</property>
<entry producer="producer0" in="00:00:00.000" out="00:00:19.960"/>
</playlist>
<producer id="black_track" in="00:00:00.000" out="00:24:00.280">
<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>
<producer id="producer1" in="00:00:00.000" out="00:00:20.000">
<property name="length">15000</property>
<property name="eof">pause</property>
<property name="resource">&lt;producer&gt;</property>
<property name="aspect_ratio">1.06667</property>
<property name="period">1</property>
<property name="offset">0</property>
<property name="mlt_service">blipflash</property>
<property name="kdenlive:clip_type">0</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:id">2</property>
<property name="xml">was here</property>
<property name="set.test_audio">0</property>
<property name="set.test_image">1</property>
</producer>
<playlist id="playlist2">
<property name="kdenlive:audio_track">1</property>
<entry producer="producer1" in="00:00:00.000" out="00:00:19.960">
<property name="kdenlive:id">2</property>
</entry>
</playlist>
<playlist id="playlist3">
<property name="kdenlive:audio_track">1</property>
</playlist>
<tractor id="tractor1" in="00:00:00.000" out="00:00:19.960">
<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>
<producer id="producer2" in="00:00:00.000" out="00:00:20.000">
<property name="length">15000</property>
<property name="eof">pause</property>
<property name="resource">&lt;producer&gt;</property>
<property name="aspect_ratio">1.06667</property>
<property name="period">1</property>
<property name="offset">0</property>
<property name="mlt_service">blipflash</property>
<property name="kdenlive:clip_type">0</property>
<property name="kdenlive:folderid">-1</property>
<property name="kdenlive:id">2</property>
<property name="xml">was here</property>
<property name="set.test_audio">1</property>
<property name="set.test_image">0</property>
</producer>
<playlist id="playlist4">
<entry producer="producer2" in="00:00:00.000" out="00:00:19.960">
<property name="kdenlive:id">2</property>
</entry>
</playlist>
<playlist id="playlist5"/>
<tractor id="tractor2" in="00:00:00.000" out="00:00:19.960">
<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"/>
</tractor>
<playlist id="playlist6"/>
<playlist id="playlist7"/>
<tractor id="tractor3" in="00:00:00.000">
<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"/>
</tractor>
<tractor id="tractor4" in="00:00:00.000" out="00:00:19.960">
<track producer="black_track"/>
<track producer="tractor0"/>
<track producer="tractor1"/>
<track producer="tractor2"/>
<track producer="tractor3"/>
<transition id="transition0">
<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="transition1">
<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="transition2">
<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="kdenlive_id">frei0r.cairoblend</property>
<property name="internal_added">237</property>
<property name="always_active">1</property>
</transition>
<transition id="transition3">
<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="kdenlive_id">frei0r.cairoblend</property>
<property name="internal_added">237</property>
<property name="always_active">1</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="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>
......@@ -25,11 +25,11 @@ TEST_CASE("Save File", "[SF]")
{
// Create document
Mock<KdenliveDoc> docMock;
/*When(Method(docMock, getDocumentProperty)).AlwaysDo([](const QString &name, const QString &defaultValue) {
Q_UNUSED(name) Q_UNUSED(defaultValue)
qDebug() << "Intercepted call";
return QStringLiteral("dummyId");
});*/
// When(Method(docMock, getDocumentProperty)).AlwaysDo([](const QString &name, const QString &defaultValue) {
// Q_UNUSED(name) Q_UNUSED(defaultValue)
// qDebug() << "Intercepted call";
// return QStringLiteral("dummyId");
// });
KdenliveDoc &mockedDoc = docMock.get();
// We mock the project class so that the undoStack function returns our undoStack, and our mocked document
......@@ -64,10 +64,10 @@ TEST_CASE("Save File", "[SF]")
QString binId = createProducerWithSound(profile_file, binModel);
QString binId2 = createProducer(profile_file, "red", binModel, 20, false);
/*int tid2b =*/TrackModel::construct(timeline, -1, -1, QString(), true);
/*int tid2 =*/TrackModel::construct(timeline, -1, -1, QString(), true);
TrackModel::construct(timeline, -1, -1, QString(), true);
TrackModel::construct(timeline, -1, -1, QString(), true);
int tid1 = TrackModel::construct(timeline);
/*int tid1b =*/TrackModel::construct(timeline);
TrackModel::construct(timeline);
// Setup timeline audio drop info
QMap<int, QString> audioInfo;
......@@ -168,5 +168,71 @@ TEST_CASE("Save File", "[SF]")
QFile::remove(dir.absoluteFilePath(QStringLiteral("test.kdenlive")));
}
binModel->clean();
SECTION("Open a file with AV clips")
{
// Create new document
Mock<KdenliveDoc> docMock;
KdenliveDoc &mockedDoc = docMock.get();
// 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)));
When(Method(pmMock, current)).AlwaysReturn(&mockedDoc);
When(Method(pmMock, slotAddTextNote)).AlwaysDo([](const QString &text) {
Q_UNUSED(text)
qDebug() << "Intercepted Add Notes call";
return;
});
ProjectManager &mocked = pmMock.get();
pCore->m_projectManager = &mocked;
pCore->m_projectManager->m_project = &mockedDoc;
pCore->m_projectManager->m_project->m_guideModel = guideModel;
// We also mock timeline object to spy few functions and mock others
TimelineItemModel tim(&profile_file, undoStack);
Mock<TimelineItemModel> timMock(tim);
auto timeline = std::shared_ptr<TimelineItemModel>(&timMock.get(), [](...) {});
TimelineItemModel::finishConstruct(timeline, guideModel);
mocked.testSetActiveDocument(&mockedDoc, timeline);
QDir dir = QDir::temp();
RESET(timMock)
// This file contains an AV clip on tracks A1/V1 at 0, duration 500 frames
QString path = sourcesPath + "/dataset/av.kdenlive";
QFile file(path);
REQUIRE(file.open(QIODevice::ReadOnly | QIODevice::Text) == true);
QByteArray playlist = file.readAll();
file.close();
QScopedPointer<Mlt::Producer> xmlProd(new Mlt::Producer(profile_file, "xml-string", playlist));
QDomDocument doc;
doc.setContent(playlist);
Mlt::Service s(*xmlProd);
Mlt::Tractor tractor(s);
bool projectErrors;
constructTimelineFromMelt(timeline, tractor, nullptr, QString(), QString(), QString(), 0, &projectErrors);
REQUIRE(timeline->checkConsistency());
int tid1 = timeline->getTrackIndexFromPosition(0);
int tid2 = timeline->getTrackIndexFromPosition(1);
int tid3 = timeline->getTrackIndexFromPosition(2);
int tid4 = timeline->getTrackIndexFromPosition(3);
// Check we have audio and video tracks
REQUIRE(timeline->isAudioTrack(tid1));
REQUIRE(timeline->isAudioTrack(tid2));
REQUIRE(timeline->isAudioTrack(tid3) == false);
REQUIRE(timeline->isAudioTrack(tid4) == false);
int cid1 = timeline->getClipByStartPosition(tid1, 0);
int cid2 = timeline->getClipByStartPosition(tid2, 0);
int cid3 = timeline->getClipByStartPosition(tid3, 0);
int cid4 = timeline->getClipByStartPosition(tid4, 0);
// Check we have our clips
REQUIRE(cid1 == -1);
REQUIRE(cid2 > -1);
REQUIRE(cid3 > -1);
REQUIRE(cid4 == -1);
REQUIRE(timeline->getClipPlaytime(cid2) == 500);
REQUIRE(timeline->getClipPlaytime(cid3) == 500);
}
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