TrackGroupArray implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(length); for (int i = 0; i < length; i++) { dest.writeParcelable(trackGroups[i], 0); } } TrackGroupArray(TrackGroup... trackGroups);   TrackGroupArray(Parcel in); TrackGroup get(int index); @SuppressWarnings("ReferenceEquality") int indexOf(TrackGroup group); boolean isEmpty(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final TrackGroupArray EMPTY; final int length; static final Parcelable.Creator<TrackGroupArray> CREATOR; }
@Test public void testParcelable() { Format format1 = Format.createSampleFormat("1", MimeTypes.VIDEO_H264, 0); Format format2 = Format.createSampleFormat("2", MimeTypes.AUDIO_AAC, 0); Format format3 = Format.createSampleFormat("3", MimeTypes.VIDEO_H264, 0); TrackGroup trackGroup1 = new TrackGroup(format1, format2); TrackGroup trackGroup2 = new TrackGroup(format3); TrackGroupArray trackGroupArrayToParcel = new TrackGroupArray(trackGroup1, trackGroup2); Parcel parcel = Parcel.obtain(); trackGroupArrayToParcel.writeToParcel(parcel, 0); parcel.setDataPosition(0); TrackGroupArray trackGroupArrayFromParcel = TrackGroupArray.CREATOR.createFromParcel(parcel); assertThat(trackGroupArrayFromParcel).isEqualTo(trackGroupArrayToParcel); parcel.recycle(); }