Merge "Sending state ordinals from Launcher to TAPL" into ub-launcher3-master
This commit is contained in:
commit
6ffac2ea78
|
@ -153,8 +153,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe
|
|||
// Optimization, hide the all apps view to prevent layout while initializing
|
||||
activity.getAppsView().getContentView().setVisibility(View.GONE);
|
||||
|
||||
AccessibilityManagerCompat.sendEventToTest(
|
||||
activity, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
|
||||
AccessibilityManagerCompat.sendStateEventToTest(activity, fromState.ordinal);
|
||||
} else {
|
||||
fromState = startState;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package com.android.launcher3;
|
|||
public final class TestProtocol {
|
||||
public static final String GET_SCROLL_MESSAGE = "TAPL_GET_SCROLL";
|
||||
public static final String SCROLL_Y_FIELD = "scrollY";
|
||||
public static final String STATE_FIELD = "state";
|
||||
public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
|
||||
public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE";
|
||||
}
|
||||
|
|
|
@ -52,11 +52,14 @@ public class AccessibilityManagerCompat {
|
|||
return (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
}
|
||||
|
||||
public static void sendEventToTest(Context context, String eventTag) {
|
||||
public static void sendStateEventToTest(Context context, int stateOrdinal) {
|
||||
final AccessibilityManager accessibilityManager = getAccessibilityManagerForTest(context);
|
||||
if (accessibilityManager == null) return;
|
||||
|
||||
sendEventToTest(accessibilityManager, eventTag, null);
|
||||
final Bundle parcel = new Bundle();
|
||||
parcel.putInt(TestProtocol.STATE_FIELD, stateOrdinal);
|
||||
|
||||
sendEventToTest(accessibilityManager, TestProtocol.SWITCHED_TO_STATE_MESSAGE, parcel);
|
||||
}
|
||||
|
||||
private static void sendEventToTest(
|
||||
|
|
|
@ -522,8 +522,7 @@ public abstract class AbstractStateChangeTouchController
|
|||
}
|
||||
mLauncher.getStateManager().goToState(targetState, false /* animated */);
|
||||
|
||||
AccessibilityManagerCompat.sendEventToTest(
|
||||
mLauncher, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
|
||||
AccessibilityManagerCompat.sendStateEventToTest(mLauncher, targetState.ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ public final class AllAppsFromOverview extends AllApps {
|
|||
final Point start = qsb.getVisibleCenter();
|
||||
final int endY = (int) (mLauncher.getDevice().getDisplayHeight() * 0.6);
|
||||
LauncherInstrumentation.log("AllAppsFromOverview.switchBackToOverview before swipe");
|
||||
mLauncher.swipe(start.x, start.y, start.x, endY);
|
||||
mLauncher.swipe(
|
||||
start.x, start.y, start.x, endY, LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
|
||||
|
||||
return new Overview(mLauncher);
|
||||
}
|
||||
|
|
|
@ -50,21 +50,22 @@ public class Background extends LauncherInstrumentation.VisibleContainer {
|
|||
@NonNull
|
||||
public BaseOverview switchToOverview() {
|
||||
verifyActiveContainer();
|
||||
goToOverviewUnchecked();
|
||||
goToOverviewUnchecked(LauncherInstrumentation.BACKGROUND_APP_STATE_ORDINAL);
|
||||
assertTrue("Overview not visible", mLauncher.getDevice().wait(
|
||||
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
|
||||
return new BaseOverview(mLauncher);
|
||||
}
|
||||
|
||||
|
||||
protected void goToOverviewUnchecked() {
|
||||
protected void goToOverviewUnchecked(int expectedState) {
|
||||
if (mLauncher.isSwipeUpEnabled()) {
|
||||
final int height = mLauncher.getDevice().getDisplayHeight();
|
||||
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
|
||||
|
||||
mLauncher.swipe(
|
||||
navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
|
||||
navBar.getVisibleBounds().centerX(), height - 400);
|
||||
navBar.getVisibleBounds().centerX(), height - 400,
|
||||
expectedState);
|
||||
} else {
|
||||
mLauncher.getSystemUiObject("recent_apps").click();
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public abstract class Home extends Background {
|
|||
@Override
|
||||
public Overview switchToOverview() {
|
||||
verifyActiveContainer();
|
||||
goToOverviewUnchecked();
|
||||
goToOverviewUnchecked(LauncherInstrumentation.OVERVIEW_STATE_ORDINAL);
|
||||
return new Overview(mLauncher);
|
||||
}
|
||||
}
|
|
@ -54,6 +54,9 @@ import java.util.concurrent.TimeoutException;
|
|||
public final class LauncherInstrumentation {
|
||||
|
||||
private static final String TAG = "Tapl";
|
||||
static final int OVERVIEW_STATE_ORDINAL = 2;
|
||||
static final int APPS_LIST_STATE_ORDINAL = 4;
|
||||
static final int BACKGROUND_APP_STATE_ORDINAL = 5;
|
||||
|
||||
// Types for launcher containers that the user is interacting with. "Background" is a
|
||||
// pseudo-container corresponding to inactive launcher covered by another app.
|
||||
|
@ -154,7 +157,7 @@ public final class LauncherInstrumentation {
|
|||
fail(message + ". " + "Actual: " + actual);
|
||||
}
|
||||
|
||||
static public void assertEquals(String message, int expected, int actual) {
|
||||
static private void assertEquals(String message, int expected, int actual) {
|
||||
if (expected != actual) {
|
||||
fail(message + " expected: " + expected + " but was: " + actual);
|
||||
}
|
||||
|
@ -416,12 +419,14 @@ public final class LauncherInstrumentation {
|
|||
return mDevice;
|
||||
}
|
||||
|
||||
void swipe(int startX, int startY, int endX, int endY) {
|
||||
executeAndWaitForEvent(
|
||||
void swipe(int startX, int startY, int endX, int endY, int expectedState) {
|
||||
final Bundle parcel = (Bundle) executeAndWaitForEvent(
|
||||
() -> mDevice.swipe(startX, startY, endX, endY, 60),
|
||||
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
|
||||
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
|
||||
+ ", " + endX + ", " + endY);
|
||||
assertEquals("Swipe switched launcher to a wrong state",
|
||||
expectedState, parcel.getInt(TestProtocol.STATE_FIELD));
|
||||
}
|
||||
|
||||
void waitForIdle() {
|
||||
|
|
|
@ -51,7 +51,8 @@ public final class Overview extends BaseOverview {
|
|||
final UiObject2 navBar = mLauncher.getSystemUiObject("navigation_bar_frame");
|
||||
final Point start = navBar.getVisibleCenter();
|
||||
LauncherInstrumentation.log("Overview.switchToAllApps before swipe");
|
||||
mLauncher.swipe(start.x, start.y, start.x, 0);
|
||||
mLauncher.swipe(
|
||||
start.x, start.y, start.x, 0, LauncherInstrumentation.APPS_LIST_STATE_ORDINAL);
|
||||
|
||||
return new AllAppsFromOverview(mLauncher);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,8 @@ public final class Workspace extends Home {
|
|||
start.x,
|
||||
start.y,
|
||||
start.x,
|
||||
endY
|
||||
endY,
|
||||
LauncherInstrumentation.APPS_LIST_STATE_ORDINAL
|
||||
);
|
||||
|
||||
return new AllApps(mLauncher);
|
||||
|
|
Loading…
Reference in New Issue