• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>UiThreadTestRule</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
170
171
172
173
174
175
176
177
178
179
180
181
182
183<div class="sum-details-links">
184
185Summary:
186
187
188
189
190
191
192
193
194
195  <a href="#pubctors">Ctors</a>
196
197
198
199
200  &#124; <a href="#pubmethods">Methods</a>
201
202
203
204  &#124; <a href="#promethods">Protected Methods</a>
205
206
207
208  &#124; <a href="#inhmethods">Inherited Methods</a>
209
210&#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
211
212</div><!-- end sum-details-links -->
213</div><!-- end api-info-block -->
214
215<div class="api apilevel-" id="jd-content">
216
217<!-- ======== START OF CLASS DATA ======== -->
218
219<h1 class="api-title">UiThreadTestRule</h1>
220<p>
221<code class="api-signature">
222  public
223
224
225
226  class
227  UiThreadTestRule
228</code>
229<br>
230
231
232<code class="api-signature">
233
234    extends Object
235
236
237
238</code>
239
240<code class="api-signature">
241
242
243      implements
244
245        TestRule
246
247
248
249</code>
250
251</p><table class="jd-inheritance-table">
252
253
254  <tr>
255
256    <td colspan="2" class="jd-inheritance-class-cell">java.lang.Object
257    </td>
258  </tr>
259
260
261  <tr>
262
263      <td class="jd-inheritance-space">&nbsp;&nbsp;&nbsp;&#x21b3;</td>
264
265    <td colspan="1" class="jd-inheritance-class-cell">android.support.test.rule.UiThreadTestRule
266    </td>
267  </tr>
268
269
270</table>
271  <table class="jd-sumtable jd-sumtable-subclasses">
272  <tr><td style="border:none;margin:0;padding:0;">
273
274  <a href="#" onclick="return toggleInherited(this, null)" id="subclasses-direct" class="jd-expando-trigger closed"
275          ><img height="34" id="subclasses-direct-trigger"
276          src="/assets/images/styles/disclosure_down.png"
277          class="jd-expando-trigger-img" /></a>Known Direct Subclasses
278
279  <div id="subclasses-direct">
280      <div id="subclasses-direct-list"
281              class="jd-inheritedlinks"
282
283              >
284
285
286              <a href="/reference/android/support/test/rule/ActivityTestRule.html">ActivityTestRule</a>&lt;T&nbsp;extends&nbsp;Activity&gt;
287
288
289      </div>
290      <div id="subclasses-direct-summary"
291              style="display: none;"
292              >
293
294  <table class="jd-sumtable-expando">
295
296      <tr class="alt-color api apilevel-" >
297        <td class="jd-linkcol"><a href="/reference/android/support/test/rule/ActivityTestRule.html">ActivityTestRule</a>&lt;T&nbsp;extends&nbsp;Activity&gt;</td>
298        <td class="jd-descrcol" width="100%">
299          This rule provides functional testing of a single activity.&nbsp;
300
301
302
303        </td>
304      </tr>
305
306
307  </table>
308
309      </div>
310  </div>
311  </td></tr>
312  </table>
313
314
315  <table class="jd-sumtable jd-sumtable-subclasses"><tr><td colspan="2" style="border:none;margin:0;padding:0;">
316
317  <a href="#" onclick="return toggleInherited(this, null)" id="subclasses-indirect" class="jd-expando-trigger closed"
318          ><img height="34" id="subclasses-indirect-trigger"
319          src="/assets/images/styles/disclosure_down.png"
320          class="jd-expando-trigger-img" /></a>Known Indirect Subclasses
321
322  <div id="subclasses-indirect">
323      <div id="subclasses-indirect-list"
324              class="jd-inheritedlinks"
325
326              >
327
328
329              <a href="/reference/android/support/test/espresso/intent/rule/IntentsTestRule.html">IntentsTestRule</a>&lt;T&nbsp;extends&nbsp;Activity&gt;
330
331
332      </div>
333      <div id="subclasses-indirect-summary"
334              style="display: none;"
335              >
336
337  <table class="jd-sumtable-expando">
338
339      <tr class="alt-color api apilevel-" >
340        <td class="jd-linkcol"><a href="/reference/android/support/test/espresso/intent/rule/IntentsTestRule.html">IntentsTestRule</a>&lt;T&nbsp;extends&nbsp;Activity&gt;</td>
341        <td class="jd-descrcol" width="100%">
342          This rule makes it easy to use Espresso-Intents APIs in functional UI tests.&nbsp;
343
344
345
346        </td>
347      </tr>
348
349
350  </table>
351
352      </div>
353  </div>
354  </td></tr></table>
355
356
357
358<br><hr>
359
360
361  <p>This rule allows the test method annotated with <code><a href="/reference/android/support/test/annotation/UiThreadTest.html">UiThreadTest</a></code> to execute on the
362 application's main thread (or UI thread).
363 <p/>
364 Note, methods annotated with
365 <a href="http://junit.sourceforge.net/javadoc/org/junit/Before.html"><code>Before</code></a> and
366 <a href="http://junit.sourceforge.net/javadoc/org/junit/After.html"><code>After</code></a> will
367 also be executed on the UI thread.</p>
368
369
370
371  <div>
372      <p><b>See also:</b></p>
373      <ul class="nolist"><li><code><a href="/reference/android/support/test/annotation/UiThreadTest.html">UiThreadTest</a></code></li>
374      </ul>
375  </div>
376
377
378
379
380<h2 class="api-section">Summary</h2>
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404<!-- ======== CONSTRUCTOR SUMMARY ======== -->
405<table id="pubctors" class="responsive constructors">
406<tr><th colspan="2"><h3>Public constructors</h3></th></tr>
407
408
409
410
411  <tr class="api apilevel-" >
412
413
414    <td width="100%">
415      <code>
416      <a href="/reference/android/support/test/rule/UiThreadTestRule.html#UiThreadTestRule()">UiThreadTestRule</a>()
417      </code>
418
419    </td>
420  </tr>
421
422
423
424</table>
425
426
427
428
429
430
431<!-- ========== METHOD SUMMARY =========== -->
432<table id="pubmethods" class="responsive methods">
433<tr><th colspan="2"><h3>Public methods</h3></th></tr>
434
435
436
437
438  <tr class="api apilevel-" >
439
440
441    <td><code>
442
443
444
445
446
447        Statement</code>
448    </td>
449
450    <td width="100%">
451      <code>
452      <a href="/reference/android/support/test/rule/UiThreadTestRule.html#apply(org.junit.runners.model.Statement, org.junit.runner.Description)">apply</a>(Statement base, Description description)
453      </code>
454
455    </td>
456  </tr>
457
458
459
460  <tr class="api apilevel-" >
461
462
463    <td><code>
464
465
466
467
468
469        void</code>
470    </td>
471
472    <td width="100%">
473      <code>
474      <a href="/reference/android/support/test/rule/UiThreadTestRule.html#runOnUiThread(java.lang.Runnable)">runOnUiThread</a>(Runnable runnable)
475      </code>
476
477        <p>Helper for running portions of a test on the UI thread.
478
479
480</p>
481
482    </td>
483  </tr>
484
485
486
487</table>
488
489
490
491
492<!-- ========== METHOD SUMMARY =========== -->
493<table id="promethods" class="reponsive methods">
494<tr><th colspan="2"><h3>Protected methods</h3></th></tr>
495
496
497
498
499  <tr class="api apilevel-" >
500
501
502    <td><code>
503
504
505
506
507
508        boolean</code>
509    </td>
510
511    <td width="100%">
512      <code>
513      <a href="/reference/android/support/test/rule/UiThreadTestRule.html#shouldRunOnUiThread(org.junit.runner.Description)">shouldRunOnUiThread</a>(Description description)
514      </code>
515
516    </td>
517  </tr>
518
519
520
521</table>
522
523
524
525
526
527<!-- ========== METHOD SUMMARY =========== -->
528<table id="inhmethods" class="methods inhtable">
529<tr><th><h3>Inherited methods</h3></th></tr>
530
531
532<tr class="api apilevel-" >
533<td colspan="2">
534
535  <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-java.lang.Object" class="jd-expando-trigger closed"
536          ><img height="34" id="inherited-methods-java.lang.Object-trigger"
537          src="/assets/images/styles/disclosure_down.png"
538          class="jd-expando-trigger-img" /></a>From
539class
540<code>
541
542    java.lang.Object
543
544</code>
545<div id="inherited-methods-java.lang.Object">
546  <div id="inherited-methods-java.lang.Object-list"
547        class="jd-inheritedlinks">
548  </div>
549  <div id="inherited-methods-java.lang.Object-summary" style="display: none;">
550    <table class="jd-sumtable-expando responsive">
551
552
553
554
555  <tr class="api apilevel-" >
556
557
558    <td><code>
559
560
561
562
563
564        Object</code>
565    </td>
566
567    <td width="100%">
568      <code>
569      clone()
570      </code>
571
572    </td>
573  </tr>
574
575
576
577  <tr class="api apilevel-" >
578
579
580    <td><code>
581
582
583
584
585
586        boolean</code>
587    </td>
588
589    <td width="100%">
590      <code>
591      equals(Object arg0)
592      </code>
593
594    </td>
595  </tr>
596
597
598
599  <tr class="api apilevel-" >
600
601
602    <td><code>
603
604
605
606
607
608        void</code>
609    </td>
610
611    <td width="100%">
612      <code>
613      finalize()
614      </code>
615
616    </td>
617  </tr>
618
619
620
621  <tr class="api apilevel-" >
622
623
624    <td><code>
625
626
627
628        final
629
630        Class&lt;?&gt;</code>
631    </td>
632
633    <td width="100%">
634      <code>
635      getClass()
636      </code>
637
638    </td>
639  </tr>
640
641
642
643  <tr class="api apilevel-" >
644
645
646    <td><code>
647
648
649
650
651
652        int</code>
653    </td>
654
655    <td width="100%">
656      <code>
657      hashCode()
658      </code>
659
660    </td>
661  </tr>
662
663
664
665  <tr class="api apilevel-" >
666
667
668    <td><code>
669
670
671
672        final
673
674        void</code>
675    </td>
676
677    <td width="100%">
678      <code>
679      notify()
680      </code>
681
682    </td>
683  </tr>
684
685
686
687  <tr class="api apilevel-" >
688
689
690    <td><code>
691
692
693
694        final
695
696        void</code>
697    </td>
698
699    <td width="100%">
700      <code>
701      notifyAll()
702      </code>
703
704    </td>
705  </tr>
706
707
708
709  <tr class="api apilevel-" >
710
711
712    <td><code>
713
714
715
716
717
718        String</code>
719    </td>
720
721    <td width="100%">
722      <code>
723      toString()
724      </code>
725
726    </td>
727  </tr>
728
729
730
731  <tr class="api apilevel-" >
732
733
734    <td><code>
735
736
737
738        final
739
740        void</code>
741    </td>
742
743    <td width="100%">
744      <code>
745      wait(long arg0, int arg1)
746      </code>
747
748    </td>
749  </tr>
750
751
752
753  <tr class="api apilevel-" >
754
755
756    <td><code>
757
758
759
760        final
761
762        void</code>
763    </td>
764
765    <td width="100%">
766      <code>
767      wait(long arg0)
768      </code>
769
770    </td>
771  </tr>
772
773
774
775  <tr class="api apilevel-" >
776
777
778    <td><code>
779
780
781
782        final
783
784        void</code>
785    </td>
786
787    <td width="100%">
788      <code>
789      wait()
790      </code>
791
792    </td>
793  </tr>
794
795
796
797    </table>
798  </div>
799</div>
800</td></tr>
801
802
803
804<tr class="api apilevel-" >
805<td colspan="2">
806
807  <a href="#" onclick="return toggleInherited(this, null)" id="inherited-methods-org.junit.rules.TestRule" class="jd-expando-trigger closed"
808          ><img height="34" id="inherited-methods-org.junit.rules.TestRule-trigger"
809          src="/assets/images/styles/disclosure_down.png"
810          class="jd-expando-trigger-img" /></a>From
811interface
812<code>
813
814    org.junit.rules.TestRule
815
816</code>
817<div id="inherited-methods-org.junit.rules.TestRule">
818  <div id="inherited-methods-org.junit.rules.TestRule-list"
819        class="jd-inheritedlinks">
820  </div>
821  <div id="inherited-methods-org.junit.rules.TestRule-summary" style="display: none;">
822    <table class="jd-sumtable-expando responsive">
823
824
825
826
827  <tr class="api apilevel-" >
828
829
830    <td><code>
831        abstract
832
833
834
835
836        Statement</code>
837    </td>
838
839    <td width="100%">
840      <code>
841      apply(Statement arg0, Description arg1)
842      </code>
843
844    </td>
845  </tr>
846
847
848
849    </table>
850  </div>
851</div>
852</td></tr>
853
854
855</table>
856
857
858
859<!-- XML Attributes -->
860
861
862<!-- Enum Values -->
863
864
865<!-- Constants -->
866
867
868<!-- Fields -->
869
870
871<!-- Public ctors -->
872
873
874<!-- ========= CONSTRUCTOR DETAIL ======== -->
875<h2 class="api-section">Public constructors</h2>
876
877
878
879<A NAME="UiThreadTestRule()"></A>
880
881<div class="api apilevel-">
882    <h3 class="api-name">UiThreadTestRule</h3>
883    <div class="api-level">
884      <div></div>
885
886
887
888    </div>
889<pre class="api-signature no-pretty-print">
890UiThreadTestRule ()</pre>
891
892
893
894
895  <p></p>
896
897</div>
898
899
900
901
902
903<!-- ========= CONSTRUCTOR DETAIL ======== -->
904<!-- Protected ctors -->
905
906
907
908<!-- ========= METHOD DETAIL ======== -->
909<!-- Public methdos -->
910
911<h2 class="api-section">Public methods</h2>
912
913
914
915<A NAME="apply(org.junit.runners.model.Statement, org.junit.runner.Description)"></A>
916
917<div class="api apilevel-">
918    <h3 class="api-name">apply</h3>
919    <div class="api-level">
920      <div></div>
921
922
923
924    </div>
925<pre class="api-signature no-pretty-print">
926Statement apply (Statement base,
927                Description description)</pre>
928
929
930
931
932  <p></p>
933    <table class="responsive">
934    <tr><th colspan=2>Parameters</th></tr>
935      <tr>
936        <td><code>base</code></td>
937        <td width="100%">
938          <code>Statement</code>
939          <!-- no parameter comment --></td>
940      </tr>
941      <tr>
942        <td><code>description</code></td>
943        <td width="100%">
944          <code>Description</code>
945          <!-- no parameter comment --></td>
946      </tr>
947    </table>
948    <table class="responsive">
949      <tr><th colspan=2>Returns</th></tr>
950      <tr>
951        <td><code>Statement</code></td>
952        <td width="100%"><!-- no returns description in source --></td>
953      </tr>
954    </table>
955
956</div>
957
958
959<A NAME="runOnUiThread(java.lang.Runnable)"></A>
960
961<div class="api apilevel-">
962    <h3 class="api-name">runOnUiThread</h3>
963    <div class="api-level">
964      <div></div>
965
966
967
968    </div>
969<pre class="api-signature no-pretty-print">
970void runOnUiThread (Runnable runnable)</pre>
971
972
973
974
975  <p>Helper for running portions of a test on the UI thread.
976 <p/>
977 Note, in most cases it is simpler to annotate the test method with
978 <code><a href="/reference/android/support/test/annotation/UiThreadTest.html">UiThreadTest</a></code>, which will run the entire test method including methods annotated with
979 <a href="http://junit.sourceforge.net/javadoc/org/junit/Before.html"><code>Before</code></a>
980 and <a href="http://junit.sourceforge.net/javadoc/org/junit/After.html">
981 <code>After</code></a> on the UI thread.
982 <p/>
983 Use this method if you need to switch in and out of the UI thread to perform your test.</p>
984    <table class="responsive">
985    <tr><th colspan=2>Parameters</th></tr>
986      <tr>
987        <td><code>runnable</code></td>
988        <td width="100%">
989          <code>Runnable</code>:
990          runnable containing test code in the <code><a href="/reference/java/lang/Runnable.html#run()">run()</a></code> method</td>
991      </tr>
992    </table>
993      <table class="responsive">
994      <tr><th colspan=2>Throws</th></tr>
995        <tr>
996          <td><code>Throwable</code></td>
997          <td width="100%"></td>
998        </tr>
999      </table>
1000
1001  <div>
1002      <p><b>See also:</b></p>
1003      <ul class="nolist"><li><code><a href="/reference/android/support/test/annotation/UiThreadTest.html">UiThreadTest</a></code></li>
1004      </ul>
1005  </div>
1006
1007</div>
1008
1009
1010
1011
1012
1013<!-- ========= METHOD DETAIL ======== -->
1014
1015<h2 class="api-section">Protected methods</h2>
1016
1017
1018
1019<A NAME="shouldRunOnUiThread(org.junit.runner.Description)"></A>
1020
1021<div class="api apilevel-">
1022    <h3 class="api-name">shouldRunOnUiThread</h3>
1023    <div class="api-level">
1024      <div></div>
1025
1026
1027
1028    </div>
1029<pre class="api-signature no-pretty-print">
1030boolean shouldRunOnUiThread (Description description)</pre>
1031
1032
1033
1034
1035  <p></p>
1036    <table class="responsive">
1037    <tr><th colspan=2>Parameters</th></tr>
1038      <tr>
1039        <td><code>description</code></td>
1040        <td width="100%">
1041          <code>Description</code>
1042          <!-- no parameter comment --></td>
1043      </tr>
1044    </table>
1045    <table class="responsive">
1046      <tr><th colspan=2>Returns</th></tr>
1047      <tr>
1048        <td><code>boolean</code></td>
1049        <td width="100%"><!-- no returns description in source --></td>
1050      </tr>
1051    </table>
1052
1053</div>
1054
1055
1056
1057
1058
1059<!-- ========= END OF CLASS DATA ========= -->
1060
1061</div><!-- end jd-content -->
1062
1063
1064
1065<div class="data-reference-resources-wrapper">
1066
1067  <ul data-reference-resources>
1068
1069
1070
1071    <li><h2>Classes</h2>
1072      <ul>
1073          <li class="api apilevel-"><a href="/reference/android/support/test/rule/ActivityTestRule.html">ActivityTestRule</a></li>
1074          <li class="api apilevel-"><a href="/reference/android/support/test/rule/DisableOnAndroidDebug.html">DisableOnAndroidDebug</a></li>
1075          <li class="api apilevel-"><a href="/reference/android/support/test/rule/ServiceTestRule.html">ServiceTestRule</a></li>
1076          <li class="selected api apilevel-"><a href="/reference/android/support/test/rule/UiThreadTestRule.html">UiThreadTestRule</a></li>
1077      </ul>
1078    </li>
1079
1080
1081
1082  </ul>
1083
1084</div>
1085
1086
1087
1088</body>
1089</html>
1090