1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.launcher3.testing;
18 
19 /**
20  * Protocol for custom accessibility events for communication with UI Automation tests.
21  */
22 public final class TestProtocol {
23     public static final String STATE_FIELD = "state";
24     public static final String SWITCHED_TO_STATE_MESSAGE = "TAPL_SWITCHED_TO_STATE";
25     public static final String SCROLL_FINISHED_MESSAGE = "TAPL_SCROLL_FINISHED";
26     public static final String PAUSE_DETECTED_MESSAGE = "TAPL_PAUSE_DETECTED";
27     public static final int NORMAL_STATE_ORDINAL = 0;
28     public static final int SPRING_LOADED_STATE_ORDINAL = 1;
29     public static final int OVERVIEW_STATE_ORDINAL = 2;
30     public static final int OVERVIEW_PEEK_STATE_ORDINAL = 3;
31     public static final int OVERVIEW_MODAL_TASK_STATE_ORDINAL = 4;
32     public static final int QUICK_SWITCH_STATE_ORDINAL = 5;
33     public static final int ALL_APPS_STATE_ORDINAL = 6;
34     public static final int BACKGROUND_APP_STATE_ORDINAL = 7;
35     public static final int HINT_STATE_ORDINAL = 8;
36     public static final String TAPL_EVENTS_TAG = "TaplEvents";
37     public static final String SEQUENCE_MAIN = "Main";
38     public static final String SEQUENCE_TIS = "TIS";
39     public static final String SEQUENCE_PILFER = "Pilfer";
40 
stateOrdinalToString(int ordinal)41     public static String stateOrdinalToString(int ordinal) {
42         switch (ordinal) {
43             case NORMAL_STATE_ORDINAL:
44                 return "Normal";
45             case SPRING_LOADED_STATE_ORDINAL:
46                 return "SpringLoaded";
47             case OVERVIEW_STATE_ORDINAL:
48                 return "Overview";
49             case OVERVIEW_PEEK_STATE_ORDINAL:
50                 return "OverviewPeek";
51             case OVERVIEW_MODAL_TASK_STATE_ORDINAL:
52                 return "OverviewModal";
53             case QUICK_SWITCH_STATE_ORDINAL:
54                 return "QuickSwitch";
55             case ALL_APPS_STATE_ORDINAL:
56                 return "AllApps";
57             case BACKGROUND_APP_STATE_ORDINAL:
58                 return "Background";
59             case HINT_STATE_ORDINAL:
60                 return "Hint";
61             default:
62                 return "Unknown";
63         }
64     }
65 
66     public static final String TEST_INFO_RESPONSE_FIELD = "response";
67 
68     public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT =
69             "home-to-overview-swipe-height";
70     public static final String REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT =
71             "background-to-overview-swipe-height";
72     public static final String REQUEST_ALL_APPS_TO_OVERVIEW_SWIPE_HEIGHT =
73             "all-apps-to-overview-swipe-height";
74     public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
75             "home-to-all-apps-swipe-height";
76     public static final String REQUEST_ICON_HEIGHT =
77             "icon-height";
78     public static final String REQUEST_HOTSEAT_TOP = "hotseat-top";
79     public static final String REQUEST_IS_LAUNCHER_INITIALIZED = "is-launcher-initialized";
80     public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list";
81     public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
82     public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
83     public static final String REQUEST_APPS_LIST_SCROLL_Y = "apps-list-scroll-y";
84     public static final String REQUEST_WINDOW_INSETS = "window-insets";
85     public static final String REQUEST_PID = "pid";
86     public static final String REQUEST_TOTAL_PSS_KB = "total_pss";
87     public static final String REQUEST_JAVA_LEAK = "java-leak";
88     public static final String REQUEST_NATIVE_LEAK = "native-leak";
89     public static final String REQUEST_VIEW_LEAK = "view-leak";
90     public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list";
91     public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging";
92     public static final String REQUEST_GET_TEST_EVENTS = "get-test-events";
93     public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
94     public static final String REQUEST_CLEAR_DATA = "clear-data";
95 
96     public static boolean sDebugTracing = false;
97     public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
98     public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing";
99 
100     public static final String REQUEST_OVERVIEW_ACTIONS_ENABLED = "overview-actions-enabled";
101 
102     public static boolean sDisableSensorRotation;
103     public static final String REQUEST_MOCK_SENSOR_ROTATION = "mock-sensor-rotation";
104 
105     public static final String PERMANENT_DIAG_TAG = "TaplTarget";
106     public static final String PAUSE_NOT_DETECTED = "b/139891609";
107     public static final String OVERIEW_NOT_ALLAPPS = "b/156095088";
108     public static final String NO_SWIPE_TO_HOME = "b/158017601";
109 }
110