diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoder.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoder.java
index ebbb156af7..d812bd11e5 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoder.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoder.java
@@ -15,7 +15,10 @@
*/
package androidx.media3.exoplayer.text;
+import static androidx.annotation.VisibleForTesting.PACKAGE_PRIVATE;
+
import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
import androidx.media3.extractor.text.CuesWithTiming;
import androidx.media3.extractor.text.SimpleSubtitleDecoder;
import androidx.media3.extractor.text.Subtitle;
@@ -43,17 +46,19 @@ import java.util.List;
*
XXXDecoder(initializationData)
*
- *
- * TODO(b/289983417): this will only be used in the old decoding flow (Decoder after SampleQueue)
- * while we maintain dual architecture. Once we fully migrate to the pre-SampleQueue flow, it can be
- * deprecated and later deleted.
*/
-/* package */ final class DelegatingSubtitleDecoder extends SimpleSubtitleDecoder {
+// TODO(b/289983417): this will only be used in the old decoding flow (Decoder after SampleQueue)
+// while we maintain dual architecture. Once we fully migrate to the pre-SampleQueue flow, it can be
+// deprecated and later deleted.
+// TODO: remove VisibleForTesting annotation once SubtitleExtractor uses SubtitleParser (rather than
+// SubtitleDecoder) and SubtitleExtractorTest is refactored
+@VisibleForTesting(otherwise = PACKAGE_PRIVATE)
+public final class DelegatingSubtitleDecoder extends SimpleSubtitleDecoder {
private static final Subtitle EMPTY_SUBTITLE = new CuesWithTimingSubtitle(ImmutableList.of());
private final SubtitleParser subtitleParser;
- /* package */ DelegatingSubtitleDecoder(String name, SubtitleParser subtitleParser) {
+ public DelegatingSubtitleDecoder(String name, SubtitleParser subtitleParser) {
super(name);
this.subtitleParser = subtitleParser;
}
@@ -63,7 +68,8 @@ import java.util.List;
if (reset) {
subtitleParser.reset();
}
- @Nullable List cuesWithTiming = subtitleParser.parse(data);
+ @Nullable
+ List cuesWithTiming = subtitleParser.parse(data, /* offset= */ 0, length);
if (cuesWithTiming == null) {
return EMPTY_SUBTITLE;
}
diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/SubtitleDecoderFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/SubtitleDecoderFactory.java
index 815e525eb7..de4450643e 100644
--- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/SubtitleDecoderFactory.java
+++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/text/SubtitleDecoderFactory.java
@@ -25,7 +25,6 @@ import androidx.media3.extractor.text.SubtitleParser;
import androidx.media3.extractor.text.cea.Cea608Decoder;
import androidx.media3.extractor.text.cea.Cea708Decoder;
import androidx.media3.extractor.text.ttml.TtmlDecoder;
-import androidx.media3.extractor.text.webvtt.WebvttDecoder;
import java.util.Objects;
/** A factory for {@link SubtitleDecoder} instances. */
@@ -56,7 +55,6 @@ public interface SubtitleDecoderFactory {
* Supports formats supported by {@link DefaultSubtitleParserFactory} as well as the following:
*
*
- * - WebVTT ({@link WebvttDecoder})
*
- TTML ({@link TtmlDecoder})
*
- Cea608 ({@link Cea608Decoder})
*
- Cea708 ({@link Cea708Decoder})
@@ -72,7 +70,6 @@ public interface SubtitleDecoderFactory {
public boolean supportsFormat(Format format) {
@Nullable String mimeType = format.sampleMimeType;
return delegate.supportsFormat(format)
- || Objects.equals(mimeType, MimeTypes.TEXT_VTT)
|| Objects.equals(mimeType, MimeTypes.APPLICATION_TTML)
|| Objects.equals(mimeType, MimeTypes.APPLICATION_CEA608)
|| Objects.equals(mimeType, MimeTypes.APPLICATION_MP4CEA608)
@@ -90,8 +87,6 @@ public interface SubtitleDecoderFactory {
@Nullable String mimeType = format.sampleMimeType;
if (mimeType != null) {
switch (mimeType) {
- case MimeTypes.TEXT_VTT:
- return new WebvttDecoder();
case MimeTypes.APPLICATION_TTML:
return new TtmlDecoder();
case MimeTypes.APPLICATION_CEA608:
diff --git a/libraries/extractor/src/test/java/androidx/media3/extractor/text/webvtt/WebvttDecoderTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoderWithWebvttParserTest.java
similarity index 92%
rename from libraries/extractor/src/test/java/androidx/media3/extractor/text/webvtt/WebvttDecoderTest.java
rename to libraries/exoplayer/src/test/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoderWithWebvttParserTest.java
index e2788b4814..d0127044fa 100644
--- a/libraries/extractor/src/test/java/androidx/media3/extractor/text/webvtt/WebvttDecoderTest.java
+++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/text/DelegatingSubtitleDecoderWithWebvttParserTest.java
@@ -1,11 +1,11 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.media3.extractor.text.webvtt;
+package androidx.media3.exoplayer.text;
import static androidx.media3.test.utils.truth.SpannedSubject.assertThat;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import android.text.Layout.Alignment;
import android.text.Spanned;
@@ -25,7 +25,8 @@ import androidx.media3.common.text.Cue;
import androidx.media3.common.text.TextAnnotation;
import androidx.media3.common.util.Assertions;
import androidx.media3.common.util.ColorParser;
-import androidx.media3.extractor.text.SubtitleDecoderException;
+import androidx.media3.extractor.text.Subtitle;
+import androidx.media3.extractor.text.webvtt.WebvttParser;
import androidx.media3.test.utils.TestUtil;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -37,10 +38,9 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-/** Unit test for {@link WebvttDecoder}. */
+/** Unit test for a {@link DelegatingSubtitleDecoder} backed by {@link WebvttParser}. */
@RunWith(AndroidJUnit4.class)
-public class WebvttDecoderTest {
-
+public final class DelegatingSubtitleDecoderWithWebvttParserTest {
private static final String TYPICAL_FILE = "media/webvtt/typical";
private static final String TYPICAL_WITH_BAD_TIMESTAMPS =
"media/webvtt/typical_with_bad_timestamps";
@@ -61,32 +61,27 @@ public class WebvttDecoderTest {
"media/webvtt/with_css_text_combine_upright";
private static final String WITH_BOM = "media/webvtt/with_bom";
private static final String EMPTY_FILE = "media/webvtt/empty";
-
@Rule public final Expect expect = Expect.create();
@Test
public void decodeEmpty() throws IOException {
- WebvttDecoder decoder = new WebvttDecoder();
+ DelegatingSubtitleDecoder decoder =
+ new DelegatingSubtitleDecoder(
+ "DelegatingSubtitleDecoderWithWebvttParser", new WebvttParser());
byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), EMPTY_FILE);
- try {
- decoder.decode(bytes, bytes.length, /* reset= */ false);
- fail();
- } catch (SubtitleDecoderException expected) {
- // Do nothing.
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> decoder.decode(bytes, bytes.length, /* reset= */ false));
}
@Test
public void decodeTypical() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(TYPICAL_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(TYPICAL_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -95,15 +90,12 @@ public class WebvttDecoderTest {
@Test
public void decodeWithBom() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_BOM);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_BOM);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -112,15 +104,12 @@ public class WebvttDecoderTest {
@Test
public void decodeTypicalWithBadTimestamps() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_BAD_TIMESTAMPS);
-
+ Subtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_BAD_TIMESTAMPS);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -129,15 +118,12 @@ public class WebvttDecoderTest {
@Test
public void decodeTypicalWithIds() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_IDS_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_IDS_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -146,15 +132,12 @@ public class WebvttDecoderTest {
@Test
public void decodeTypicalWithComments() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_COMMENTS_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(TYPICAL_WITH_COMMENTS_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(4);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(0 + 1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(2 + 1)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -163,25 +146,20 @@ public class WebvttDecoderTest {
@Test
public void decodeWithTags() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_TAGS_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_TAGS_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(8);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("This is the first subtitle.");
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
assertThat(secondCue.text.toString()).isEqualTo("This is the second subtitle.");
-
assertThat(subtitle.getEventTime(4)).isEqualTo(4_000_000L);
assertThat(subtitle.getEventTime(5)).isEqualTo(5_000_000L);
Cue thirdCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(4)));
assertThat(thirdCue.text.toString()).isEqualTo("This is the third subtitle.");
-
assertThat(subtitle.getEventTime(6)).isEqualTo(6_000_000L);
assertThat(subtitle.getEventTime(7)).isEqualTo(7_000_000L);
Cue fourthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(6)));
@@ -190,10 +168,8 @@ public class WebvttDecoderTest {
@Test
public void decodeWithPositioning() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_POSITIONING_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(16);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
@@ -202,12 +178,10 @@ public class WebvttDecoderTest {
assertThat(firstCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_END);
assertThat(firstCue.textAlignment).isEqualTo(Alignment.ALIGN_NORMAL);
assertThat(firstCue.size).isEqualTo(0.35f);
-
// Unspecified values should use WebVTT defaults
assertThat(firstCue.line).isEqualTo(-1f);
assertThat(firstCue.lineType).isEqualTo(Cue.LINE_TYPE_NUMBER);
assertThat(firstCue.verticalType).isEqualTo(Cue.TYPE_UNSET);
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
@@ -215,7 +189,6 @@ public class WebvttDecoderTest {
// Position is invalid so defaults to 0.5
assertThat(secondCue.position).isEqualTo(0.5f);
assertThat(secondCue.textAlignment).isEqualTo(Alignment.ALIGN_OPPOSITE);
-
assertThat(subtitle.getEventTime(4)).isEqualTo(4_000_000L);
assertThat(subtitle.getEventTime(5)).isEqualTo(5_000_000L);
Cue thirdCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(4)));
@@ -226,7 +199,6 @@ public class WebvttDecoderTest {
assertThat(thirdCue.textAlignment).isEqualTo(Alignment.ALIGN_CENTER);
// Derived from `align:middle`:
assertThat(thirdCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_MIDDLE);
-
assertThat(subtitle.getEventTime(6)).isEqualTo(6_000_000L);
assertThat(subtitle.getEventTime(7)).isEqualTo(7_000_000L);
Cue fourthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(6)));
@@ -237,7 +209,6 @@ public class WebvttDecoderTest {
// Derived from `align:middle`:
assertThat(fourthCue.position).isEqualTo(0.5f);
assertThat(fourthCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_MIDDLE);
-
assertThat(subtitle.getEventTime(8)).isEqualTo(8_000_000L);
assertThat(subtitle.getEventTime(9)).isEqualTo(9_000_000L);
Cue fifthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(8)));
@@ -246,7 +217,6 @@ public class WebvttDecoderTest {
// Derived from `align:right`:
assertThat(fifthCue.position).isEqualTo(1.0f);
assertThat(fifthCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_END);
-
assertThat(subtitle.getEventTime(10)).isEqualTo(10_000_000L);
assertThat(subtitle.getEventTime(11)).isEqualTo(11_000_000L);
Cue sixthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(10)));
@@ -255,13 +225,11 @@ public class WebvttDecoderTest {
// Derived from `align:center`:
assertThat(sixthCue.position).isEqualTo(0.5f);
assertThat(sixthCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_MIDDLE);
-
assertThat(subtitle.getEventTime(12)).isEqualTo(12_000_000L);
assertThat(subtitle.getEventTime(13)).isEqualTo(13_000_000L);
Cue seventhCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(12)));
assertThat(seventhCue.text.toString()).isEqualTo("This is the seventh subtitle.");
assertThat(seventhCue.positionAnchor).isEqualTo(Cue.ANCHOR_TYPE_START);
-
assertThat(subtitle.getEventTime(14)).isEqualTo(14_000_000L);
assertThat(subtitle.getEventTime(15)).isEqualTo(15_000_000L);
Cue eighthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(14)));
@@ -271,15 +239,12 @@ public class WebvttDecoderTest {
@Test
public void decodeWithOverlappingTimestamps() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_OVERLAPPING_TIMESTAMPS_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_OVERLAPPING_TIMESTAMPS_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(8);
-
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("Displayed at the bottom for 3 seconds.");
assertThat(firstCue.line).isEqualTo(-1f);
assertThat(firstCue.lineType).isEqualTo(Cue.LINE_TYPE_NUMBER);
-
List firstAndSecondCue = subtitle.getCues(subtitle.getEventTime(1));
assertThat(firstAndSecondCue).hasSize(2);
assertThat(firstAndSecondCue.get(0).text.toString())
@@ -290,12 +255,10 @@ public class WebvttDecoderTest {
.isEqualTo("Appears directly above for 1 second.");
assertThat(firstAndSecondCue.get(1).line).isEqualTo(-2f);
assertThat(firstAndSecondCue.get(1).lineType).isEqualTo(Cue.LINE_TYPE_NUMBER);
-
Cue thirdCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(4)));
assertThat(thirdCue.text.toString()).isEqualTo("Displayed at the bottom for 2 seconds.");
assertThat(thirdCue.line).isEqualTo(-1f);
assertThat(thirdCue.lineType).isEqualTo(Cue.LINE_TYPE_NUMBER);
-
List thirdAndFourthCue = subtitle.getCues(subtitle.getEventTime(5));
assertThat(thirdAndFourthCue).hasSize(2);
assertThat(thirdAndFourthCue.get(0).text.toString())
@@ -306,7 +269,6 @@ public class WebvttDecoderTest {
.isEqualTo("Appears directly above the previous cue, then replaces it after 1 second.");
assertThat(thirdAndFourthCue.get(1).line).isEqualTo(-2f);
assertThat(thirdAndFourthCue.get(1).lineType).isEqualTo(Cue.LINE_TYPE_NUMBER);
-
Cue fourthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(6)));
assertThat(fourthCue.text.toString())
.isEqualTo("Appears directly above the previous cue, then replaces it after 1 second.");
@@ -316,22 +278,18 @@ public class WebvttDecoderTest {
@Test
public void decodeWithVertical() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_VERTICAL_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_VERTICAL_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(6);
-
assertThat(subtitle.getEventTime(0)).isEqualTo(0L);
assertThat(subtitle.getEventTime(1)).isEqualTo(1_234_000L);
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("Vertical right-to-left (e.g. Japanese)");
assertThat(firstCue.verticalType).isEqualTo(Cue.VERTICAL_TYPE_RL);
-
assertThat(subtitle.getEventTime(2)).isEqualTo(2_345_000L);
assertThat(subtitle.getEventTime(3)).isEqualTo(3_456_000L);
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
assertThat(secondCue.text.toString()).isEqualTo("Vertical left-to-right (e.g. Mongolian)");
assertThat(secondCue.verticalType).isEqualTo(Cue.VERTICAL_TYPE_LR);
-
assertThat(subtitle.getEventTime(4)).isEqualTo(4_000_000L);
assertThat(subtitle.getEventTime(5)).isEqualTo(5_000_000L);
Cue thirdCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(4)));
@@ -341,17 +299,14 @@ public class WebvttDecoderTest {
@Test
public void decodeWithRubies() throws Exception {
- WebvttSubtitle subtitle = getSubtitleForTestAsset(WITH_RUBIES_FILE);
-
+ Subtitle subtitle = getSubtitleForTestAsset(WITH_RUBIES_FILE);
assertThat(subtitle.getEventTimeCount()).isEqualTo(8);
-
// Check that an explicit `over` position is read from CSS.
Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
assertThat(firstCue.text.toString()).isEqualTo("Some text with over-ruby.");
assertThat((Spanned) firstCue.text)
.hasRubySpanBetween("Some ".length(), "Some text with over-ruby".length())
.withTextAndPosition("over", TextAnnotation.POSITION_BEFORE);
-
// Check that `under` is read from CSS and unspecified defaults to `over`.
Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
assertThat(secondCue.text.toString())
@@ -364,7 +319,6 @@ public class WebvttDecoderTest {
"Some text with under-ruby and ".length(),
"Some text with under-ruby and over-ruby (default)".length())
.withTextAndPosition("over", TextAnnotation.POSITION_BEFORE);
-
// Check many