use of org.wikipedia.gallery.GalleryItemClient.Callback in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestSuccessForVideo.
@Test
@SuppressWarnings("checkstyle:magicnumber")
public void testRequestSuccessForVideo() throws Throwable {
enqueueFromFile("gallery_item_video.json");
Callback cb = mock(Callback.class);
Call<MwQueryResponse> call = request(cb, true);
server().takeRequest();
ArgumentCaptor<GalleryItem> captor = ArgumentCaptor.forClass(GalleryItem.class);
// noinspection unchecked
verify(cb).success(eq(call), captor.capture());
// noinspection unchecked
GalleryItem galleryItem = captor.getValue();
assertThat(galleryItem != null, is(true));
assertThat(String.valueOf(galleryItem.getHeight()), is("720"));
assertThat(String.valueOf(galleryItem.getWidth()), is("400"));
assertThat(galleryItem.getThumbUrl(), is("https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Wood_cleaving_-_2016.webm/400px--Wood_cleaving_-_2016.webm.jpg"));
assertThat(galleryItem.getMimeType(), is("video/webm"));
assertThat(galleryItem.getUrl(), is("https://upload.wikimedia.org/wikipedia/commons/e/eb/Wood_cleaving_-_2016.webm"));
assertThat(galleryItem.getDerivatives().size(), is(11));
}
use of org.wikipedia.gallery.GalleryItemClient.Callback in project apps-android-wikipedia by wikimedia.
the class GalleryItemClientTest method testRequestSuccessForImage.
@Test
public void testRequestSuccessForImage() throws Throwable {
enqueueFromFile("gallery_item_image.json");
Callback cb = mock(Callback.class);
Call<MwQueryResponse> call = request(cb, false);
server().takeRequest();
ArgumentCaptor<GalleryItem> captor = ArgumentCaptor.forClass(GalleryItem.class);
// noinspection unchecked
verify(cb).success(eq(call), captor.capture());
// noinspection unchecked
GalleryItem galleryItem = captor.getValue();
assertThat(galleryItem != null, is(true));
assertThat(String.valueOf(galleryItem.getHeight()), is("1489"));
assertThat(String.valueOf(galleryItem.getWidth()), is("2125"));
assertThat(galleryItem.getThumbUrl(), is("https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Kinkaku3402CBcropped.jpg/1280px-Kinkaku3402CBcropped.jpg"));
assertThat(galleryItem.getMimeType(), is("image/jpeg"));
assertThat(galleryItem.getUrl(), is("https://upload.wikimedia.org/wikipedia/commons/c/c9/Kinkaku3402CBcropped.jpg"));
}
Aggregations