Refactor RecentTasksList ctor to be testable

Made ctor accept more arguments so we can
pass in mock objects for unit testing.

Test: Created RecentsTasksListTest.java, passes
adb shell am instrument -w -r -e debug false -e \
class 'com.android.quickstep.RecentTasksListTest' \
com.google.android.apps.nexuslauncher.tests/androidx.test.runner.AndroidJUnitRunner

Fixes: 135687618
Change-Id: Iffda661e9d5329a2a403060bde674ab81e4e720e
This commit is contained in:
Vinit Nayak committed 2019-07-23 11:49:19 -07:00
1 parent f05d3f8fd4
commit 15abc500ea
3 files changed
+117 -8

No files matched your search

@@ -30,11 +30,14 @@ import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.BackgroundExecutor;
import com.android.systemui.shared.system.KeyguardManagerCompat;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.TaskStackChangeListener;
@@ -68,7 +71,8 @@ public class RecentsModel extends TaskStackChangeListener {
HandlerThread loaderThread = new HandlerThread("TaskThumbnailIconCache",
Process.THREAD_PRIORITY_BACKGROUND);
loaderThread.start();
mTaskList = new RecentTasksList(context);
mTaskList = new RecentTasksList(new MainThreadExecutor(),
new KeyguardManagerCompat(context), ActivityManagerWrapper.getInstance());
mIconCache = new TaskIconCache(context, loaderThread.getLooper());
mThumbnailCache = new TaskThumbnailCache(context, loaderThread.getLooper());
ActivityManagerWrapper.getInstance().registerTaskStackListener(this);