@@ -101,13 +101,15 @@ public void testNoKey() throws Throwable {
101101 final UploadOptions opt = new UploadOptions (params , null , true , null , null );
102102 runTestOnUiThread (new Runnable () { // THIS IS THE KEY TO SUCCESS
103103 public void run () {
104+ final Thread t = Thread .currentThread ();
104105 uploadManager .put ("hello" .getBytes (), expectKey , TestConfig .token , new UpCompletionHandler () {
105106 public void complete (String k , ResponseInfo rinfo , JSONObject response ) {
106107 Log .i ("qiniutest" , k + rinfo );
107108 key = k ;
108109 info = rinfo ;
109110 resp = response ;
110111 signal .countDown ();
112+ Assert .assertSame ("not in ui thread" , t , Thread .currentThread ());
111113 }
112114 }, opt );
113115 }
@@ -133,13 +135,15 @@ public void testInvalidToken() throws Throwable {
133135 final String expectKey = "你好" ;
134136 runTestOnUiThread (new Runnable () { // THIS IS THE KEY TO SUCCESS
135137 public void run () {
138+ final Thread t = Thread .currentThread ();
136139 uploadManager .put ("hello" .getBytes (), expectKey , "invalid" , new UpCompletionHandler () {
137140 public void complete (String k , ResponseInfo rinfo , JSONObject response ) {
138141 Log .i ("qiniutest" , k + rinfo );
139142 key = k ;
140143 info = rinfo ;
141144 resp = response ;
142145 signal .countDown ();
146+ Assert .assertSame ("not in ui thread" , t , Thread .currentThread ());
143147 }
144148 }, null );
145149 }
@@ -188,6 +192,9 @@ public void complete(String k, ResponseInfo rinfo, JSONObject response) {
188192 public void testNoToken () throws Throwable {
189193 final String expectKey = "你好" ;
190194 runTestOnUiThread (new Runnable () { // THIS IS THE KEY TO SUCCESS
195+
196+ final Thread t = Thread .currentThread ();
197+
191198 public void run () {
192199 uploadManager .put (new byte [1 ], expectKey , null , new UpCompletionHandler () {
193200 public void complete (String k , ResponseInfo rinfo , JSONObject response ) {
@@ -196,6 +203,7 @@ public void complete(String k, ResponseInfo rinfo, JSONObject response) {
196203 info = rinfo ;
197204 resp = response ;
198205 signal .countDown ();
206+ Assert .assertSame ("not in ui thread" , t , Thread .currentThread ());
199207 }
200208 }, null );
201209 }
@@ -217,13 +225,17 @@ public void testEmptyToken() throws Throwable {
217225 final String expectKey = "你好" ;
218226 runTestOnUiThread (new Runnable () { // THIS IS THE KEY TO SUCCESS
219227 public void run () {
228+
229+ final Thread t = Thread .currentThread ();
220230 uploadManager .put (new byte [1 ], expectKey , "" , new UpCompletionHandler () {
221231 public void complete (String k , ResponseInfo rinfo , JSONObject response ) {
222232 Log .i ("qiniutest" , k + rinfo );
223233 key = k ;
224234 info = rinfo ;
225235 resp = response ;
226236 signal .countDown ();
237+ Assert .assertSame ("not in ui thread" , t , Thread .currentThread ());
238+
227239 }
228240 }, null );
229241 }
0 commit comments