Esempio n. 1
0
 @Test
 public void clearsCallbackOnCancel() throws Exception {
   Picasso picasso = mock(Picasso.class);
   ImageView target = mockImageViewTarget();
   Callback callback = mockCallback();
   ImageViewAction request =
       new ImageViewAction(
           picasso, target, null, false, false, 0, null, URI_KEY_1, null, callback);
   request.cancel();
   assertThat(request.callback).isNull();
 }
Esempio n. 2
0
 @Test
 public void invokesErrorIfTargetIsNotNullWithErrorResourceId() throws Exception {
   ImageView target = mockImageViewTarget();
   Callback callback = mockCallback();
   Picasso mock = mock(Picasso.class);
   ImageViewAction request =
       new ImageViewAction(
           mock, target, null, false, false, RESOURCE_ID_1, null, null, null, callback);
   request.error();
   verify(target).setImageResource(RESOURCE_ID_1);
   verify(callback).onError();
 }
Esempio n. 3
0
 @Test
 public void returnsIfTargetIsNullOnError() throws Exception {
   Picasso picasso = mock(Picasso.class);
   ImageView target = mockImageViewTarget();
   Callback callback = mockCallback();
   ImageViewAction request =
       new ImageViewAction(
           picasso, target, null, false, false, 0, null, URI_KEY_1, null, callback);
   request.target.clear();
   request.error();
   verifyZeroInteractions(target);
   verifyZeroInteractions(callback);
 }
Esempio n. 4
0
 @Test
 public void invokesErrorIfTargetIsNotNullWithErrorDrawable() throws Exception {
   Drawable errorDrawable = mock(Drawable.class);
   ImageView target = mockImageViewTarget();
   Callback callback = mockCallback();
   Picasso mock = mock(Picasso.class);
   ImageViewAction request =
       new ImageViewAction(
           mock, target, null, false, false, 0, errorDrawable, URI_KEY_1, null, callback);
   request.error();
   verify(target).setImageDrawable(errorDrawable);
   verify(callback).onError();
 }
Esempio n. 5
0
 @Test(expected = AssertionError.class)
 public void throwsErrorWithNullResult() throws Exception {
   ImageViewAction action =
       new ImageViewAction(
           mock(Picasso.class),
           mockImageViewTarget(),
           null,
           false,
           false,
           0,
           null,
           URI_KEY_1,
           null,
           null);
   action.complete(null, MEMORY);
 }
Esempio n. 6
0
 @Test
 public void invokesTargetAndCallbackSuccessIfTargetIsNotNull() throws Exception {
   Picasso picasso =
       new Picasso(
           Robolectric.application,
           mock(Dispatcher.class),
           Cache.NONE,
           null,
           IDENTITY,
           null,
           mock(Stats.class),
           false,
           false);
   ImageView target = mockImageViewTarget();
   Callback callback = mockCallback();
   ImageViewAction request =
       new ImageViewAction(
           picasso, target, null, false, false, 0, null, URI_KEY_1, null, callback);
   request.complete(BITMAP_1, MEMORY);
   verify(target).setImageDrawable(any(PicassoDrawable.class));
   verify(callback).onSuccess();
 }