Commit 890fd0a9 by rohks Committed by Marc Baechinger

Check `MediaMetadata` bundle to verify keys are skipped

Added another check in test to make sure we don't add keys to bundle for fields with `null` values.

PiperOrigin-RevId: 496948705
parent 8ed51588
......@@ -107,12 +107,17 @@ public class MediaMetadataTest {
}
@Test
public void createMinimalMediaMetadata_roundTripViaBundle_yieldsEqualInstance() {
public void toBundleSkipsDefaultValues_fromBundleRestoresThem() {
MediaMetadata mediaMetadata = new MediaMetadata.Builder().build();
MediaMetadata mediaMetadataFromBundle =
MediaMetadata.CREATOR.fromBundle(mediaMetadata.toBundle());
Bundle mediaMetadataBundle = mediaMetadata.toBundle();
// check Bundle created above, contains no keys.
assertThat(mediaMetadataBundle.keySet()).isEmpty();
MediaMetadata mediaMetadataFromBundle = MediaMetadata.CREATOR.fromBundle(mediaMetadataBundle);
// check object retrieved from mediaMetadataBundle is equal to mediaMetadata.
assertThat(mediaMetadataFromBundle).isEqualTo(mediaMetadata);
// Extras is not implemented in MediaMetadata.equals(Object o).
assertThat(mediaMetadataFromBundle.extras).isNull();
......
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