Commit fa73c4a5 authored by Eric Jiang's avatar Eric Jiang
Browse files

Test ASS/SSA files containing commas

Unit test with sample file containing commas in subtitle dialogue.

BUG: 461486
parent 07744f3a
Pipeline #265194 passed with stage
in 5 minutes and 12 seconds
[Script Info]
Title: Test parsing of lines with commas
ScaledBorderAndShadow: yes
ScriptType: v4.00+
Collisions: Normal
PlayResX: 640
PlayResY: 360
Timer: 0.0000
WrapStyle: 0
[V4+ Styles]
Format: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,Strikeout,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding
Style: Default,Trebuchet MS,24,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,0010,0010,0018,0
[Events]
Format: Layer,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text
Dialogue: 0,0:00:00.58,0:00:02.98,Default,Alice,0000,0000,0000,,Line with one comma, second part.
Dialogue: 0,0:00:04.33,0:00:09.10,Default,Bob,0000,0000,0000,,Line with two commas, second part, third part.
......@@ -105,6 +105,26 @@ TEST_CASE("Read subtitle file", "[Subtitles]")
}
#endif
SECTION("Load ASS file with commas")
{
QString subtitleFile = sourcesPath + "/dataset/subs-with-commas.ass";
QByteArray guessedEncoding = SubtitleModel::guessFileEncoding(subtitleFile);
qDebug() << "Guessed encoding: " << guessedEncoding;
subtitleModel->importSubtitle(subtitleFile, 0, false, 30.00, 30.00, guessedEncoding);
// Ensure all 2 lines are loaded
REQUIRE(subtitleModel->rowCount() == 2);
QList<SubtitledTime> allSubs = subtitleModel->getAllSubtitles();
QStringList subtitlesText;
QStringList control = {
QStringLiteral("Line with one comma, second part."),
QStringLiteral("Line with two commas, second part, third part.")};
for (const auto &s : qAsConst(allSubs)) {
subtitlesText << s.subtitle();
}
// Ensure that non-ASCII characters are read correctly
CHECK(subtitlesText == control);
}
SECTION("Load a broken subtitle file")
{
QString subtitleFile = sourcesPath + "/dataset/02.srt";
......
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