Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
74ef83e0
Commit
74ef83e0
authored
Aug 12, 2022
by
Jean-Baptiste Mardelle
Browse files
Add test loading broken subtitle file
parent
26212c71
Pipeline
#217098
passed with stage
in 8 minutes and 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/projectclip.cpp
View file @
74ef83e0
...
...
@@ -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
);
...
...
tests/dataset/02.srt
0 → 100644
View file @
74ef83e0
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
tests/subtitlestest.cpp
View file @
74ef83e0
...
...
@@ -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
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment