Commit a010ebf7 by samrobinson Committed by christosts

Consolidate TransformationResult.transformationException test usage.

PiperOrigin-RevId: 504257627
parent 1f9a3327
...@@ -37,7 +37,6 @@ public class TransformationTestResult { ...@@ -37,7 +37,6 @@ public class TransformationTestResult {
private long elapsedTimeMs; private long elapsedTimeMs;
private double ssim; private double ssim;
@Nullable private FallbackDetails fallbackDetails; @Nullable private FallbackDetails fallbackDetails;
@Nullable private Exception testException;
@Nullable private Exception analysisException; @Nullable private Exception analysisException;
/** Creates a new {@link Builder}. */ /** Creates a new {@link Builder}. */
...@@ -106,20 +105,6 @@ public class TransformationTestResult { ...@@ -106,20 +105,6 @@ public class TransformationTestResult {
} }
/** /**
* Sets an {@link Exception} that occurred during the test.
*
* <p>{@code null} represents an unset or unknown value.
*
* @param testException The {@link Exception} thrown during the test.
* @return This {@link Builder}.
*/
@CanIgnoreReturnValue
public Builder setTestException(@Nullable Exception testException) {
this.testException = testException;
return this;
}
/**
* Sets an {@link Exception} that occurred during post-transformation analysis. * Sets an {@link Exception} that occurred during post-transformation analysis.
* *
* <p>{@code null} represents an unset or unknown value. * <p>{@code null} represents an unset or unknown value.
...@@ -136,13 +121,7 @@ public class TransformationTestResult { ...@@ -136,13 +121,7 @@ public class TransformationTestResult {
/** Builds the {@link TransformationTestResult} instance. */ /** Builds the {@link TransformationTestResult} instance. */
public TransformationTestResult build() { public TransformationTestResult build() {
return new TransformationTestResult( return new TransformationTestResult(
transformationResult, transformationResult, filePath, elapsedTimeMs, ssim, fallbackDetails, analysisException);
filePath,
elapsedTimeMs,
ssim,
fallbackDetails,
testException,
analysisException);
} }
} }
...@@ -167,8 +146,6 @@ public class TransformationTestResult { ...@@ -167,8 +146,6 @@ public class TransformationTestResult {
* {@code null} if no fallback occurred. * {@code null} if no fallback occurred.
*/ */
@Nullable public final FallbackDetails fallbackDetails; @Nullable public final FallbackDetails fallbackDetails;
/** The {@link Exception} thrown during the test, or {@code null} if nothing was thrown. */
@Nullable public final Exception testException;
/** /**
* The {@link Exception} thrown during post-transformation analysis, or {@code null} if nothing * The {@link Exception} thrown during post-transformation analysis, or {@code null} if nothing
* was thrown. * was thrown.
...@@ -187,7 +164,9 @@ public class TransformationTestResult { ...@@ -187,7 +164,9 @@ public class TransformationTestResult {
.putOpt("colorInfo", transformationResult.colorInfo) .putOpt("colorInfo", transformationResult.colorInfo)
.putOpt("videoDecoderName", transformationResult.videoDecoderName) .putOpt("videoDecoderName", transformationResult.videoDecoderName)
.putOpt("videoEncoderName", transformationResult.videoEncoderName) .putOpt("videoEncoderName", transformationResult.videoEncoderName)
.putOpt("testException", exceptionAsJsonObject(testException)) .putOpt(
"testException",
exceptionAsJsonObject(transformationResult.transformationException))
.putOpt("analysisException", exceptionAsJsonObject(analysisException)); .putOpt("analysisException", exceptionAsJsonObject(analysisException));
if (transformationResult.averageAudioBitrate != C.RATE_UNSET_INT) { if (transformationResult.averageAudioBitrate != C.RATE_UNSET_INT) {
...@@ -238,14 +217,12 @@ public class TransformationTestResult { ...@@ -238,14 +217,12 @@ public class TransformationTestResult {
long elapsedTimeMs, long elapsedTimeMs,
double ssim, double ssim,
@Nullable FallbackDetails fallbackDetails, @Nullable FallbackDetails fallbackDetails,
@Nullable Exception testException,
@Nullable Exception analysisException) { @Nullable Exception analysisException) {
this.transformationResult = transformationResult; this.transformationResult = transformationResult;
this.filePath = filePath; this.filePath = filePath;
this.elapsedTimeMs = elapsedTimeMs; this.elapsedTimeMs = elapsedTimeMs;
this.ssim = ssim; this.ssim = ssim;
this.fallbackDetails = fallbackDetails; this.fallbackDetails = fallbackDetails;
this.testException = testException;
this.analysisException = analysisException; this.analysisException = analysisException;
this.throughputFps = this.throughputFps =
elapsedTimeMs != C.TIME_UNSET && transformationResult.videoFrameCount > 0 elapsedTimeMs != C.TIME_UNSET && transformationResult.videoFrameCount > 0
......
...@@ -204,8 +204,8 @@ public class TransformerAndroidTestRunner { ...@@ -204,8 +204,8 @@ public class TransformerAndroidTestRunner {
try { try {
TransformationTestResult transformationTestResult = runInternal(testId, editedMediaItem); TransformationTestResult transformationTestResult = runInternal(testId, editedMediaItem);
resultJson.put("transformationResult", transformationTestResult.asJsonObject()); resultJson.put("transformationResult", transformationTestResult.asJsonObject());
if (transformationTestResult.testException != null) { if (transformationTestResult.transformationResult.transformationException != null) {
throw transformationTestResult.testException; throw transformationTestResult.transformationResult.transformationException;
} }
if (!suppressAnalysisExceptions && transformationTestResult.analysisException != null) { if (!suppressAnalysisExceptions && transformationTestResult.analysisException != null) {
throw transformationTestResult.analysisException; throw transformationTestResult.analysisException;
...@@ -257,8 +257,6 @@ public class TransformerAndroidTestRunner { ...@@ -257,8 +257,6 @@ public class TransformerAndroidTestRunner {
AtomicReference<@NullableType FallbackDetails> fallbackDetailsReference = AtomicReference<@NullableType FallbackDetails> fallbackDetailsReference =
new AtomicReference<>(); new AtomicReference<>();
AtomicReference<@NullableType TransformationException> transformationExceptionReference =
new AtomicReference<>();
AtomicReference<@NullableType Exception> unexpectedExceptionReference = new AtomicReference<>(); AtomicReference<@NullableType Exception> unexpectedExceptionReference = new AtomicReference<>();
AtomicReference<@NullableType TransformationResult> transformationResultReference = AtomicReference<@NullableType TransformationResult> transformationResultReference =
new AtomicReference<>(); new AtomicReference<>();
...@@ -282,7 +280,6 @@ public class TransformerAndroidTestRunner { ...@@ -282,7 +280,6 @@ public class TransformerAndroidTestRunner {
MediaItem inputMediaItem, MediaItem inputMediaItem,
TransformationResult result, TransformationResult result,
TransformationException exception) { TransformationException exception) {
transformationExceptionReference.set(exception);
transformationResultReference.set(result); transformationResultReference.set(result);
countDownLatch.countDown(); countDownLatch.countDown();
} }
...@@ -337,14 +334,12 @@ public class TransformerAndroidTestRunner { ...@@ -337,14 +334,12 @@ public class TransformerAndroidTestRunner {
long elapsedTimeMs = SystemClock.DEFAULT.elapsedRealtime() - startTimeMs; long elapsedTimeMs = SystemClock.DEFAULT.elapsedRealtime() - startTimeMs;
@Nullable FallbackDetails fallbackDetails = fallbackDetailsReference.get(); @Nullable FallbackDetails fallbackDetails = fallbackDetailsReference.get();
@Nullable TransformationResult transformationResult = checkNotNull(transformationResultReference.get());
TransformationException transformationException = transformationExceptionReference.get();
if (transformationException != null) { if (transformationResult.transformationException != null) {
return new TransformationTestResult.Builder(checkNotNull(transformationResultReference.get())) return new TransformationTestResult.Builder(transformationResult)
.setElapsedTimeMs(elapsedTimeMs) .setElapsedTimeMs(elapsedTimeMs)
.setFallbackDetails(fallbackDetails) .setFallbackDetails(fallbackDetails)
.setTestException(transformationException)
.build(); .build();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment