From aa712114c66b5e92d73d0529e1cbdb7242e9cd50 Mon Sep 17 00:00:00 2001 From: tonihei Date: Wed, 23 Aug 2017 09:04:29 -0700 Subject: [PATCH] Force stop hosted test after timeout. When hosted tests run into a timeout, the outer test method stops. However, the hosted test itself may continue running and needs to be forced-stopped to ensure it does not block any resources needed by subsequent test methods. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=166208204 --- .../google/android/exoplayer2/testutil/HostActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java index 66b992e652..54087c4461 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java @@ -137,6 +137,12 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba fail(message); } } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + hostedTest.forceStop(); + } + }); String message = "Test timed out after " + timeoutMs + " ms."; Log.e(TAG, message); if (failOnTimeout) {