ArtInfo implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(artistName); dest.writeString(albumName); dest.writeString(artworkUri.toString()); } ArtInfo(String artistName, String albumName, Uri artworkUri); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); final String artistName; final String albumName; final Uri artworkUri; static final Creator<ArtInfo> CREATOR; }
@Test public void ensureArtInfoParcelableWorks() { Parcel p = Parcel.obtain(); artInfo1.writeToParcel(p, 0); p.setDataPosition(0); ArtInfo fromP = ArtInfo.CREATOR.createFromParcel(p); assertThat(artInfo1).isEqualTo(fromP); }