Merge "Add launch assistant method." into tm-qpr-dev am: 0b44854718

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19822904

Change-Id: I3770f6e904abf8507e47b62470540eb0e102ca3e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Hui Kang
2022-09-09 18:25:19 +00:00
committed by Automerger Merge Worker

View File

@@ -15,18 +15,56 @@
*/
package com.android.launcher3.tapl;
import androidx.annotation.NonNull;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
/**
* Operations on home screen qsb.
*/
public class HomeQsb {
private final LauncherInstrumentation mLauncher;
private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
HomeQsb(LauncherInstrumentation launcher) {
mLauncher = launcher;
mLauncher.waitForLauncherObject("search_container_hotseat");
}
/**
* Launch assistant app by tapping mic icon on qsb.
*/
@NonNull
public LaunchedAppState launchAssistant() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to click assistant mic icon button");
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
LauncherInstrumentation.log("HomeQsb.launchAssistant before click "
+ assistantIcon.getVisibleCenter() + " in "
+ mLauncher.getVisibleBounds(assistantIcon));
mLauncher.clickLauncherObject(assistantIcon);
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
// assert Assistant App Launched
BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
mLauncher.assertTrue(
"assistant app didn't start: (" + selector + ")",
mLauncher.getDevice().wait(Until.hasObject(selector),
LauncherInstrumentation.WAIT_TIME_MS)
);
return new LaunchedAppState(mLauncher);
}
}
}
/**
* Show search result page from tapping qsb.
*/