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

Add test loading broken subtitle file

parent 26212c71
Pipeline #217098 passed with stage
in 8 minutes and 21 seconds
......@@ -1350,8 +1350,14 @@ const QString ProjectClip::getFileHash()
break;
}
if (fileHash.isEmpty()) {
qDebug() << "// WARNING EMPTY CLIP HASH: ";
return QString();
if (m_service == QLatin1String("blipflash")) {
// Used in tests
fileData = getProducerProperty(QStringLiteral("resource")).toUtf8();
fileHash = QCryptographicHash::hash(fileData, QCryptographicHash::Md5);
} else {
qDebug() << "// WARNING EMPTY CLIP HASH: ";
return QString();
}
}
QString result = fileHash.toHex();
ClipController::setProducerProperty(QStringLiteral("kdenlive:file_hash"), result);
......
1
00:00:05,600 --> 00:00:10,600
J'hésite à vérifier
2
00:00:20,120 -->
Ce test de sous-titres
3
00:00:25,120 --> 00:00:35,000
!! Quand même !!
4
--> 00:00:35,000
Bravo
......@@ -75,6 +75,8 @@ TEST_CASE("Read subtitle file", "[Subtitles]")
REQUIRE(subtitlesText == control);
// Ensure timeing is correct
REQUIRE(sTime == controleTime);
subtitleModel->removeAllSubtitles();
REQUIRE(subtitleModel->rowCount() == 0);
}
SECTION("Load a non-UTF-8 subtitle")
......@@ -94,6 +96,32 @@ TEST_CASE("Read subtitle file", "[Subtitles]")
// Ensure that non-ASCII characters are read correctly
CHECK(subtitlesText == control);
}
SECTION("Load a broken subtitle file")
{
QString subtitleFile = sourcesPath + "/dataset/02.srt";
subtitleModel->importSubtitle(subtitleFile);
// Ensure the 2 dialogues are loaded
REQUIRE(subtitleModel->rowCount() == 2);
QList<SubtitledTime> allSubs = subtitleModel->getAllSubtitles();
QList<GenTime> sTime;
QList<GenTime> controleTime;
controleTime << GenTime(140, 25) << GenTime(265, 25) << GenTime(628, 25) << GenTime(875, 25);
QStringList subtitlesText;
QStringList control = {QStringLiteral("J'hésite à vérifier"), QStringLiteral("!! Quand même !!")};
for (const auto &s : allSubs) {
subtitlesText << s.subtitle();
sTime << s.start();
sTime << s.end();
}
// Ensure the texts are read correctly
REQUIRE(subtitlesText == control);
// Ensure timeing is correct
REQUIRE(sTime == controleTime);
subtitleModel->removeAllSubtitles();
REQUIRE(subtitleModel->rowCount() == 0);
}
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