mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix SRT test
This commit is contained in:
parent
1b1769bb6d
commit
87dfaff74b
1 changed files with 14 additions and 18 deletions
|
|
@ -15,10 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer.text.subrip;
|
package com.google.android.exoplayer.text.subrip;
|
||||||
|
|
||||||
import android.test.InstrumentationTestCase;
|
|
||||||
|
|
||||||
import com.google.android.exoplayer.C;
|
import com.google.android.exoplayer.C;
|
||||||
|
|
||||||
|
import android.test.InstrumentationTestCase;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
|
@ -34,13 +34,10 @@ public class SubripParserTest extends InstrumentationTestCase {
|
||||||
SubripParser parser = new SubripParser();
|
SubripParser parser = new SubripParser();
|
||||||
InputStream inputStream =
|
InputStream inputStream =
|
||||||
getInstrumentation().getContext().getResources().getAssets().open(EMPTY_SUBRIP_FILE);
|
getInstrumentation().getContext().getResources().getAssets().open(EMPTY_SUBRIP_FILE);
|
||||||
|
SubripSubtitle subtitle = parser.parse(inputStream, C.UTF8_NAME, 0);
|
||||||
try {
|
// Assert that the subtitle is empty.
|
||||||
parser.parse(inputStream, C.UTF8_NAME, 0);
|
assertEquals(0, subtitle.getEventTimeCount());
|
||||||
fail("Expected IOException");
|
assertTrue(subtitle.getCues(0).isEmpty());
|
||||||
} catch (IOException expected) {
|
|
||||||
// Do nothing.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseTypicalSubripFile() throws IOException {
|
public void testParseTypicalSubripFile() throws IOException {
|
||||||
|
|
@ -49,22 +46,21 @@ public class SubripParserTest extends InstrumentationTestCase {
|
||||||
getInstrumentation().getContext().getResources().getAssets().open(TYPICAL_SUBRIP_FILE);
|
getInstrumentation().getContext().getResources().getAssets().open(TYPICAL_SUBRIP_FILE);
|
||||||
SubripSubtitle subtitle = parser.parse(inputStream, C.UTF8_NAME, 0);
|
SubripSubtitle subtitle = parser.parse(inputStream, C.UTF8_NAME, 0);
|
||||||
|
|
||||||
// test start time and event count
|
// Test start time and event count.
|
||||||
long startTimeUs = 0;
|
assertEquals(0, subtitle.getStartTime());
|
||||||
assertEquals(startTimeUs, subtitle.getStartTime());
|
|
||||||
assertEquals(4, subtitle.getEventTimeCount());
|
assertEquals(4, subtitle.getEventTimeCount());
|
||||||
|
|
||||||
// test first cue
|
// Test first cue.
|
||||||
assertEquals(startTimeUs, subtitle.getEventTime(0));
|
assertEquals(0, subtitle.getEventTime(0));
|
||||||
assertEquals("This is the first subtitle.",
|
assertEquals("This is the first subtitle.",
|
||||||
subtitle.getCues(subtitle.getEventTime(0)).get(0).text.toString());
|
subtitle.getCues(subtitle.getEventTime(0)).get(0).text.toString());
|
||||||
assertEquals(startTimeUs + 1234000, subtitle.getEventTime(1));
|
assertEquals(1234000, subtitle.getEventTime(1));
|
||||||
|
|
||||||
// test second cue
|
// Test second cue.
|
||||||
assertEquals(startTimeUs + 2345000, subtitle.getEventTime(2));
|
assertEquals(2345000, subtitle.getEventTime(2));
|
||||||
assertEquals("This is the second subtitle.\nSecond subtitle with second line.",
|
assertEquals("This is the second subtitle.\nSecond subtitle with second line.",
|
||||||
subtitle.getCues(subtitle.getEventTime(2)).get(0).text.toString());
|
subtitle.getCues(subtitle.getEventTime(2)).get(0).text.toString());
|
||||||
assertEquals(startTimeUs + 3456000, subtitle.getEventTime(3));
|
assertEquals(3456000, subtitle.getEventTime(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue