Java 类com.bumptech.glide.request.target.BaseTarget 实例源码

项目:GitHub    文件:RequestManagerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  context = RuntimeEnvironment.application;
  connectivityMonitor = mock(ConnectivityMonitor.class);
  ConnectivityMonitorFactory factory = mock(ConnectivityMonitorFactory.class);
  when(factory.build(isA(Context.class), isA(ConnectivityMonitor.ConnectivityListener.class)))
      .thenAnswer(new Answer<ConnectivityMonitor>() {
        @Override
        public ConnectivityMonitor answer(InvocationOnMock invocation) throws Throwable {
          connectivityListener = (ConnectivityListener) invocation.getArguments()[1];
          return connectivityMonitor;
        }
      });

   target = new BaseTarget<Drawable>() {
     @Override
     public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
       // Empty.
     }
     @Override
     public void getSize(SizeReadyCallback cb) {
       // Empty.
     }
     @Override
     public void removeCallback(SizeReadyCallback cb) {
       // Empty.
     }
  };

  requestTracker = mock(RequestTracker.class);
  manager =
      new RequestManager(
          Glide.get(RuntimeEnvironment.application),
          lifecycle,
          treeNode,
          requestTracker,
          factory,
          context);
}