loader/src/androidTest/java/androidx/loader/app/LoaderManagerTest.java
@Test
    public void testDestroyFromOnLoadFinished() throws Throwable {
        final CountDownLatch onLoadFinishedLatch = new CountDownLatch(1);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                mLoaderManager.initLoader(43, null,
                        new DummyLoaderCallbacks(mock(Context.class)) {
                            @Override
                            public void onLoadFinished(@NonNull Loader<Boolean> loader,
                                    Boolean data) {
                                super.onLoadFinished(loader, data);
                                mLoaderManager.destroyLoader(43);
                            }
                        });
            }
        });
        onLoadFinishedLatch.await(1, TimeUnit.SECONDS);
    }
/**
     * Test to ensure that loader operations, such as destroyLoader, can safely be called
     * in onLoadFinished
     */
Test to ensure that loader operations, such as destroyLoader, can safely be called
in onLoadFinished
Test to ensure that loader operations such as destroyLoader can safely be called in onLoadFinished
@Test
    public void testDestroyFromOnLoadFinished() throws Throwable {
        final CountDownLatch onLoadFinishedLatch = new CountDownLatch(1);
        InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                mLoaderManager.initLoader(43, null,
                        new DummyLoaderCallbacks(mock(Context.class)) {
                            @Override
                            public void onLoadFinished(@NonNull Loader<Boolean> loader,
                                    Boolean data) {
                                super.onLoadFinished(loader, data);
                                mLoaderManager.destroyLoader(43);
                            }
                        });
            }
        });
        onLoadFinishedLatch.await(1, TimeUnit.SECONDS);
    }
@ Test public void testDestroyFromOnLoadFinished ( ) throws Throwable { final CountDownLatch onLoadFinishedLatch = new CountDownLatch ( 1 ) ; InstrumentationRegistry . getInstrumentation ( ) . runOnMainSync ( new Runnable ( ) { @ Override public void run ( ) { mLoaderManager . initLoader ( 43 , null , new DummyLoaderCallbacks ( mock ( Context . class ) ) { @ Override public void onLoadFinished ( @ NonNull Loader < Boolean > loader , Boolean data ) { super . onLoadFinished ( loader , data ) ; mLoaderManager . destroyLoader ( 43 ) ; } } ) ; } } ) ; onLoadFinishedLatch . await ( 1 , TimeUnit . SECONDS ) ; }
Test to ensure that loader operations, such as destroyLoader, can safely be called
 in onLoadFinished
Test to ensure that loader operations such as destroyLoader can safely be called in onLoadFinished