@Test
public void testDecodePositions() throws IOException {

  SsaDecoder decoder = new SsaDecoder();
  byte[] bytes = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), POSITIONS);
  Subtitle subtitle = decoder.decode(bytes, bytes.length, false);
  // Check \pos() sets position & line
  Cue firstCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(0)));
  assertWithMessage("Cue.position").that(firstCue.position).isEqualTo(0.5f);
  assertWithMessage("Cue.lineType").that(firstCue.lineType).isEqualTo(Cue.LINE_TYPE_FRACTION);
  assertWithMessage("Cue.line").that(firstCue.line).isEqualTo(0.25f);
  // Check the \pos() doesn't need to be at the start of the line.
  Cue secondCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(2)));
  assertWithMessage("Cue.position").that(secondCue.position).isEqualTo(0.25f);
  assertWithMessage("Cue.line").that(secondCue.line).isEqualTo(0.25f);
  // Check only the last \pos() value is used.
  Cue thirdCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(4)));
  assertWithMessage("Cue.position").that(thirdCue.position).isEqualTo(0.25f);
  // Check \move() is treated as \pos()
  Cue fourthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(6)));
  assertWithMessage("Cue.position").that(fourthCue.position).isEqualTo(0.5f);
  assertWithMessage("Cue.line").that(fourthCue.line).isEqualTo(0.25f);
  // Check alignment override in a separate brace (to bottom-center) affects textAlignment and
  // both line & position anchors.
  Cue fifthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(8)));
  assertWithMessage("Cue.position").that(fifthCue.position).isEqualTo(0.5f);
  assertWithMessage("Cue.line").that(fifthCue.line).isEqualTo(0.5f);
  assertWithMessage("Cue.positionAnchor")
      .that(fifthCue.positionAnchor)
      .isEqualTo(Cue.ANCHOR_TYPE_MIDDLE);
  assertWithMessage("Cue.lineAnchor").that(fifthCue.lineAnchor).isEqualTo(Cue.ANCHOR_TYPE_END);
  assertWithMessage("Cue.textAlignment")
      .that(fifthCue.textAlignment)
      .isEqualTo(Layout.Alignment.ALIGN_CENTER);
  // Check alignment override in the same brace (to top-right) affects textAlignment and both line
  // & position anchors.
  Cue sixthCue = Iterables.getOnlyElement(subtitle.getCues(subtitle.getEventTime(10)));
  assertWithMessage("Cue.position").that(sixthCue.position).isEqualTo(0.5f);
  assertWithMessage("Cue.line").that(sixthCue.line).isEqualTo(0.5f);
  assertWithMessage("Cue.positionAnchor")
      .that(sixthCue.positionAnchor)
      .isEqualTo(Cue.ANCHOR_TYPE_END);
  assertWithMessage("Cue.lineAnchor").that(sixthCue.lineAnchor).isEqualTo(Cue.ANCHOR_TYPE_START);
  assertWithMessage("Cue.textAlignment")
      .that(sixthCue.textAlignment)
      .isEqualTo(Layout.Alignment.ALIGN_OPPOSITE);
}