[go: nahoru, domu]

Skip to content

Commit

Permalink
Check MediaMetadata bundle to verify keys are skipped
Browse files Browse the repository at this point in the history
Added another check in test to make sure we don't add keys to bundle for fields with `null` values.

PiperOrigin-RevId: 496948705
  • Loading branch information
rohitjoins authored and marcbaechinger committed Jan 4, 2023
1 parent 8ed5158 commit 890fd0a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,17 @@ public void populate_populatesEveryField() {
}

@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();
Expand Down

0 comments on commit 890fd0a

Please sign in to comment.