use of net.rdrei.android.scdl2.api.entity.TrackEntity in project scdl by passy.
the class PlaylistEntityTest method testParcel.
@Test
public void testParcel() {
final TrackEntity track0 = new TrackEntity();
track0.setId(200l);
track0.setTitle("Hello, World.");
final TrackEntity track1 = new TrackEntity();
track1.setId(201l);
track1.setTitle("Yet another track");
final PlaylistEntity playlist = new PlaylistEntity();
playlist.setId(23l);
playlist.setDescription("new stuff");
playlist.setTracks(Arrays.asList(new TrackEntity[] { track0, track1 }));
final byte[] bytes;
final Parcel parcel0 = Parcel.obtain();
try {
parcel0.writeValue(playlist);
bytes = parcel0.marshall();
} finally {
parcel0.recycle();
}
final PlaylistEntity newPlaylist;
final Parcel parcel1 = Parcel.obtain();
try {
parcel1.unmarshall(bytes, 0, bytes.length);
parcel1.setDataPosition(0);
newPlaylist = (PlaylistEntity) parcel1.readValue(PlaylistEntity.class.getClassLoader());
} finally {
parcel1.recycle();
}
assertThat(newPlaylist.getId(), equalTo(23l));
assertThat(newPlaylist.getDescription(), equalTo("new stuff"));
assertThat(newPlaylist.getTracks().size(), equalTo(2));
assertThat(newPlaylist.getTracks().get(0).getId(), equalTo(200l));
}
use of net.rdrei.android.scdl2.api.entity.TrackEntity 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();
}
use of net.rdrei.android.scdl2.api.entity.TrackEntity 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");
}
use of net.rdrei.android.scdl2.api.entity.TrackEntity in project scdl by passy.
the class TrackEntityTest method testFormattedDuration.
@Test
public void testFormattedDuration() {
TrackEntity entity = new TrackEntity();
entity.setDuration(121000);
assertThat(entity.getFormattedDuration(), equalTo("2:01"));
}
use of net.rdrei.android.scdl2.api.entity.TrackEntity in project scdl by passy.
the class TrackServiceTest method testResolveTrack.
@Test
public void testResolveTrack() throws APIException {
final TrackService service = mServiceManager.trackService();
TrackEntity entity = service.getTrack("44276907");
assertThat(entity.getTitle(), equalTo("Newklear - Contaminated Selection *SPECIAL GUEST SHOW BOUNFM RADIO APRIL. 24TH*"));
}
Aggregations