mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Extend HostActivity for reuse and silent timeout.
Added option to fail on timeout. Also reset internals in all cases such that the activity can be used more than once. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=159419176
This commit is contained in:
parent
56ff2ef598
commit
de4ff4c5ec
1 changed files with 16 additions and 1 deletions
|
|
@ -101,6 +101,17 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||||
* is exceeded then the test will fail.
|
* is exceeded then the test will fail.
|
||||||
*/
|
*/
|
||||||
public void runTest(final HostedTest hostedTest, long timeoutMs) {
|
public void runTest(final HostedTest hostedTest, long timeoutMs) {
|
||||||
|
runTest(hostedTest, timeoutMs, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a {@link HostedTest} inside the host.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
public void runTest(final HostedTest hostedTest, long timeoutMs, boolean failOnTimeout) {
|
||||||
Assertions.checkArgument(timeoutMs > 0);
|
Assertions.checkArgument(timeoutMs > 0);
|
||||||
Assertions.checkState(Thread.currentThread() != getMainLooper().getThread());
|
Assertions.checkState(Thread.currentThread() != getMainLooper().getThread());
|
||||||
|
|
||||||
|
|
@ -131,7 +142,11 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
||||||
} else {
|
} else {
|
||||||
String message = "Test timed out after " + timeoutMs + " ms.";
|
String message = "Test timed out after " + timeoutMs + " ms.";
|
||||||
Log.e(TAG, message);
|
Log.e(TAG, message);
|
||||||
fail(message);
|
if (failOnTimeout) {
|
||||||
|
fail(message);
|
||||||
|
}
|
||||||
|
maybeStopHostedTest();
|
||||||
|
hostedTestStoppedCondition.block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue