@Test
public void readMetadataBlock_pictureBlock_updatesStreamMetadata() throws Exception {

  ExtractorInput input = buildExtractorInput("flac/bear_with_picture.flac");
  // Skip to picture block.
  input.skipFully(640);
  FlacStreamMetadataHolder metadataHolder = new FlacStreamMetadataHolder(buildStreamMetadata());
  long originalSampleRate = metadataHolder.flacStreamMetadata.sampleRate;
  FlacMetadataReader.readMetadataBlock(input, metadataHolder);
  assertThat(metadataHolder.flacStreamMetadata).isNotNull();
  // Check that metadata passed has not been erased.
  assertThat(metadataHolder.flacStreamMetadata.sampleRate).isEqualTo(originalSampleRate);
  Metadata metadata =
      metadataHolder.flacStreamMetadata.getMetadataCopyWithAppendedEntriesFrom(null);
  assertThat(metadata).isNotNull();
  PictureFrame pictureFrame = (PictureFrame) metadata.get(0);
  assertThat(pictureFrame.pictureType).isEqualTo(3);
  assertThat(pictureFrame.mimeType).isEqualTo("image/png");
  assertThat(pictureFrame.description).isEqualTo("");
  assertThat(pictureFrame.width).isEqualTo(371);
  assertThat(pictureFrame.height).isEqualTo(320);
  assertThat(pictureFrame.depth).isEqualTo(24);
  assertThat(pictureFrame.colors).isEqualTo(0);
  assertThat(pictureFrame.pictureData).hasLength(30943);
}