Re-split ExoHostedTest.onTestFinished into logMetrics and assertPassed

This is a partial revert of <unknown commit>. The split and the order is important. For
example, as things are currently, if playback fails for a test that makes additional
assertions in onTestFinished, the visible reason the test failed is quite likely to
be one of the additional assertions, rather than the error that actually caused the
playback to fail. I think we probably also don't want to log metrics if playback
fails.

PiperOrigin-RevId: 300733109
This commit is contained in:
olly 2020-03-13 11:44:15 +00:00 committed by Oliver Woodman
parent 4a582b2361
commit 3acc85c2df
2 changed files with 13 additions and 4 deletions

View file

@ -312,7 +312,7 @@ import java.util.List;
}
@Override
protected void onTestFinished(DecoderCounters audioCounters, DecoderCounters videoCounters) {
protected void logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters) {
metricsLogger.logMetric(MetricsLogger.KEY_TEST_NAME, streamName);
metricsLogger.logMetric(MetricsLogger.KEY_IS_CDD_LIMITED_RETRY, isCddLimitedRetry);
metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_DROPPED_COUNT,
@ -324,7 +324,10 @@ import java.util.List;
metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_RENDERED_COUNT,
videoCounters.renderedOutputBufferCount);
metricsLogger.close();
}
@Override
protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) {
if (fullPlaybackNoSeeking) {
// We shouldn't have skipped any output buffers.
DecoderCountersUtil

View file

@ -159,10 +159,10 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
@Override
public final void onFinished() {
onTestFinished(audioDecoderCounters, videoDecoderCounters);
if (failOnPlayerError && playerError != null) {
throw new Error(playerError);
}
logMetrics(audioDecoderCounters, videoDecoderCounters);
if (expectedPlayingTimeMs != EXPECTED_PLAYING_TIME_UNSET) {
long playingTimeToAssertMs = expectedPlayingTimeMs == EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS
? sourceDurationMs : expectedPlayingTimeMs;
@ -176,6 +176,8 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
&& totalPlayingTimeMs <= maxAllowedActualPlayingTimeMs)
.isTrue();
}
// Make any additional assertions.
assertPassed(audioDecoderCounters, videoDecoderCounters);
}
// AnalyticsListener
@ -259,8 +261,12 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
// Do nothing. Interested subclasses may override.
}
protected void onTestFinished(DecoderCounters audioCounters, DecoderCounters videoCounters) {
// Do nothing. Subclasses may override to add clean-up and assertions.
protected void logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters) {
// Do nothing. Subclasses may override to log metrics.
}
protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) {
// Do nothing. Subclasses may override to add additional assertions.
}
@EnsuresNonNullIf(