Commit 87dfaff7 by Oliver Woodman

Fix SRT test

parent 1b1769bb
...@@ -15,10 +15,10 @@ ...@@ -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 { ...@@ -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 { ...@@ -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));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment