mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Add AllApps TAPL APIs for toggling with meta key." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
c0b9b422be
@@ -161,6 +161,10 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
|
||||
SystemUiProxy.INSTANCE.get(mContext).isDragAndDropReady());
|
||||
return response;
|
||||
|
||||
case TestProtocol.REQUEST_REFRESH_OVERVIEW_TARGET:
|
||||
runOnTISBinder(TouchInteractionService.TISBinder::refreshOverviewTarget);
|
||||
return response;
|
||||
}
|
||||
|
||||
return super.call(method, arg, extras);
|
||||
|
||||
@@ -409,18 +409,16 @@ public class TouchInteractionService extends Service {
|
||||
* Sets a proxy to bypass swipe up behavior
|
||||
*/
|
||||
public void setSwipeUpProxy(Function<GestureState, AnimatedFloat> proxy) {
|
||||
TouchInteractionService tis = mTis.get();
|
||||
if (tis == null) return;
|
||||
tis.mSwipeUpProxyProvider = proxy != null ? proxy : (i -> null);
|
||||
executeForTouchInteractionService(
|
||||
tis -> tis.mSwipeUpProxyProvider = proxy != null ? proxy : (i -> null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the task id where gestures should be blocked
|
||||
*/
|
||||
public void setGestureBlockedTaskId(int taskId) {
|
||||
TouchInteractionService tis = mTis.get();
|
||||
if (tis == null) return;
|
||||
tis.mDeviceState.setGestureBlockingTaskId(taskId);
|
||||
executeForTouchInteractionService(
|
||||
tis -> tis.mDeviceState.setGestureBlockingTaskId(taskId));
|
||||
}
|
||||
|
||||
/** Sets a listener to be run on Overview Target updates. */
|
||||
@@ -434,6 +432,12 @@ public class TouchInteractionService extends Service {
|
||||
mOnOverviewTargetChangeListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Refreshes the current overview target. */
|
||||
public void refreshOverviewTarget() {
|
||||
executeForTouchInteractionService(tis -> tis.onOverviewTargetChange(
|
||||
tis.mOverviewComponentObserver.isHomeAndOverviewSame()));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean sConnected = false;
|
||||
|
||||
@@ -126,6 +126,7 @@ public final class TestProtocol {
|
||||
"taskbar-all-apps-top-padding";
|
||||
public static final String REQUEST_ALL_APPS_TOP_PADDING = "all-apps-top-padding";
|
||||
public static final String REQUEST_ALL_APPS_BOTTOM_PADDING = "all-apps-bottom-padding";
|
||||
public static final String REQUEST_REFRESH_OVERVIEW_TARGET = "refresh-overview-target";
|
||||
|
||||
public static final String REQUEST_WORKSPACE_CELL_LAYOUT_SIZE = "workspace-cell-layout-size";
|
||||
public static final String REQUEST_WORKSPACE_CELL_CENTER = "workspace-cell-center";
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static android.view.KeyEvent.KEYCODE_META_RIGHT;
|
||||
|
||||
import static com.android.launcher3.tapl.LauncherInstrumentation.DEFAULT_POLL_INTERVAL;
|
||||
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
|
||||
|
||||
@@ -370,6 +372,17 @@ public abstract class AllApps extends LauncherInstrumentation.VisibleContainer
|
||||
}
|
||||
}
|
||||
|
||||
/** Presses the meta keyboard shortcut to dismiss AllApps. */
|
||||
public void dismissByKeyboardShortcut() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.getDevice().pressKeyCode(KEYCODE_META_RIGHT);
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"pressed meta key")) {
|
||||
verifyVisibleContainerOnDismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void verifyVisibleContainerOnDismiss();
|
||||
|
||||
/**
|
||||
|
||||
@@ -1343,6 +1343,16 @@ public final class LauncherInstrumentation {
|
||||
}
|
||||
}
|
||||
|
||||
void waitForObjectFocused(UiObject2 object, String waitReason) {
|
||||
try {
|
||||
assertTrue("Timed out waiting for object to be focused for " + waitReason + " "
|
||||
+ object.getResourceName(),
|
||||
object.wait(Until.focused(true), WAIT_TIME_MS));
|
||||
} catch (StaleObjectException e) {
|
||||
fail("The object disappeared from screen");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
UiObject2 waitForObjectInContainer(UiObject2 container, BySelector selector) {
|
||||
return waitForObjectsInContainer(container, selector).get(0);
|
||||
@@ -2043,6 +2053,12 @@ public final class LauncherInstrumentation {
|
||||
getTestInfo(TestProtocol.REQUEST_RECREATE_TASKBAR);
|
||||
}
|
||||
|
||||
// TODO(b/270393900): Remove with ENABLE_ALL_APPS_SEARCH_IN_TASKBAR flag cleanup.
|
||||
/** Refreshes the known overview target in TIS. */
|
||||
public void refreshOverviewTarget() {
|
||||
getTestInfo(TestProtocol.REQUEST_REFRESH_OVERVIEW_TARGET);
|
||||
}
|
||||
|
||||
public List<String> getHotseatIconNames() {
|
||||
return getTestInfo(TestProtocol.REQUEST_HOTSEAT_ICON_NAMES)
|
||||
.getStringArrayList(TestProtocol.TEST_INFO_RESPONSE_FIELD);
|
||||
|
||||
@@ -25,7 +25,7 @@ import androidx.test.uiautomator.Until;
|
||||
/**
|
||||
* Operations on qsb from either Home screen or AllApp screen.
|
||||
*/
|
||||
public abstract class Qsb {
|
||||
public abstract class Qsb implements SearchInputSource {
|
||||
|
||||
private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
|
||||
private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
|
||||
@@ -125,6 +125,16 @@ public abstract class Qsb {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherInstrumentation getLauncher() {
|
||||
return mLauncher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResultFromQsb getSearchResultForInput() {
|
||||
return createSearchResult();
|
||||
}
|
||||
|
||||
protected SearchResultFromQsb createSearchResult() {
|
||||
return new SearchResultFromQsb(mLauncher);
|
||||
}
|
||||
|
||||
52
tests/tapl/com/android/launcher3/tapl/SearchInputSource.java
Normal file
52
tests/tapl/com/android/launcher3/tapl/SearchInputSource.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
|
||||
/**
|
||||
* Container that can be used to input a search query and retrieve a {@link SearchResultFromQsb}
|
||||
* instance.
|
||||
*/
|
||||
interface SearchInputSource {
|
||||
String INPUT_RES = "input";
|
||||
|
||||
/** Set the already focused search input edit text and update search results. */
|
||||
default SearchResultFromQsb searchForInput(String input) {
|
||||
LauncherInstrumentation launcher = getLauncher();
|
||||
try (LauncherInstrumentation.Closable c = launcher.addContextLayer(
|
||||
"want to search for result with an input");
|
||||
LauncherInstrumentation.Closable e = launcher.eventsCheck()) {
|
||||
launcher.executeAndWaitForLauncherEvent(
|
||||
() -> {
|
||||
UiObject2 editText = launcher.waitForLauncherObject(INPUT_RES);
|
||||
launcher.waitForObjectFocused(editText, "search input");
|
||||
editText.setText(input);
|
||||
},
|
||||
event -> TestProtocol.SEARCH_RESULT_COMPLETE.equals(event.getClassName()),
|
||||
() -> "Didn't receive a search result completed message", "searching");
|
||||
return getSearchResultForInput();
|
||||
}
|
||||
}
|
||||
|
||||
/** This method requires public access, however should not be called in tests. */
|
||||
LauncherInstrumentation getLauncher();
|
||||
|
||||
/** This method requires public access, however should not be called in tests. */
|
||||
SearchResultFromQsb getSearchResultForInput();
|
||||
}
|
||||
@@ -20,16 +20,12 @@ import android.widget.TextView;
|
||||
import androidx.test.uiautomator.By;
|
||||
import androidx.test.uiautomator.UiObject2;
|
||||
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Operations on search result page opened from qsb.
|
||||
*/
|
||||
public class SearchResultFromQsb {
|
||||
// The input resource id in the search box.
|
||||
private static final String INPUT_RES = "input";
|
||||
public class SearchResultFromQsb implements SearchInputSource {
|
||||
private static final String BOTTOM_SHEET_RES_ID = "bottom_sheet_background";
|
||||
|
||||
// This particular ID change should happen with caution
|
||||
@@ -41,18 +37,6 @@ public class SearchResultFromQsb {
|
||||
mLauncher.waitForLauncherObject("search_container_all_apps");
|
||||
}
|
||||
|
||||
/** Set the input to the search input edit text and update search results. */
|
||||
public void searchForInput(String input) {
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"want to search for result with an input");
|
||||
LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.executeAndWaitForLauncherEvent(
|
||||
() -> mLauncher.waitForLauncherObject(INPUT_RES).setText(input),
|
||||
event -> TestProtocol.SEARCH_RESULT_COMPLETE.equals(event.getClassName()),
|
||||
() -> "Didn't receive a search result completed message", "searching");
|
||||
}
|
||||
}
|
||||
|
||||
/** Find the app from search results with app name. */
|
||||
public AppIcon findAppIcon(String appName) {
|
||||
UiObject2 icon = mLauncher.waitForLauncherObject(By.clazz(TextView.class).text(appName));
|
||||
@@ -114,4 +98,14 @@ public class SearchResultFromQsb {
|
||||
protected void verifyVisibleContainerOnDismiss() {
|
||||
mLauncher.getWorkspace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherInstrumentation getLauncher() {
|
||||
return mLauncher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchResultFromQsb getSearchResultForInput() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static android.view.KeyEvent.KEYCODE_META_RIGHT;
|
||||
|
||||
import static com.android.launcher3.tapl.LauncherInstrumentation.TASKBAR_RES_ID;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING;
|
||||
@@ -105,6 +107,17 @@ public final class Taskbar {
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the Taskbar all apps page with the meta keyboard shortcut. */
|
||||
public TaskbarAllApps openAllAppsFromKeyboardShortcut() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
|
||||
mLauncher.getDevice().pressKeyCode(KEYCODE_META_RIGHT);
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
"pressed meta key")) {
|
||||
return getAllApps();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns {@link TaskbarAllApps} if it is open, otherwise fails. */
|
||||
public TaskbarAllApps getAllApps() {
|
||||
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.tapl;
|
||||
|
||||
import static android.view.KeyEvent.KEYCODE_META_RIGHT;
|
||||
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_SCROLLED;
|
||||
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL;
|
||||
@@ -115,6 +116,20 @@ public final class Workspace extends Home {
|
||||
}
|
||||
}
|
||||
|
||||
/** Opens the Launcher all apps page with the meta keyboard shortcut. */
|
||||
public HomeAllApps openAllAppsFromKeyboardShortcut() {
|
||||
try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
|
||||
LauncherInstrumentation.Closable c =
|
||||
mLauncher.addContextLayer("want to open all apps search")) {
|
||||
verifyActiveContainer();
|
||||
mLauncher.getDevice().pressKeyCode(KEYCODE_META_RIGHT);
|
||||
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer(
|
||||
"pressed meta key")) {
|
||||
return new HomeAllApps(mLauncher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the home qsb.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user