mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add unit tests for region attrs in style
This commit is contained in:
parent
fbd6dfa439
commit
026700a9d9
@ -74,6 +74,7 @@ public final class TtmlParserTest {
|
||||
private static final String RUBIES_FILE = "media/ttml/rubies.xml";
|
||||
private static final String TEXT_EMPHASIS_FILE = "media/ttml/text_emphasis.xml";
|
||||
private static final String SHEAR_FILE = "media/ttml/shear.xml";
|
||||
private static final String REGION_ATTRS_FROM_STYLE_FILE = "media/ttml/inherit_region_attributes_from_style.xml";
|
||||
|
||||
@Test
|
||||
public void simple_allCues() throws Exception {
|
||||
@ -1093,6 +1094,21 @@ public final class TtmlParserTest {
|
||||
assertThat(eighthCue.shearDegrees).isWithin(0.01f).of(90f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regionAttrsFromStyle() throws Exception {
|
||||
ImmutableList<CuesWithTiming> allCues = getAllCues(REGION_ATTRS_FROM_STYLE_FILE);
|
||||
|
||||
Cue firstCue = Iterables.getOnlyElement(allCues.get(0).cues);
|
||||
assertThat(firstCue.position).isEqualTo(10f / 100f);
|
||||
assertThat(firstCue.line).isEqualTo(10f / 100f);
|
||||
assertThat(firstCue.size).isEqualTo(20f / 100f);
|
||||
|
||||
Cue secondCue = Iterables.getOnlyElement(allCues.get(1).cues);
|
||||
assertThat(secondCue.position).isEqualTo(30f / 100f);
|
||||
assertThat(secondCue.line).isEqualTo(30f / 100f);
|
||||
assertThat(secondCue.size).isEqualTo(40f / 100f);
|
||||
}
|
||||
|
||||
private static Spanned getOnlyCueTextAtIndex(List<CuesWithTiming> allCues, int index) {
|
||||
Cue cue = getOnlyCueAtIndex(allCues, index);
|
||||
assertThat(cue.text).isInstanceOf(Spanned.class);
|
||||
|
@ -0,0 +1,19 @@
|
||||
<tt xmlns="http://www.w3.org/ns/ttml"
|
||||
xmlns:tts="http://www.w3.org/2006/10/ttaf1#style">
|
||||
<head>
|
||||
<styling>
|
||||
<style xml:id="style1" tts:extent="20% 20%" />
|
||||
<style xml:id="style2" tts:origin="30% 30%" />
|
||||
</styling>
|
||||
<layout>
|
||||
<region xml:id="region1" style="style1" tts:origin="10% 10%" />
|
||||
<region xml:id="region2" style="style2" tts:extent="40% 40%" />
|
||||
</layout>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<p begin="2s" end="4s" region="region1">text 1</p>
|
||||
<p begin="4s" end="6s" region="region2">text 2</p>
|
||||
</div>
|
||||
</body>
|
||||
</tt>
|
Loading…
x
Reference in New Issue
Block a user