Search in sources :

Example 1 with ShadowLooperExecutor

use of com.android.launcher3.shadows.ShadowLooperExecutor in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherModelHelper method loadModelSync.

/**
 * Loads the model in memory synchronously
 */
public void loadModelSync() throws ExecutionException, InterruptedException {
    // Since robolectric tests run on main thread, we run the loader-UI calls on a temp thread,
    // so that we can wait appropriately for the loader to complete.
    ShadowLooperExecutor sle = Shadow.extract(Executors.MAIN_EXECUTOR);
    sle.setHandler(Executors.UI_HELPER_EXECUTOR.getHandler());
    Callbacks mockCb = mock(Callbacks.class);
    getModel().addCallbacksAndLoad(mockCb);
    Executors.MODEL_EXECUTOR.submit(() -> {
    }).get();
    Executors.UI_HELPER_EXECUTOR.submit(() -> {
    }).get();
    sle.setHandler(null);
    getModel().removeCallbacks(mockCb);
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) ShadowLooperExecutor(com.android.launcher3.shadows.ShadowLooperExecutor)

Example 2 with ShadowLooperExecutor

use of com.android.launcher3.shadows.ShadowLooperExecutor in project android_packages_apps_Launcher3 by crdroidandroid.

the class ModelMultiCallbacksTest method setUp.

@Before
public void setUp() throws Exception {
    mModelHelper = new LauncherModelHelper();
    mModelHelper.installApp(TEST_PACKAGE);
    mSpm = shadowOf(RuntimeEnvironment.application.getPackageManager());
    // Since robolectric tests run on main thread, we run the loader-UI calls on a temp thread,
    // so that we can wait appropriately for the loader to complete.
    mTempMainExecutor = new LooperExecutor(createAndStartNewLooper("tempMain"));
    ShadowLooperExecutor sle = Shadow.extract(Executors.MAIN_EXECUTOR);
    sle.setHandler(mTempMainExecutor.getHandler());
}
Also used : LooperExecutor(com.android.launcher3.util.LooperExecutor) ShadowLooperExecutor(com.android.launcher3.shadows.ShadowLooperExecutor) LauncherModelHelper(com.android.launcher3.util.LauncherModelHelper) ShadowLooperExecutor(com.android.launcher3.shadows.ShadowLooperExecutor) Before(org.junit.Before)

Aggregations

ShadowLooperExecutor (com.android.launcher3.shadows.ShadowLooperExecutor)2 Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)1 LauncherModelHelper (com.android.launcher3.util.LauncherModelHelper)1 LooperExecutor (com.android.launcher3.util.LooperExecutor)1 Before (org.junit.Before)1