Search in sources :

Example 1 with FakeAction

use of com.squareup.picasso3.TestUtils.FakeAction in project picasso by square.

the class PicassoTest method completeDeliversToSingleAndMultiple.

@Test
public void completeDeliversToSingleAndMultiple() {
    FakeAction action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    FakeAction action2 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    BitmapHunter hunter = mockHunter(new RequestHandler.Result.Bitmap(bitmap, MEMORY), action);
    hunter.attach(action2);
    hunter.run();
    picasso.complete(hunter);
    verifyActionComplete(action);
    verifyActionComplete(action2);
}
Also used : FakeAction(com.squareup.picasso3.TestUtils.FakeAction) Test(org.junit.Test)

Example 2 with FakeAction

use of com.squareup.picasso3.TestUtils.FakeAction in project picasso by square.

the class PicassoTest method completeSkipsIfNoActions.

@Test
public void completeSkipsIfNoActions() {
    FakeAction action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    BitmapHunter hunter = mockHunter(new RequestHandler.Result.Bitmap(bitmap, MEMORY), action);
    hunter.detach(action);
    hunter.run();
    picasso.complete(hunter);
    assertThat(hunter.getAction()).isNull();
    assertThat(hunter.getActions()).isNull();
}
Also used : FakeAction(com.squareup.picasso3.TestUtils.FakeAction) Test(org.junit.Test)

Example 3 with FakeAction

use of com.squareup.picasso3.TestUtils.FakeAction in project picasso by square.

the class PicassoTest method completeDeliversToSingle.

@Test
public void completeDeliversToSingle() {
    FakeAction action = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    BitmapHunter hunter = mockHunter(new RequestHandler.Result.Bitmap(bitmap, MEMORY), action);
    hunter.run();
    picasso.complete(hunter);
    verifyActionComplete(action);
}
Also used : FakeAction(com.squareup.picasso3.TestUtils.FakeAction) Test(org.junit.Test)

Example 4 with FakeAction

use of com.squareup.picasso3.TestUtils.FakeAction in project picasso by square.

the class PicassoTest method completeInvokesSuccessOnAllSuccessfulRequests.

@Test
public void completeInvokesSuccessOnAllSuccessfulRequests() {
    FakeAction action1 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    BitmapHunter hunter = mockHunter(new RequestHandler.Result.Bitmap(bitmap, MEMORY), action1);
    FakeAction action2 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    hunter.attach(action2);
    action2.cancelled = true;
    hunter.run();
    picasso.complete(hunter);
    verifyActionComplete(action1);
    assertThat(action2.completedResult).isNull();
}
Also used : FakeAction(com.squareup.picasso3.TestUtils.FakeAction) Test(org.junit.Test)

Example 5 with FakeAction

use of com.squareup.picasso3.TestUtils.FakeAction in project picasso by square.

the class PicassoTest method completeInvokesErrorOnAllFailedRequests.

@Test
public void completeInvokesErrorOnAllFailedRequests() {
    FakeAction action1 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    Exception exception = mock(Exception.class);
    BitmapHunter hunter = mockHunter(new RequestHandler.Result.Bitmap(bitmap, MEMORY), action1, exception);
    FakeAction action2 = mockAction(URI_KEY_1, URI_1, mockImageViewTarget());
    hunter.attach(action2);
    action2.cancelled = true;
    hunter.run();
    picasso.complete(hunter);
    assertThat(action1.errorException).hasCauseThat().isEqualTo(exception);
    assertThat(action2.errorException).isNull();
    verify(listener).onImageLoadFailed(picasso, URI_1, action1.errorException);
}
Also used : FakeAction(com.squareup.picasso3.TestUtils.FakeAction) Test(org.junit.Test)

Aggregations

FakeAction (com.squareup.picasso3.TestUtils.FakeAction)6 Test (org.junit.Test)6