mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
SSA: Add a test with a present but empty "Style" line
PiperOrigin-RevId: 370897451
This commit is contained in:
parent
2b120f478d
commit
f56c1a1253
2 changed files with 35 additions and 1 deletions
|
|
@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
|
||||||
public final class SsaDecoderTest {
|
public final class SsaDecoderTest {
|
||||||
|
|
||||||
private static final String EMPTY = "media/ssa/empty";
|
private static final String EMPTY = "media/ssa/empty";
|
||||||
|
private static final String EMPTY_STYLE_LINE = "media/ssa/empty_style_line";
|
||||||
private static final String TYPICAL = "media/ssa/typical";
|
private static final String TYPICAL = "media/ssa/typical";
|
||||||
private static final String TYPICAL_HEADER_ONLY = "media/ssa/typical_header";
|
private static final String TYPICAL_HEADER_ONLY = "media/ssa/typical_header";
|
||||||
private static final String TYPICAL_DIALOGUE_ONLY = "media/ssa/typical_dialogue";
|
private static final String TYPICAL_DIALOGUE_ONLY = "media/ssa/typical_dialogue";
|
||||||
|
|
@ -60,7 +61,27 @@ public final class SsaDecoderTest {
|
||||||
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
|
Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
|
||||||
|
|
||||||
assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
|
assertThat(subtitle.getEventTimeCount()).isEqualTo(0);
|
||||||
assertThat(subtitle.getCues(0).isEmpty()).isTrue();
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void decodeEmptyStyleLine() throws IOException {
|
||||||
|
SsaDecoder decoder = new SsaDecoder();
|
||||||
|
byte[] bytes =
|
||||||
|
TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_STYLE_LINE);
|
||||||
|
Subtitle subtitle = decoder.decode(bytes, bytes.length, /* reset= */ false);
|
||||||
|
|
||||||
|
assertThat(subtitle.getEventTimeCount()).isEqualTo(2);
|
||||||
|
Cue cue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
|
||||||
|
SpannedSubject.assertThat((Spanned) cue.text).hasNoSpans();
|
||||||
|
assertThat(cue.textSize).isEqualTo(Cue.DIMEN_UNSET);
|
||||||
|
assertThat(cue.textSizeType).isEqualTo(Cue.TYPE_UNSET);
|
||||||
|
assertThat(cue.textAlignment).isNull();
|
||||||
|
assertThat(cue.positionAnchor).isEqualTo(Cue.TYPE_UNSET);
|
||||||
|
assertThat(cue.position).isEqualTo(Cue.DIMEN_UNSET);
|
||||||
|
assertThat(cue.size).isEqualTo(Cue.DIMEN_UNSET);
|
||||||
|
assertThat(cue.lineAnchor).isEqualTo(Cue.TYPE_UNSET);
|
||||||
|
assertThat(cue.line).isEqualTo(Cue.DIMEN_UNSET);
|
||||||
|
assertThat(cue.lineType).isEqualTo(Cue.LINE_TYPE_FRACTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
13
testdata/src/test/assets/media/ssa/empty_style_line
vendored
Normal file
13
testdata/src/test/assets/media/ssa/empty_style_line
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[Script Info]
|
||||||
|
Title: SSA/ASS Test
|
||||||
|
Script Type: V4.00+
|
||||||
|
PlayResX: 1280
|
||||||
|
PlayResY: 720
|
||||||
|
|
||||||
|
[V4+ Styles]
|
||||||
|
Format: Name
|
||||||
|
Style: Empty
|
||||||
|
|
||||||
|
[Events]
|
||||||
|
Format: Start ,End ,Style,Text
|
||||||
|
Dialogue: 0:00:01.00,0:00:03.00,Empty,First line.
|
||||||
Loading…
Reference in a new issue