use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by crdroidandroid.
the class AddWorkspaceItemsTaskTest method testAddItem_some_items_added.
@Test
public void testAddItem_some_items_added() throws Exception {
Callbacks callbacks = mock(Callbacks.class);
mModelHelper.getModel().addCallbacks(callbacks);
WorkspaceItemInfo info = new WorkspaceItemInfo();
info.intent = new Intent().setComponent(mComponent1);
WorkspaceItemInfo info2 = new WorkspaceItemInfo();
info2.intent = new Intent().setComponent(mComponent2);
// Setup a screen with a hole
setupWorkspaceWithHoles(1, 1, new Rect(2, 2, 3, 3));
mModelHelper.executeTaskForTest(newTask(info, info2)).get(0).run();
ArgumentCaptor<ArrayList> notAnimated = ArgumentCaptor.forClass(ArrayList.class);
ArgumentCaptor<ArrayList> animated = ArgumentCaptor.forClass(ArrayList.class);
// only info2 should be added because info was already added to the workspace
// in setupWorkspaceWithHoles()
verify(callbacks).bindAppsAdded(any(IntArray.class), notAnimated.capture(), animated.capture());
assertTrue(notAnimated.getValue().isEmpty());
assertEquals(1, animated.getValue().size());
assertTrue(animated.getValue().contains(info2));
}
use of com.android.launcher3.model.BgDataModel.Callbacks 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.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by AOSPA.
the class FallbackActivityInterface method getParallelAnimationToLauncher.
@Override
@Nullable
public Animator getParallelAnimationToLauncher(GestureEndTarget endTarget, long duration, RecentsAnimationCallbacks callbacks) {
FallbackTaskbarUIController uiController = getTaskbarController();
Animator superAnimator = super.getParallelAnimationToLauncher(endTarget, duration, callbacks);
if (uiController == null) {
return superAnimator;
}
RecentsState toState = stateFromGestureEndTarget(endTarget);
Animator taskbarAnimator = uiController.createAnimToRecentsState(toState, duration);
if (taskbarAnimator == null) {
return superAnimator;
}
if (superAnimator == null) {
return taskbarAnimator;
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(superAnimator, taskbarAnimator);
return animatorSet;
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by AOSPA.
the class LauncherActivityInterface method getParallelAnimationToLauncher.
@Override
@Nullable
public Animator getParallelAnimationToLauncher(GestureEndTarget endTarget, long duration, RecentsAnimationCallbacks callbacks) {
LauncherTaskbarUIController uiController = getTaskbarController();
Animator superAnimator = super.getParallelAnimationToLauncher(endTarget, duration, callbacks);
if (uiController == null || callbacks == null) {
return superAnimator;
}
LauncherState toState = stateFromGestureEndTarget(endTarget);
Animator taskbarAnimator = uiController.createAnimToLauncher(toState, callbacks, duration);
if (superAnimator == null) {
return taskbarAnimator;
} else {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(superAnimator, taskbarAnimator);
return animatorSet;
}
}
use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by AOSPA.
the class LauncherModelHelper method executeTaskForTest.
/**
* Synchronously executes the task and returns all the UI callbacks posted.
*/
public List<Runnable> executeTaskForTest(ModelUpdateTask task) throws Exception {
LauncherModel model = getModel();
if (!model.isModelLoaded()) {
ReflectionHelpers.setField(model, "mModelLoaded", true);
}
Executor mockExecutor = mock(Executor.class);
model.enqueueModelUpdateTask(new ModelUpdateTask() {
@Override
public void init(LauncherAppState app, LauncherModel model, BgDataModel dataModel, AllAppsList allAppsList, Executor uiExecutor) {
task.init(app, model, dataModel, allAppsList, mockExecutor);
}
@Override
public void run() {
task.run();
}
});
MODEL_EXECUTOR.submit(() -> null).get();
ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
verify(mockExecutor, atLeast(0)).execute(captor.capture());
return captor.getAllValues();
}
Aggregations