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 save requests. 69 */ 70 public static final Timeout SAVE_TIMEOUT = new Timeout("SAVE_TIMEOUT", 71 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 72 73 /** 74 * Timeout used when save is not expected to be shown - test will sleep for that amount of time 75 * as there is no callback that be received to assert it's not shown. 76 */ 77 public static final long SAVE_NOT_SHOWN_NAPTIME_MS = ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 78 79 /** 80 * Timeout for UI operations. Typically used by {@link UiBot}. 81 */ 82 public static final Timeout UI_TIMEOUT = new Timeout("UI_TIMEOUT", 83 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 84 85 /** 86 * Timeout for a11y window change events. 87 */ 88 public static final long WINDOW_CHANGE_TIMEOUT_MS = ONE_TIMEOUT_TO_RULE_THEN_ALL_MS; 89 90 /** 91 * Timeout used when an a11y window change events is not expected to be generated - test will 92 * sleep for that amount of time as there is no callback that be received to assert it's not 93 * shown. 94 */ 95 public static final long WINDOW_CHANGE_NOT_GENERATED_NAPTIME_MS = 96 ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 97 98 /** 99 * Timeout for webview operations. Typically used by {@link UiBot}. 100 */ 101 // TODO(b/80317628): switch back to ONE_TIMEOUT_TO_RULE_THEN_ALL_MS once fixed... 102 public static final Timeout WEBVIEW_TIMEOUT = new Timeout("WEBVIEW_TIMEOUT", 3_000, 2F, 5_000); 103 104 /** 105 * Timeout for showing the autofill dataset picker UI. 106 * 107 * <p>The value is usually higher than {@link #UI_TIMEOUT} because the performance of the 108 * dataset picker UI can be affect by external factors in some low-level devices. 109 * 110 * <p>Typically used by {@link UiBot}. 111 */ 112 public static final Timeout UI_DATASET_PICKER_TIMEOUT = new Timeout("UI_DATASET_PICKER_TIMEOUT", 113 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 114 115 /** 116 * Timeout used when the dataset picker is not expected to be shown - test will sleep for that 117 * amount of time as there is no callback that be received to assert it's not shown. 118 */ 119 public static final long DATASET_PICKER_NOT_SHOWN_NAPTIME_MS = ONE_NAPTIME_TO_RULE_THEN_ALL_MS; 120 121 /** 122 * Timeout (in milliseconds) for an activity to be brought out to top. 123 */ 124 public static final Timeout ACTIVITY_RESURRECTION = new Timeout("ACTIVITY_RESURRECTION", 125 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 126 127 /** 128 * Timeout for changing the screen orientation. 129 */ 130 public static final Timeout UI_SCREEN_ORIENTATION_TIMEOUT = new Timeout( 131 "UI_SCREEN_ORIENTATION_TIMEOUT", ONE_TIMEOUT_TO_RULE_THEN_ALL_MS, 2F, 132 ONE_TIMEOUT_TO_RULE_THEN_ALL_MS); 133 Timeouts()134 private Timeouts() { 135 throw new UnsupportedOperationException("contain static methods only"); 136 } 137 } 138