mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make ABR playback tests more resilient to HostActivity failures.
We currently fail the entire playback tests if we exceed a start timeout or the test gets stopped forcefully. This is problematic as the start timeout may happen from time to time for the ABR tests and we'd still like to have the remaining playbacks. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=222406639
This commit is contained in:
parent
dd47bfffb0
commit
fd2f8eaba8
@ -99,7 +99,7 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||
* is exceeded then the test will fail.
|
||||
*/
|
||||
public void runTest(HostedTest hostedTest, long timeoutMs) {
|
||||
runTest(hostedTest, timeoutMs, true);
|
||||
runTest(hostedTest, timeoutMs, /* failOnTimeoutOrForceStop= */ true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,9 +107,11 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||
*
|
||||
* @param hostedTest The test to execute.
|
||||
* @param timeoutMs The number of milliseconds to wait for the test to finish.
|
||||
* @param failOnTimeout Whether the test fails when the timeout is exceeded.
|
||||
* @param failOnTimeoutOrForceStop Whether the test fails when a timeout is exceeded or the test
|
||||
* is stopped forcefully.
|
||||
*/
|
||||
public void runTest(final HostedTest hostedTest, long timeoutMs, boolean failOnTimeout) {
|
||||
public void runTest(
|
||||
final HostedTest hostedTest, long timeoutMs, boolean failOnTimeoutOrForceStop) {
|
||||
Assertions.checkArgument(timeoutMs > 0);
|
||||
Assertions.checkState(Thread.currentThread() != getMainLooper().getThread());
|
||||
Assertions.checkState(this.hostedTest == null);
|
||||
@ -128,8 +130,10 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||
String message =
|
||||
"Test failed to start. Display may be turned off or keyguard may be present.";
|
||||
Log.e(TAG, message);
|
||||
if (failOnTimeoutOrForceStop) {
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
|
||||
if (hostedTest.blockUntilStopped(timeoutMs)) {
|
||||
if (!forcedStopped) {
|
||||
@ -140,13 +144,15 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||
String message = "Test force stopped. Activity may have been paused whilst "
|
||||
+ "test was in progress.";
|
||||
Log.e(TAG, message);
|
||||
if (failOnTimeoutOrForceStop) {
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
runOnUiThread(hostedTest::forceStop);
|
||||
String message = "Test timed out after " + timeoutMs + " ms.";
|
||||
Log.e(TAG, message);
|
||||
if (failOnTimeout) {
|
||||
if (failOnTimeoutOrForceStop) {
|
||||
fail(message);
|
||||
}
|
||||
}
|
||||
@ -234,5 +240,4 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||
forcedStopped = hostedTest.forceStop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user