Merge "VirtualDisplayTest: Rethrow runOnUiThread exceptions on test thread" into tm-dev am: 424c5a18c1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17523153 Change-Id: I4026bb1cd47fa0fd95b9397b020742483131e66b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -332,21 +332,23 @@ public class VirtualDisplayTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void runOnUiThread(Runnable runnable) {
|
private void runOnUiThread(Runnable runnable) {
|
||||||
Runnable waiter = new Runnable() {
|
final Throwable[] thrown = new Throwable[1];
|
||||||
@Override
|
assertTrue("Timed out", mHandler.runWithScissors(() -> {
|
||||||
public void run() {
|
|
||||||
synchronized (this) {
|
|
||||||
notifyAll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
synchronized (waiter) {
|
|
||||||
mHandler.post(runnable);
|
|
||||||
mHandler.post(waiter);
|
|
||||||
try {
|
try {
|
||||||
waiter.wait(TIMEOUT);
|
runnable.run();
|
||||||
} catch (InterruptedException ex) {
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
thrown[0] = t;
|
||||||
}
|
}
|
||||||
|
}, TIMEOUT));
|
||||||
|
if (thrown[0] != null) {
|
||||||
|
if (thrown[0] instanceof RuntimeException) {
|
||||||
|
throw (RuntimeException) thrown[0];
|
||||||
|
}
|
||||||
|
if (thrown[0] instanceof Error) {
|
||||||
|
throw (Error) thrown[0];
|
||||||
|
}
|
||||||
|
throw new RuntimeException(thrown[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user