Merge "Revert^2 "Expose getSearchBox from the HomeAllApps class"" into tm-qpr-dev am: 6d3658dd0c am: 4f9196c305
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21160354 Change-Id: I2d4c1b04e1f6fef0a0c075e8692a742f5a5bf2c8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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 AllApp screen qsb.
|
||||||
|
*/
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,4 +109,13 @@ public class HomeAllApps extends AllApps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the QSB UI object on the AllApps screen.
|
||||||
|
* @return the QSB UI object.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Qsb getQsb() {
|
||||||
|
return new AllAppsQsb(mLauncher, verifyActiveContainer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,69 +15,23 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.launcher3.tapl;
|
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.UiObject2;
|
||||||
import androidx.test.uiautomator.Until;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operations on home screen qsb.
|
* Operations on Home screen qsb.
|
||||||
*/
|
*/
|
||||||
public class HomeQsb {
|
class HomeQsb extends Qsb {
|
||||||
|
|
||||||
private final LauncherInstrumentation mLauncher;
|
private final UiObject2 mHotSeat;
|
||||||
private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
|
|
||||||
private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
|
|
||||||
|
|
||||||
|
HomeQsb(LauncherInstrumentation launcher, UiObject2 hotseat) {
|
||||||
HomeQsb(LauncherInstrumentation launcher) {
|
super(launcher);
|
||||||
mLauncher = launcher;
|
mHotSeat = hotseat;
|
||||||
mLauncher.waitForLauncherObject("search_container_hotseat");
|
waitForQsbObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Launch assistant app by tapping mic icon on qsb.
|
protected UiObject2 waitForQsbObject() {
|
||||||
*/
|
return mLauncher.waitForObjectInContainer(mHotSeat, "search_container_hotseat");
|
||||||
@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.
|
|
||||||
*/
|
|
||||||
public SearchResultFromQsb showSearchResult() {
|
|
||||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
|
||||||
"want to open search result page");
|
|
||||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
|
||||||
mLauncher.clickLauncherObject(
|
|
||||||
mLauncher.waitForLauncherObject("search_container_hotseat"));
|
|
||||||
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
|
|
||||||
"clicked qsb to open search result page")) {
|
|
||||||
return new SearchResultFromQsb(mLauncher);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 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.annotation.NonNull;
|
||||||
|
import androidx.test.uiautomator.By;
|
||||||
|
import androidx.test.uiautomator.BySelector;
|
||||||
|
import androidx.test.uiautomator.UiObject2;
|
||||||
|
import androidx.test.uiautomator.Until;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operations on qsb from either Home screen or AllApp screen.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
|
protected Qsb(LauncherInstrumentation launcher) {
|
||||||
|
mLauncher = launcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Waits for the quick search box.
|
||||||
|
protected abstract UiObject2 waitForQsbObject();
|
||||||
|
/**
|
||||||
|
* 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("Qsb.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.
|
||||||
|
*/
|
||||||
|
public SearchResultFromQsb showSearchResult() {
|
||||||
|
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||||
|
"want to open search result page");
|
||||||
|
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||||
|
mLauncher.clickLauncherObject(waitForQsbObject());
|
||||||
|
// wait for the result rendering to complete
|
||||||
|
mLauncher.waitForIdle();
|
||||||
|
try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
|
||||||
|
"clicked qsb to open search result page")) {
|
||||||
|
return new SearchResultFromQsb(mLauncher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@ import androidx.test.uiautomator.UiObject2;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operations on search result page opened from home screen qsb.
|
* Operations on search result page opened from qsb.
|
||||||
*/
|
*/
|
||||||
public class SearchResultFromQsb {
|
public class SearchResultFromQsb {
|
||||||
// The input resource id in the search box.
|
// The input resource id in the search box.
|
||||||
|
|||||||
@@ -119,10 +119,11 @@ public final class Workspace extends Home {
|
|||||||
*
|
*
|
||||||
* The qsb must already be visible when calling this method.
|
* The qsb must already be visible when calling this method.
|
||||||
*/
|
*/
|
||||||
public HomeQsb getQsb() {
|
@NonNull
|
||||||
|
public Qsb getQsb() {
|
||||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||||
"want to get the home qsb")) {
|
"want to get the home qsb")) {
|
||||||
return new HomeQsb(mLauncher);
|
return new HomeQsb(mLauncher, mHotseat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user