LoaderManager { public void destroy() { for (int i = 0, size = loaders.size(); i < size; i++) { Loader<?> loader = loaders.get(i); if (loader != null) { loader.destroy(); } } loaders.clear(); }  L init(int id, RetainState.OnCreate<L> create, Loader.Callbacks<T> callbacks); void remove(int id); void detach(); void destroy(); void onDestroy(RetainState retainState); static final RetainState.OnCreate<LoaderManager> CREATE; }
@Test public void destroy() { Loader.Callbacks<String> callbacks = mock(Loader.Callbacks.class); TestLoader<String> loader = loaderManager.init(0, TestLoader.<String>create(), callbacks); loader.start(); loaderManager.destroy(); loader.deliverResult("test"); assertTrue(loader.isCanceled()); verify(callbacks).onLoaderStart(); verifyNoMoreInteractions(callbacks); }