Merge "Move common code from DesktopTaskView and GroupedTaskView to TaskView" into main
diff --git a/tests/Android.bp b/tests/Android.bp
index 11177de..cc0021b 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -199,8 +199,8 @@
         "androidx.test.ext.junit",
         "androidx.test.rules",
         "uiautomator-helpers",
-        "mockito-robolectric-prebuilt",
-        "mockito-kotlin2",
+        "inline-mockito-robolectric-prebuilt",
+        "mockito-kotlin-nodeps",
         "platform-parametric-runner-lib",
         "testables",
         "Launcher3TestResources",
diff --git a/tests/src/com/android/launcher3/AppFilterTest.kt b/tests/src/com/android/launcher3/AppFilterTest.kt
new file mode 100644
index 0000000..f2150a2
--- /dev/null
+++ b/tests/src/com/android/launcher3/AppFilterTest.kt
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3
+
+import android.content.ComponentName
+import android.content.Context
+import android.content.res.Resources
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mock
+import org.mockito.Mockito.`when`
+import org.mockito.junit.MockitoJUnitRunner
+
+@RunWith(MockitoJUnitRunner::class)
+class AppFilterTest {
+
+    @Mock private lateinit var mockContext: Context
+
+    @Mock // Mock the Resources object as well
+    private lateinit var mockResources: Resources
+
+    private lateinit var appFilter: AppFilter
+
+    @Before
+    fun setUp() {
+        `when`(mockContext.resources).thenReturn(mockResources) // Link the context and resources
+        `when`(mockResources.getStringArray(R.array.filtered_components))
+            .thenReturn(arrayOf("com.example.app1/Activity1"))
+        appFilter = AppFilter(mockContext)
+    }
+
+    @Test
+    fun shouldShowApp_notFiltered_returnsTrue() {
+        val appToShow = ComponentName("com.example.app2", "Activity2")
+        assertThat(appFilter.shouldShowApp(appToShow)).isTrue()
+    }
+
+    @Test
+    fun shouldShowApp_filtered_returnsFalse() {
+        val appToHide = ComponentName("com.example.app1", "Activity1")
+        assertThat(appFilter.shouldShowApp(appToHide)).isFalse()
+    }
+}
diff --git a/tests/src/com/android/launcher3/popup/SystemShortcutTest.java b/tests/src/com/android/launcher3/popup/SystemShortcutTest.java
index dc8c17a..c663be0 100644
--- a/tests/src/com/android/launcher3/popup/SystemShortcutTest.java
+++ b/tests/src/com/android/launcher3/popup/SystemShortcutTest.java
@@ -57,6 +57,7 @@
 import com.android.launcher3.model.data.ItemInfo;
 import com.android.launcher3.model.data.WorkspaceItemInfo;
 import com.android.launcher3.pm.UserCache;
+import com.android.launcher3.util.ApiWrapper;
 import com.android.launcher3.util.ComponentKey;
 import com.android.launcher3.util.LauncherModelHelper.SandboxModelContext;
 import com.android.launcher3.util.TestSandboxModelContextWrapper;
@@ -88,6 +89,7 @@
     private PopupDataProvider mPopupDataProvider;
     private AppInfo mAppInfo;
     @Mock UserCache mUserCache;
+    @Mock ApiWrapper mApiWrapper;
     @Mock BaseDragLayer mBaseDragLayer;
     @Mock UserIconInfo mUserIconInfo;
     @Mock LauncherActivityInfo mLauncherActivityInfo;
@@ -98,6 +100,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mSandboxContext.putObject(UserCache.INSTANCE, mUserCache);
+        mSandboxContext.putObject(ApiWrapper.INSTANCE, mApiWrapper);
         mTestContext = new TestSandboxModelContextWrapper(mSandboxContext);
         mView = new View(mSandboxContext);
         spyOn(mTestContext);