diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 6e1b24a284..58e36bc8d0 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -57,6 +57,7 @@ import com.android.launcher3.anim.Interpolators; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.popup.SystemShortcut; +import com.android.launcher3.testing.TestLogging; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; @@ -331,6 +332,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { Consumer resultCallback, Handler resultCallbackHandler) { if (mTask != null) { final ActivityOptions opts; + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + TestLogging.recordEvent("startActivityFromRecentsAsync:" + mTask); + } if (animate) { opts = mActivity.getActivityLaunchOptions(this); if (freezeTaskList) { diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 3ca4f5989d..f3c5191bbe 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -41,6 +41,7 @@ import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; +import com.android.launcher3.testing.TestLogging; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.ViewCache; @@ -329,6 +330,9 @@ public abstract class BaseActivity extends Activity return; } try { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + TestLogging.recordEvent("start: shortcut: " + packageName); + } getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds, startActivityOptions, user); } catch (SecurityException | IllegalStateException e) { diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index df15fc12fe..0283eac050 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -35,6 +35,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.model.AppLaunchTracker; +import com.android.launcher3.testing.TestLogging; import com.android.launcher3.uioverrides.DisplayRotationListener; import com.android.launcher3.uioverrides.WallpaperColorInfo; import com.android.launcher3.util.PackageManagerHelper; @@ -164,6 +165,9 @@ public abstract class BaseDraggingActivity extends BaseActivity startShortcutIntentSafely(intent, optsBundle, item, sourceContainer); } else if (user == null || user.equals(Process.myUserHandle())) { // Could be launching some bookkeeping activity + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + TestLogging.recordEvent("start: activity: " + intent); + } startActivity(intent, optsBundle); AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(), Process.myUserHandle(), sourceContainer); diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java index 0a6ed7f2e9..3f814fd1eb 100644 --- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java +++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java @@ -22,11 +22,15 @@ import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; +import java.util.regex.Pattern; + /** * App icon, whether in all apps or in workspace/ */ public final class AppIcon extends Launchable { + private static final Pattern START_EVENT = Pattern.compile("start:"); + AppIcon(LauncherInstrumentation launcher, UiObject2 icon) { super(launcher, icon); } @@ -49,4 +53,9 @@ public final class AppIcon extends Launchable { protected String getLongPressIndicator() { return "deep_shortcuts_container"; } + + @Override + protected void expectActivityStartEvents() { + mLauncher.expectEvent(START_EVENT); + } } diff --git a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java index ba9c10e817..fadfd9ff38 100644 --- a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java +++ b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java @@ -18,10 +18,15 @@ package com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; +import java.util.regex.Pattern; + /** * Menu item in an app icon menu. */ public class AppIconMenuItem extends Launchable { + + private static final Pattern START_SHORTCUT_EVENT = Pattern.compile("start: shortcut:"); + AppIconMenuItem(LauncherInstrumentation launcher, UiObject2 shortcut) { super(launcher, shortcut); } @@ -37,4 +42,9 @@ public class AppIconMenuItem extends Launchable { protected String getLongPressIndicator() { return "drop_target_bar"; } + + @Override + protected void expectActivityStartEvents() { + mLauncher.expectEvent(START_SHORTCUT_EVENT); + } } diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index c37e451a7d..5c4689bd15 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -16,6 +16,7 @@ package com.android.launcher3.tapl; +import static com.android.launcher3.tapl.OverviewTask.TASK_START_EVENT; import static com.android.launcher3.testing.TestProtocol.BACKGROUND_APP_STATE_ORDINAL; import static com.android.launcher3.testing.TestProtocol.OVERVIEW_STATE_ORDINAL; @@ -28,6 +29,8 @@ import androidx.test.uiautomator.UiObject2; import com.android.launcher3.testing.TestProtocol; +import java.util.regex.Pattern; + /** * Indicates the base state with a UI other than Overview running as foreground. It can also * indicate Launcher as long as Launcher is not in Overview state. @@ -191,6 +194,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { recentsButton.click(); break; } + mLauncher.expectEvent(TASK_START_EVENT); } protected String getSwipeHeightRequestName() { diff --git a/tests/tapl/com/android/launcher3/tapl/Launchable.java b/tests/tapl/com/android/launcher3/tapl/Launchable.java index 1722d5b3a5..b20384ef6b 100644 --- a/tests/tapl/com/android/launcher3/tapl/Launchable.java +++ b/tests/tapl/com/android/launcher3/tapl/Launchable.java @@ -51,6 +51,8 @@ abstract class Launchable { } } + protected abstract void expectActivityStartEvents(); + private Background launch(BySelector selector) { LauncherInstrumentation.log("Launchable.launch before click " + mObject.getVisibleCenter() + " in " + mObject.getVisibleBounds()); @@ -59,6 +61,7 @@ abstract class Launchable { () -> mLauncher.clickLauncherObject(mObject), event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching an app didn't open a new window: " + mObject.getText()); + expectActivityStartEvents(); mLauncher.assertTrue( "App didn't start: " + selector, diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java index b21b2429a9..410e5a150f 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTask.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTask.java @@ -22,10 +22,14 @@ import android.graphics.Rect; import androidx.test.uiautomator.UiObject2; +import java.util.regex.Pattern; + /** * A recent task in the overview panel carousel. */ public final class OverviewTask { + static final Pattern TASK_START_EVENT = + Pattern.compile("startActivityFromRecentsAsync"); private final LauncherInstrumentation mLauncher; private final UiObject2 mTask; private final BaseOverview mOverview; @@ -72,6 +76,7 @@ public final class OverviewTask { event -> event.getEventType() == TYPE_WINDOW_STATE_CHANGED, () -> "Launching task didn't open a new window: " + mTask.getParent().getContentDescription()); + mLauncher.expectEvent(TASK_START_EVENT); } return new Background(mLauncher); } diff --git a/tests/tapl/com/android/launcher3/tapl/Widget.java b/tests/tapl/com/android/launcher3/tapl/Widget.java index dfd74ed0fa..a658f16deb 100644 --- a/tests/tapl/com/android/launcher3/tapl/Widget.java +++ b/tests/tapl/com/android/launcher3/tapl/Widget.java @@ -31,4 +31,8 @@ public final class Widget extends Launchable { protected String getLongPressIndicator() { return "drop_target_bar"; } + + @Override + protected void expectActivityStartEvents() { + } }