Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6398a1e authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Sharing protocol constants between Launcher and TAPL

Bug: 110103162
Test: TaplTests
Change-Id: I5b2a2b8576a7a6ea4a156f00858711496d6b5bba
parent e1c4a906
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimationSuccessListener;
@@ -233,7 +234,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
                // Optimization, hide the all apps view to prevent layout while initializing
                activity.getAppsView().getContentView().setVisibility(View.GONE);

                AccessibilityManagerCompat.sendEventToTest(activity, "TAPL_WENT_TO_STATE");
                AccessibilityManagerCompat.sendEventToTest(
                        activity, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
            }

            return new AnimationFactory() {
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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;

/**
 * Protocol for custom accessibility events for communication with UI Automation tests.
 */
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 SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
    public static final String RESPONSE_MESSAGE_POSTFIX = "_RESPONSE";
}
+4 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@@ -576,9 +577,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
    @Override
    public boolean performAccessibilityAction(int action, Bundle arguments) {
        if (AccessibilityManagerCompat.processTestRequest(
                mLauncher, "TAPL_GET_SCROLL", action, arguments,
                mLauncher, TestProtocol.GET_SCROLL_MESSAGE, action, arguments,
                response ->
                        response.putInt("scrollY", getActiveRecyclerView().getCurrentScrollY()))) {
                        response.putInt(TestProtocol.SCROLL_Y_FIELD,
                                getActiveRecyclerView().getCurrentScrollY()))) {
            return true;
        }

+2 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;

import com.android.launcher3.TestProtocol;
import com.android.launcher3.Utilities;

public class AccessibilityManagerCompat {
@@ -95,7 +96,7 @@ public class AccessibilityManagerCompat {
            final Bundle response = new Bundle();
            responseFiller.accept(response);
            AccessibilityManagerCompat.sendEventToTest(
                    accessibilityManager, eventTag + "_RESPONSE", response);
                    accessibilityManager, eventTag + TestProtocol.RESPONSE_MESSAGE_POSTFIX, response);
            return true;
        }
        return false;
+3 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationComponents;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -517,7 +518,8 @@ public abstract class AbstractStateChangeTouchController
            }
            mLauncher.getStateManager().goToState(targetState, false /* animated */);

            AccessibilityManagerCompat.sendEventToTest(mLauncher, "TAPL_WENT_TO_STATE");
            AccessibilityManagerCompat.sendEventToTest(
                    mLauncher, TestProtocol.SWITCHED_TO_STATE_MESSAGE);
        }
    }

Loading