Search in sources :

Example 1 with RequestManagerTreeNode

use of com.bumptech.glide.manager.RequestManagerTreeNode in project glide by bumptech.

the class GlideTest method setUp.

@Before
public void setUp() throws Exception {
    Glide.tearDown();
    RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager();
    ApplicationInfo info = pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0);
    info.metaData = new Bundle();
    info.metaData.putString(SetupModule.class.getName(), "GlideModule");
    // Ensure that target's size ready callback will be called synchronously.
    target = mock(Target.class);
    imageView = new ImageView(RuntimeEnvironment.application);
    imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
    doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
    Handler bgHandler = mock(Handler.class);
    when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {

        @Override
        public Boolean answer(InvocationOnMock invocation) throws Throwable {
            Runnable runnable = (Runnable) invocation.getArguments()[0];
            runnable.run();
            return true;
        }
    });
    Lifecycle lifecycle = mock(Lifecycle.class);
    RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class);
    requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode);
    requestManager.resumeRequests();
}
Also used : Bundle(android.os.Bundle) ViewGroup(android.view.ViewGroup) Lifecycle(com.bumptech.glide.manager.Lifecycle) ApplicationInfo(android.content.pm.ApplicationInfo) Handler(android.os.Handler) SizeReadyCallback(com.bumptech.glide.request.target.SizeReadyCallback) Target(com.bumptech.glide.request.target.Target) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ImageView(android.widget.ImageView) RequestManagerTreeNode(com.bumptech.glide.manager.RequestManagerTreeNode) RobolectricPackageManager(org.robolectric.res.builder.RobolectricPackageManager) Before(org.junit.Before)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 Lifecycle (com.bumptech.glide.manager.Lifecycle)1 RequestManagerTreeNode (com.bumptech.glide.manager.RequestManagerTreeNode)1 SizeReadyCallback (com.bumptech.glide.request.target.SizeReadyCallback)1 Target (com.bumptech.glide.request.target.Target)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 RobolectricPackageManager (org.robolectric.res.builder.RobolectricPackageManager)1