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);
}
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());
}
Aggregations