1 /* 2 * Copyright (C) 2012 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 package com.android.uiautomator.core; 17 18 /** 19 * See {@link UiDevice#registerWatcher(String, UiWatcher)} on how to register a 20 * a condition watcher to be called by the automation library. The automation library will 21 * invoke checkForCondition() only when a regular API call is in retry mode because it is unable 22 * to locate its selector yet. Only during this time, the watchers are invoked to check if there is 23 * something else unexpected on the screen. 24 * @since API Level 16 25 * @deprecated New tests should be written using UI Automator 2.0 which is available as part of the 26 * Android Testing Support Library. 27 */ 28 @Deprecated 29 public interface UiWatcher { 30 31 /** 32 * Custom handler that is automatically called when the testing framework is unable to 33 * find a match using the {@link UiSelector} 34 * 35 * When the framework is in the process of matching a {@link UiSelector} and it 36 * is unable to match any widget based on the specified criteria in the selector, 37 * the framework will perform retries for a predetermined time, waiting for the display 38 * to update and show the desired widget. While the framework is in this state, it will call 39 * registered watchers' checkForCondition(). This gives the registered watchers a chance 40 * to take a look at the display and see if there is a recognized condition that can be 41 * handled and in doing so allowing the current test to continue. 42 * 43 * An example usage would be to look for dialogs popped due to other background 44 * processes requesting user attention and have nothing to do with the application 45 * currently under test. 46 * 47 * @return true to indicate a matched condition or false for nothing was matched 48 * @since API Level 16 49 */ checkForCondition()50 public boolean checkForCondition(); 51 } 52