From ebba03501bc15502435b537d91cb5cfcac02a234 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Fri, 15 Sep 2023 16:01:29 -0700 Subject: [PATCH] Waiting for a TYPE_WINDOW_STATE_CHANGED event when starting Settings from task menu. We do this when starting apps from Launcher in other places. Bug: 298114205 Test: presubmit Flag: N/A Change-Id: I1ff4466a2daa78b618cdc24910f90b8d4306d8b8 --- .../launcher3/tapl/OverviewTaskMenu.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java index 7c29a6cf87..859e504679 100644 --- a/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java +++ b/tests/tapl/com/android/launcher3/tapl/OverviewTaskMenu.java @@ -16,6 +16,8 @@ package com.android.launcher3.tapl; +import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; + import androidx.annotation.NonNull; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; @@ -50,15 +52,23 @@ public class OverviewTaskMenu { } } - /** Taps the app info item from the overview task menu and returns the LaunchedAppState - * representing the App info settings page. */ + /** + * Taps the app info item from the overview task menu and returns the LaunchedAppState + * representing the App info settings page. + */ @NonNull public LaunchedAppState tapAppInfoMenuItem() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck(); LauncherInstrumentation.Closable c = mLauncher.addContextLayer( "before tapping the app info menu item")) { - mLauncher.clickLauncherObject( - mLauncher.findObjectInContainer(mMenu, By.text("App info"))); + + mLauncher.executeAndWaitForLauncherEvent( + () -> mLauncher.clickLauncherObject( + mLauncher.findObjectInContainer(mMenu, By.text("App info"))), + accessibilityEvent -> + accessibilityEvent.getEventType() == TYPE_WINDOW_STATE_CHANGED, + () -> "Unable to start Settings by clicking App Info", + "Tap the app info menu item"); try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer( "tapped app info menu item")) {