Search in sources :

Example 1 with MediaState

use of net.rdrei.android.scdl2.api.MediaState in project scdl by passy.

the class MediaStateTest method testTrackType.

@Test
public void testTrackType() {
    final TrackEntity track = new TrackEntity();
    final MediaState mediaState = MediaState.fromEntity(track);
    assertThat(mediaState.getType()).isEqualTo(MediaDownloadType.TRACK);
    assertThat(mediaState.getTrackOption().isEmpty()).isFalse();
    assertThat(mediaState.getPlaylistOption().isEmpty()).isTrue();
}
Also used : TrackEntity(net.rdrei.android.scdl2.api.entity.TrackEntity) MediaState(net.rdrei.android.scdl2.api.MediaState) Test(org.junit.Test)

Example 2 with MediaState

use of net.rdrei.android.scdl2.api.MediaState in project scdl by passy.

the class MediaStateTest method testTrackParcel.

@Test
public void testTrackParcel() {
    final TrackEntity track = new TrackEntity();
    track.setTitle("My track");
    track.setUser(new UserEntity());
    final MediaState entity = MediaState.fromEntity(track);
    final byte[] bytes;
    final Parcel parcel = Parcel.obtain();
    try {
        parcel.writeValue(entity);
        bytes = parcel.marshall();
    } finally {
        parcel.recycle();
    }
    final MediaState newEntity;
    final Parcel parcel2 = Parcel.obtain();
    try {
        parcel2.unmarshall(bytes, 0, bytes.length);
        parcel2.setDataPosition(0);
        newEntity = (MediaState) parcel2.readValue(MediaState.class.getClassLoader());
    } finally {
        parcel2.recycle();
    }
    assertThat(newEntity.getType()).isEqualTo(MediaDownloadType.TRACK);
    assertThat(newEntity.getTrackOption().get().getTitle()).isEqualTo("My track");
}
Also used : TrackEntity(net.rdrei.android.scdl2.api.entity.TrackEntity) MediaState(net.rdrei.android.scdl2.api.MediaState) Parcel(android.os.Parcel) UserEntity(net.rdrei.android.scdl2.api.entity.UserEntity) Test(org.junit.Test)

Aggregations

MediaState (net.rdrei.android.scdl2.api.MediaState)2 TrackEntity (net.rdrei.android.scdl2.api.entity.TrackEntity)2 Test (org.junit.Test)2 Parcel (android.os.Parcel)1 UserEntity (net.rdrei.android.scdl2.api.entity.UserEntity)1