Moving tests form TaplTestsLauncher3 to TaplTestsAllAppsIconsWorking

Removing testGetAppIconName since that behaviour is already tested.

I'm also using this change to remove the TISBinder rule since it's not
needed.

Bug: 302869930
Test: atest TaplTestsAllAppsIconsWorking
Change-Id: Ie6b4f801254ca69b2485fe574914a73f947fc434
diff --git a/tests/Android.bp b/tests/Android.bp
index a397307..c4bd7cf 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -43,6 +43,7 @@
     name: "launcher-oop-tests-src",
     srcs: [
       "src/com/android/launcher3/allapps/TaplOpenCloseAllApps.java",
+      "src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java",
       "src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java",
       "src/com/android/launcher3/dragging/TaplDragTest.java",
       "src/com/android/launcher3/dragging/TaplUninstallRemove.java",
@@ -62,7 +63,6 @@
       "src/com/android/launcher3/util/rule/ShellCommandRule.java",
       "src/com/android/launcher3/util/rule/TestIsolationRule.java",
       "src/com/android/launcher3/util/rule/TestStabilityRule.java",
-      "src/com/android/launcher3/util/rule/TISBindRule.java",
       "src/com/android/launcher3/util/viewcapture_analysis/*.java",
       "src/com/android/launcher3/testcomponent/BaseTestingActivity.java",
       "src/com/android/launcher3/testcomponent/OtherBaseTestingActivity.java",
diff --git a/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java b/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java
new file mode 100644
index 0000000..fd4619e
--- /dev/null
+++ b/tests/src/com/android/launcher3/allapps/TaplTestsAllAppsIconsWorking.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2023 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.allapps;
+
+import static com.android.launcher3.ui.TaplTestsLauncher3.initialize;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.tapl.AppIcon;
+import com.android.launcher3.tapl.HomeAllApps;
+import com.android.launcher3.ui.AbstractLauncherUiTest;
+import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * The test runs in Out of process (Oop) and in process.
+ * Makes sure the basic behaviors of Icons on AllApps are working.
+ */
+public class TaplTestsAllAppsIconsWorking extends AbstractLauncherUiTest {
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        initialize(this);
+    }
+
+    /**
+     * Makes sure we can launch an icon from All apps
+     */
+    @Test
+    @PortraitLandscape
+    public void testAppIconLaunchFromAllAppsFromHome() {
+        final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
+        assertTrue("Launcher internal state is not All Apps",
+                isInState(() -> LauncherState.ALL_APPS));
+
+        allApps.freeze();
+        try {
+            final AppIcon app = allApps.getAppIcon("TestActivity7");
+            assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
+            executeOnLauncher(launcher -> assertTrue(
+                    "Launcher activity is the top activity; expecting another activity to be the "
+                            + "top one",
+                    isInLaunchedApp(launcher)));
+        } finally {
+            allApps.unfreeze();
+        }
+    }
+}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 25da9ed..f37b676 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -23,14 +23,9 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import com.android.launcher3.LauncherState;
-import com.android.launcher3.tapl.AllApps;
-import com.android.launcher3.tapl.AppIcon;
-import com.android.launcher3.tapl.HomeAllApps;
 import com.android.launcher3.ui.PortraitLandscapeRunner.PortraitLandscape;
-import com.android.launcher3.util.rule.TISBindRule;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -43,9 +38,6 @@
     public static final String STORE_APP_NAME = "Play Store";
     public static final String GMAIL_APP_NAME = "Gmail";
 
-    @Rule
-    public TISBindRule mTISBindRule = new TISBindRule();
-
     @Before
     public void setUp() throws Exception {
         super.setUp();
@@ -91,30 +83,6 @@
         mLauncher.goHome();
     }
 
-    public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
-        allApps.freeze();
-        try {
-            final AppIcon app = allApps.getAppIcon("TestActivity7");
-            assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
-            test.executeOnLauncher(launcher -> assertTrue(
-                    "Launcher activity is the top activity; expecting another activity to be the "
-                            + "top one",
-                    test.isInLaunchedApp(launcher)));
-        } finally {
-            allApps.unfreeze();
-        }
-    }
-
-    @Test
-    @PortraitLandscape
-    public void testAppIconLaunchFromAllAppsFromHome() throws Exception {
-        final HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
-        assertTrue("Launcher internal state is not All Apps",
-                isInState(() -> LauncherState.ALL_APPS));
-
-        runIconLaunchFromAllAppsTest(this, allApps);
-    }
-
     @Test
     @PortraitLandscape
     public void testAddDeleteShortcutOnHotseat() {
@@ -126,16 +94,4 @@
         mLauncher.getWorkspace().deleteAppIcon(
                 mLauncher.getWorkspace().getHotseatAppIcon(APP_NAME));
     }
-
-    @Test
-    public void testGetAppIconName() {
-        HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps();
-        allApps.freeze();
-        try {
-            // getAppIcon() already verifies that the icon is not null and is the correct icon name.
-            allApps.getAppIcon(APP_NAME);
-        } finally {
-            allApps.unfreeze();
-        }
-    }
 }
diff --git a/tests/src/com/android/launcher3/util/rule/TISBindRule.java b/tests/src/com/android/launcher3/util/rule/TISBindRule.java
deleted file mode 100644
index 3ec4a29..0000000
--- a/tests/src/com/android/launcher3/util/rule/TISBindRule.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2023 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.util.rule;
-
-import android.app.UiAutomation;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.util.Log;
-
-import androidx.annotation.NonNull;
-import androidx.test.platform.app.InstrumentationRegistry;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-public class TISBindRule implements TestRule {
-    public static String TAG = "TISBindRule";
-    public static String INTENT_FILTER = "android.intent.action.QUICKSTEP_SERVICE";
-    public static String TIS_PERMISSIONS = "android.permission.STATUS_BAR_SERVICE";
-
-    private String getLauncherPackageName(Context context) {
-        return ComponentName.unflattenFromString(context.getString(
-                com.android.internal.R.string.config_recentsComponentName)).getPackageName();
-    }
-
-    private ServiceConnection createConnection() {
-        return new ServiceConnection() {
-            @Override
-            public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
-                Log.d(TAG, "Connected to TouchInteractionService");
-            }
-
-            @Override
-            public void onServiceDisconnected(ComponentName componentName) {
-                Log.d(TAG, "Disconnected from TouchInteractionService");
-            }
-        };
-    }
-
-    @NonNull
-    @Override
-    public Statement apply(@NonNull Statement base, @NonNull Description description) {
-        return new Statement() {
-
-            @Override
-            public void evaluate() throws Throwable {
-                Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
-                final ServiceConnection connection = createConnection();
-                UiAutomation uiAutomation =
-                        InstrumentationRegistry.getInstrumentation().getUiAutomation();
-                uiAutomation.adoptShellPermissionIdentity(TIS_PERMISSIONS);
-                Intent launchIntent = new Intent(INTENT_FILTER);
-                launchIntent.setPackage(getLauncherPackageName(context));
-                context.bindService(launchIntent, connection, Context.BIND_AUTO_CREATE);
-                uiAutomation.dropShellPermissionIdentity();
-                try {
-                    base.evaluate();
-                } finally {
-                    context.unbindService(connection);
-                }
-            }
-        };
-    }
-}