Yuvipanda has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/92834


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/34/92834/1

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 d7169e8..9a59a89 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: newchange
Gerrit-Change-Id: Ibec1ffbb3e6bff5c238b3fb715054309f28e2b5f
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>

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

Reply via email to