SSA: Add a test with a present but empty "Style" line

PiperOrigin-RevId: 370897451
This commit is contained in:
ibaker 2021-04-28 15:20:48 +01:00 committed by bachinger
parent 2b120f478d
commit f56c1a1253
2 changed files with 35 additions and 1 deletions

View File

@ -38,6 +38,7 @@ import org.junit.runner.RunWith;
public final class SsaDecoderTest {
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_HEADER_ONLY = "media/ssa/typical_header";
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);
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

View 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.