Merge "Introduce TAPL APIs for Taskbar QSB and search results." into udc-qpr-dev

This commit is contained in:
Brian Isganitis
2023-08-24 17:29:46 +00:00
committed by Android (Google) Code Review
9 changed files with 113 additions and 29 deletions

View File

@@ -336,4 +336,11 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer {
final Bundle testInfo = mLauncher.getTestInfo(TestProtocol.REQUEST_APP_LIST_FREEZE_FLAGS);
return testInfo == null ? 0 : testInfo.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
/**
* Return the QSB UI object on the AllApps screen.
* @return the QSB UI object.
*/
@NonNull
public abstract Qsb getQsb();
}

View File

@@ -62,4 +62,10 @@ public class AllAppsFromTaskbar extends AllApps {
return mLauncher.getTestInfo(TestProtocol.REQUEST_TASKBAR_APPS_LIST_SCROLL_Y)
.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
}
@NonNull
@Override
public TaskbarAllAppsQsb getQsb() {
return new TaskbarAllAppsQsb(mLauncher, verifyActiveContainer());
}
}

View File

@@ -22,16 +22,7 @@ import androidx.test.uiautomator.UiObject2;
*/
class AllAppsQsb extends Qsb {
private final UiObject2 mAllAppsContainer;
AllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer) {
super(launcher);
mAllAppsContainer = allAppsContainer;
waitForQsbObject();
}
@Override
protected UiObject2 waitForQsbObject() {
return mLauncher.waitForObjectInContainer(mAllAppsContainer, "search_container_all_apps");
super(launcher, allAppsContainer, "search_container_all_apps");
}
}

View File

@@ -117,11 +117,8 @@ public class HomeAllApps extends AllApps {
}
}
/**
* Return the QSB UI object on the AllApps screen.
* @return the QSB UI object.
*/
@NonNull
@Override
public Qsb getQsb() {
return new AllAppsQsb(mLauncher, verifyActiveContainer());
}

View File

@@ -22,16 +22,7 @@ import androidx.test.uiautomator.UiObject2;
*/
class HomeQsb extends Qsb {
private final UiObject2 mHotSeat;
HomeQsb(LauncherInstrumentation launcher, UiObject2 hotseat) {
super(launcher);
mHotSeat = hotseat;
waitForQsbObject();
}
@Override
protected UiObject2 waitForQsbObject() {
return mLauncher.waitForObjectInContainer(mHotSeat, "search_container_hotseat");
super(launcher, hotseat, "search_container_hotseat");
}
}

View File

@@ -30,13 +30,21 @@ public abstract class Qsb {
private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
protected final LauncherInstrumentation mLauncher;
private final UiObject2 mContainer;
private final String mQsbResName;
protected Qsb(LauncherInstrumentation launcher) {
protected Qsb(LauncherInstrumentation launcher, UiObject2 container, String qsbResName) {
mLauncher = launcher;
mContainer = container;
mQsbResName = qsbResName;
waitForQsbObject();
}
// Waits for the quick search box.
protected abstract UiObject2 waitForQsbObject();
private UiObject2 waitForQsbObject() {
return mLauncher.waitForObjectInContainer(mContainer, mQsbResName);
}
/**
* Launch assistant app by tapping mic icon on qsb.
*/
@@ -79,8 +87,12 @@ public abstract class Qsb {
mLauncher.waitForIdle();
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
"clicked qsb to open search result page")) {
return new SearchResultFromQsb(mLauncher);
return createSearchResult();
}
}
}
protected SearchResultFromQsb createSearchResult() {
return new SearchResultFromQsb(mLauncher);
}
}

View File

@@ -32,7 +32,7 @@ public class SearchResultFromQsb {
// This particular ID change should happen with caution
private static final String SEARCH_CONTAINER_RES_ID = "search_results_list_view";
private final LauncherInstrumentation mLauncher;
protected final LauncherInstrumentation mLauncher;
SearchResultFromQsb(LauncherInstrumentation launcher) {
mLauncher = launcher;
@@ -49,8 +49,12 @@ public class SearchResultFromQsb {
}
/** Find the app from search results with app name. */
public Launchable findAppIcon(String appName) {
public AppIcon findAppIcon(String appName) {
UiObject2 icon = mLauncher.waitForLauncherObject(By.clazz(TextView.class).text(appName));
return createAppIcon(icon);
}
protected AppIcon createAppIcon(UiObject2 icon) {
return new AllAppsAppIcon(mLauncher, icon);
}

View File

@@ -0,0 +1,38 @@
/*
* 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.tapl;
import androidx.test.uiautomator.UiObject2;
/**
* Operations on search result page opened from Taskbar qsb.
*/
public class SearchResultFromTaskbarQsb extends SearchResultFromQsb {
SearchResultFromTaskbarQsb(LauncherInstrumentation launcher) {
super(launcher);
}
@Override
public TaskbarAppIcon findAppIcon(String appName) {
return (TaskbarAppIcon) super.findAppIcon(appName);
}
@Override
protected TaskbarAppIcon createAppIcon(UiObject2 icon) {
return new TaskbarAppIcon(mLauncher, icon);
}
}

View File

@@ -0,0 +1,38 @@
/*
* 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.tapl;
import androidx.test.uiautomator.UiObject2;
/**
* Operations on Taskbar AllApp screen qsb.
*/
public class TaskbarAllAppsQsb extends Qsb {
TaskbarAllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer) {
super(launcher, allAppsContainer, "search_container_all_apps");
}
@Override
public SearchResultFromTaskbarQsb showSearchResult() {
return (SearchResultFromTaskbarQsb) super.showSearchResult();
}
@Override
protected SearchResultFromTaskbarQsb createSearchResult() {
return new SearchResultFromTaskbarQsb(mLauncher);
}
}