1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119<!DOCTYPE html>
120<html devsite>
121<head>
122
123
124    <meta name="top_category" value="develop" />
125
126    <meta name="subcategory" value="reference" />
127
128
129      <meta name="book_path" value="/reference/android/support/test/_book.yaml" />
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145<title>UiWatcher</title>
146
147
148</head>
149
150<body class="gc-documentation develop reference api apilevel-">
151<div id="doc-api-level" class="" style="display:none"></div>
152
153
154
155
156<div id="naMessage"></div>
157
158<div id="api-info-block">
159<div class="api-level">
160
161
162
163
164</div>
165
166
167
168
169<div class="sum-details-links">
170
171</div><!-- end sum-details-links -->
172</div><!-- end api-info-block -->
173
174<div class="api apilevel-" id="jd-content">
175
176<!-- ======== START OF CLASS DATA ======== -->
177
178<h1 class="api-title">UiWatcher</h1>
179<p>
180<code class="api-signature">
181  public
182
183
184
185  interface
186  UiWatcher
187</code>
188<br>
189
190
191<code class="api-signature">
192
193
194
195</code>
196
197</p><table class="jd-inheritance-table">
198
199
200  <tr>
201
202    <td colspan="1" class="jd-inheritance-class-cell">android.support.test.uiautomator.UiWatcher
203    </td>
204  </tr>
205
206
207</table>
208
209
210
211
212<br><hr>
213
214
215  <p>See <code><a href="/reference/android/support/test/uiautomator/UiDevice.html#registerWatcher(java.lang.String, android.support.test.uiautomator.UiWatcher)">registerWatcher(String, UiWatcher)</a></code> on how to register a
216 a condition watcher to be called by the automation library. The automation library will
217 invoke checkForCondition() only when a regular API call is in retry mode because it is unable
218 to locate its selector yet. Only during this time, the watchers are invoked to check if there is
219 something else unexpected on the screen.</p>
220
221
222
223
224
225
226
227<h2 class="api-section">Summary</h2>
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255<!-- ========== METHOD SUMMARY =========== -->
256<table id="pubmethods" class="responsive methods">
257<tr><th colspan="2"><h3>Public methods</h3></th></tr>
258
259
260
261
262  <tr class="api apilevel-" >
263
264
265    <td><code>
266        abstract
267
268
269
270
271        boolean</code>
272    </td>
273
274    <td width="100%">
275      <code>
276      <a href="/reference/android/support/test/uiautomator/UiWatcher.html#checkForCondition()">checkForCondition</a>()
277      </code>
278
279        <p>Custom handler that is automatically called when the testing framework is unable to
280 find a match using the <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code>
281
282 When the framework is in the process of matching a <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code> and it
283 is unable to match any widget based on the specified criteria in the selector,
284 the framework will perform retries for a predetermined time, waiting for the display
285 to update and show the desired widget.
286
287
288</p>
289
290    </td>
291  </tr>
292
293
294
295</table>
296
297
298
299
300
301
302
303
304<!-- XML Attributes -->
305
306
307<!-- Enum Values -->
308
309
310<!-- Constants -->
311
312
313<!-- Fields -->
314
315
316<!-- Public ctors -->
317
318
319
320<!-- ========= CONSTRUCTOR DETAIL ======== -->
321<!-- Protected ctors -->
322
323
324
325<!-- ========= METHOD DETAIL ======== -->
326<!-- Public methdos -->
327
328<h2 class="api-section">Public methods</h2>
329
330
331
332<A NAME="checkForCondition()"></A>
333
334<div class="api apilevel-">
335    <h3 class="api-name">checkForCondition</h3>
336    <div class="api-level">
337      <div></div>
338
339
340
341    </div>
342<pre class="api-signature no-pretty-print">
343boolean checkForCondition ()</pre>
344
345
346
347
348  <p>Custom handler that is automatically called when the testing framework is unable to
349 find a match using the <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code>
350
351 When the framework is in the process of matching a <code><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></code> and it
352 is unable to match any widget based on the specified criteria in the selector,
353 the framework will perform retries for a predetermined time, waiting for the display
354 to update and show the desired widget. While the framework is in this state, it will call
355 registered watchers' checkForCondition(). This gives the registered watchers a chance
356 to take a look at the display and see if there is a recognized condition that can be
357 handled and in doing so allowing the current test to continue.
358
359 An example usage would be to look for dialogs popped due to other background
360 processes requesting user attention and have nothing to do with the application
361 currently under test.</p>
362
363    <table class="responsive">
364      <tr><th colspan=2>Returns</th></tr>
365      <tr>
366        <td><code>boolean</code></td>
367        <td width="100%">true to indicate a matched condition or false for nothing was matched</td>
368      </tr>
369    </table>
370
371</div>
372
373
374
375
376
377<!-- ========= METHOD DETAIL ======== -->
378
379
380
381<!-- ========= END OF CLASS DATA ========= -->
382
383</div><!-- end jd-content -->
384
385
386
387<div class="data-reference-resources-wrapper">
388
389  <ul data-reference-resources>
390
391
392    <li><h2>Interfaces</h2>
393      <ul>
394          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/IAutomationSupport.html">IAutomationSupport</a></li>
395          <li class="selected api apilevel-"><a href="/reference/android/support/test/uiautomator/UiWatcher.html">UiWatcher</a></li>
396      </ul>
397    </li>
398
399    <li><h2>Classes</h2>
400      <ul>
401          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/By.html">By</a></li>
402          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/BySelector.html">BySelector</a></li>
403          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Configurator.html">Configurator</a></li>
404          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/EventCondition.html">EventCondition</a></li>
405          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/SearchCondition.html">SearchCondition</a></li>
406          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiAutomatorInstrumentationTestRunner.html">UiAutomatorInstrumentationTestRunner</a></li>
407          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiAutomatorTestCase.html">UiAutomatorTestCase</a></li>
408          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiCollection.html">UiCollection</a></li>
409          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiDevice.html">UiDevice</a></li>
410          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject.html">UiObject</a></li>
411          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject2.html">UiObject2</a></li>
412          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObject2Condition.html">UiObject2Condition</a></li>
413          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiScrollable.html">UiScrollable</a></li>
414          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiSelector.html">UiSelector</a></li>
415          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Until.html">Until</a></li>
416      </ul>
417    </li>
418
419    <li><h2>Enums</h2>
420      <ul>
421          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/Direction.html">Direction</a></li>
422      </ul>
423    </li>
424
425    <li><h2>Exceptions</h2>
426      <ul>
427          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/StaleObjectException.html">StaleObjectException</a></li>
428          <li class="api apilevel-"><a href="/reference/android/support/test/uiautomator/UiObjectNotFoundException.html">UiObjectNotFoundException</a></li>
429      </ul>
430    </li>
431
432  </ul>
433
434</div>
435
436
437
438</body>
439</html>
440