Search in sources :

Example 26 with Request

use of com.bumptech.glide.request.Request in project glide by bumptech.

the class RequestBuilderTest method testRemovesPreviousRequestFromRequestTracker.

@Test
public void testRemovesPreviousRequestFromRequestTracker() {
    Request previous = mock(Request.class);
    Target<Object> target = mock(Target.class);
    when(target.getRequest()).thenReturn(previous);
    getNullModelRequest().into(target);
    verify(requestManager).clear(eq(target));
}
Also used : Request(com.bumptech.glide.request.Request) Test(org.junit.Test)

Example 27 with Request

use of com.bumptech.glide.request.Request in project glide by bumptech.

the class GifFrameLoaderTest method testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame.

@Test
public void testOnFrameReadyWithNullResourceDoesNotClearPreviousFrame() {
    // Force the loader to create a real Handler by passing null.
    loader = createGifFrameLoader(null);
    DelayTarget previous = mock(DelayTarget.class);
    Request previousRequest = mock(Request.class);
    when(previous.getRequest()).thenReturn(previousRequest);
    when(previous.getResource()).thenReturn(Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888));
    DelayTarget current = mock(DelayTarget.class);
    when(current.getResource()).thenReturn(null);
    loader.onFrameReady(previous);
    loader.onFrameReady(current);
    verify(previousRequest, never()).clear();
}
Also used : Request(com.bumptech.glide.request.Request) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 28 with Request

use of com.bumptech.glide.request.Request in project glide by bumptech.

the class GifFrameLoaderTest method testClearsCompletedLoadOnFrameReadyIfCleared.

@Test
public void testClearsCompletedLoadOnFrameReadyIfCleared() {
    // Force the loader to create a real Handler by passing null;
    loader = createGifFrameLoader(null);
    loader.clear();
    DelayTarget delayTarget = mock(DelayTarget.class);
    Request request = mock(Request.class);
    when(delayTarget.getRequest()).thenReturn(request);
    loader.onFrameReady(delayTarget);
    verify(requestManager).clear(eq(delayTarget));
}
Also used : Request(com.bumptech.glide.request.Request) DelayTarget(com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget) Test(org.junit.Test)

Example 29 with Request

use of com.bumptech.glide.request.Request in project glide by bumptech.

the class ViewTargetTest method testCanSetAndRetrieveRequest.

@Test
public void testCanSetAndRetrieveRequest() {
    Request request = mock(Request.class);
    target.setRequest(request);
    assertEquals(request, target.getRequest());
}
Also used : Request(com.bumptech.glide.request.Request) Test(org.junit.Test)

Example 30 with Request

use of com.bumptech.glide.request.Request in project glide by bumptech.

the class RequestTrackerTest method testDoesNotRestartCompletedRequestsWhenResumed.

@Test
public void testDoesNotRestartCompletedRequestsWhenResumed() {
    Request request = mock(Request.class);
    when(request.isComplete()).thenReturn(true);
    tracker.addRequest(request);
    tracker.resumeRequests();
    verify(request, never()).begin();
}
Also used : Request(com.bumptech.glide.request.Request) Test(org.junit.Test)

Aggregations

Request (com.bumptech.glide.request.Request)39 Test (org.junit.Test)33 DelayTarget (com.bumptech.glide.load.resource.gif.GifFrameLoader.DelayTarget)3 SingleRequest (com.bumptech.glide.request.SingleRequest)2 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 BaseRequestOptions (com.bumptech.glide.request.BaseRequestOptions)1 ThumbnailRequestCoordinator (com.bumptech.glide.request.ThumbnailRequestCoordinator)1 ShadowView (org.robolectric.shadows.ShadowView)1