1 /* 2 * Copyright (C) 2017 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 android.autofillservice.cts.testcore; 18 19 import com.android.compatibility.common.util.Timeout; 20 21 /** 22 * Timeouts for common tasks. 23 */ 24 public final class Timeouts { 25 26 private static final long ONE_TIMEOUT_TO_RULE_THEN_ALL_MS = 20_000; 27 private static final long ONE_NAPTIME_TO_RULE_THEN_ALL_MS = 2_000; 28 29 public static final long MOCK_IME_TIMEOUT_MS = 5_000; 30 public static final long DRAWABLE_TIMEOUT_MS = 5_000; 31 32 public static final long LONG_PRESS_MS = 3000; 33 public static final long RESPONSE_DELAY_MS = 1000; 34 35 /** 36 * Timeout until framework binds / unbinds from service. 37 */ 38 public static final Timeout CONNECTION_TIMEOUT = new Timeout("CONNECTION_TIMEOUT", 39 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 40 41 /** 42 * Timeout for {@link MyAutofillCallback#assertNotCalled()} - test will sleep for that amount of 43 * time as there is no callback that be received to assert it's not shown. 44 */ 45 public static final long CALLBACK_NOT_CALLED_TIMEOUT_MS = ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 46 47 /** 48 * Timeout until framework unbinds from a service. 49 */ 50 // TODO: must be higher than RemoteFillService.TIMEOUT_IDLE_BIND_MILLIS, so we should use a 51 // @hidden @Testing constants instead... 52 public static final Timeout IDLE_UNBIND_TIMEOUT = new Timeout("IDLE_UNBIND_TIMEOUT", 53 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 54 55 /** 56 * Timeout to get the expected number of fill events. 57 */ 58 public static final Timeout FILL_EVENTS_TIMEOUT = new Timeout("FILL_EVENTS_TIMEOUT", 59 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 60 61 /** 62 * Timeout for expected autofill requests. 63 */ 64 public static final Timeout FILL_TIMEOUT = new Timeout("FILL_TIMEOUT", 65 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 66 67 /** 68 * Timeout for expected field classification requests. 69 * 70 * (May need to tune based on how much time it takes for field classification request to 71 * trigger) 72 */ 73 public static final Timeout FIELD_CLASSIFICATION_TIMEOUT = 74 new Timeout("FIELD_CLASSIFICATION_TIMEOUT", 75 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 76 77 /** 78 * Timeout for expected save requests. 79 */ 80 public static final Timeout SAVE_TIMEOUT = new Timeout("SAVE_TIMEOUT", 81 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 82 83 /** 84 * Timeout used when save is not expected to be shown - test will sleep for that amount of time 85 * as there is no callback that be received to assert it's not shown. 86 */ 87 public static final long SAVE_NOT_SHOWN_NAPTIME_MS = ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 88 89 /** 90 * Timeout for UI operations. Typically used by {@link UiBot}. 91 */ 92 public static final Timeout UI_TIMEOUT = new Timeout("UI_TIMEOUT", 93 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 94 95 /** 96 * Timeout for a11y window change events. 97 */ 98 public static final long WINDOW_CHANGE_TIMEOUT_MS = ONE_TIMEOUT_TO_RULE_THEN_ALL_MS; 99 100 /** 101 * Timeout used when an a11y window change events is not expected to be generated - test will 102 * sleep for that amount of time as there is no callback that be received to assert it's not 103 * shown. 104 */ 105 public static final long WINDOW_CHANGE_NOT_GENERATED_NAPTIME_MS = 106 ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 107 108 /** 109 * Timeout for webview operations. Typically used by {@link UiBot}. 110 */ 111 // TODO(b/80317628): switch back to ONE_TIMEOUT_TO_RULE_THEN_ALL_MS once fixed... 112 public static final Timeout WEBVIEW_TIMEOUT = new Timeout("WEBVIEW_TIMEOUT", 3_000, 2F, 5_000); 113 114 /** 115 * Timeout for showing the autofill dataset picker UI. 116 * 117 * <p>The value is usually higher than {@link #UI_TIMEOUT} because the performance of the 118 * dataset picker UI can be affect by external factors in some low-level devices. 119 * 120 * <p>Typically used by {@link UiBot}. 121 */ 122 public static final Timeout UI_DATASET_PICKER_TIMEOUT = new Timeout("UI_DATASET_PICKER_TIMEOUT", 123 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 124 125 /** 126 * Timeout used when the dataset picker is not expected to be shown - test will sleep for that 127 * amount of time as there is no callback that be received to assert it's not shown. 128 */ 129 public static final long DATASET_PICKER_NOT_SHOWN_NAPTIME_MS = ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 130 131 /** 132 * Timeout (in milliseconds) for an activity to be brought out to top. 133 */ 134 public static final Timeout ACTIVITY_RESURRECTION = new Timeout("ACTIVITY_RESURRECTION", 135 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 136 137 /** 138 * Timeout for changing the screen orientation. 139 */ 140 public static final Timeout UI_SCREEN_ORIENTATION_TIMEOUT = new Timeout( 141 "UI_SCREEN_ORIENTATION_TIMEOUT", ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, 142 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 143 144 /** 145 * Timeout for changing the mock ime status. 146 */ 147 public static final Timeout MOCK_IME_TIMEOUT = new Timeout( 148 "MOCK_IME_TIMEOUT", MOCK_IME_TIMEOUT_MS, 2F, MOCK_IME_TIMEOUT_MS); 149 Timeouts()150 private Timeouts() { 151 throw new UnsupportedOperationException("contain static methods only"); 152 } 153 } 154