Brion VIBBER has submitted this change and it was merged.

Change subject: Add test to verify SaneAsyncTask exception handler thread 
affinity
......................................................................


Add test to verify SaneAsyncTask exception handler thread affinity

Change-Id: Ibec1ffbb3e6bff5c238b3fb715054309f28e2b5f
---
M 
wikipedia-it/src/main/java/org/wikimedia/wikipedia/test/concurrency/AsyncTaskTest.java
1 file changed, 35 insertions(+), 0 deletions(-)

Approvals:
  Brion VIBBER: Verified; Looks good to me, approved



diff --git 
a/wikipedia-it/src/main/java/org/wikimedia/wikipedia/test/concurrency/AsyncTaskTest.java
 
b/wikipedia-it/src/main/java/org/wikimedia/wikipedia/test/concurrency/AsyncTaskTest.java
index 0c6609d..689b0bd 100644
--- 
a/wikipedia-it/src/main/java/org/wikimedia/wikipedia/test/concurrency/AsyncTaskTest.java
+++ 
b/wikipedia-it/src/main/java/org/wikimedia/wikipedia/test/concurrency/AsyncTaskTest.java
@@ -113,4 +113,39 @@
         });
         assertTrue(completionLatch.await(TASK_COMPLETION_TIMEOUT, 
TimeUnit.MILLISECONDS));
     }
+
+    public void testAppropriateThreadException() throws Throwable {
+        final CountDownLatch completionLatch = new CountDownLatch(1);
+        final Throwable thrown = new Exception();
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                final Thread callingThread = Thread.currentThread();
+                new SaneAsyncTask<Thread>(getDefaultExecutor()) {
+                    @Override
+                    public void onBeforeExecute() {
+                        assertSame(callingThread, Thread.currentThread());
+                    }
+
+                    @Override
+                    public void onFinish(Thread result) {
+                        assertTrue("onFinish called even when there is an 
exception", false);
+                    }
+
+                    @Override
+                    public void onCatch(Throwable caught) {
+                        assertSame(callingThread, Thread.currentThread());
+                        completionLatch.countDown();
+                    }
+
+                    @Override
+                    public Thread performTask() throws Throwable {
+                        assertNotSame(callingThread, Thread.currentThread());
+                        throw thrown;
+                    }
+                }.execute();
+            }
+        });
+        assertTrue(completionLatch.await(TASK_COMPLETION_TIMEOUT, 
TimeUnit.MILLISECONDS));
+    }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/92834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibec1ffbb3e6bff5c238b3fb715054309f28e2b5f
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to