diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java index d0cad0c4a9..d0d93d3b9d 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java @@ -17,7 +17,6 @@ package com.google.android.exoplayer2.transformer; import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.util.Assertions; import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.json.JSONException; import org.json.JSONObject; @@ -29,7 +28,7 @@ public class TransformationTestResult { /** A builder for {@link TransformationTestResult}. */ public static class Builder { - @Nullable private TransformationResult transformationResult; + private final TransformationResult transformationResult; @Nullable private String filePath; private long elapsedTimeMs; private double ssim; @@ -37,25 +36,12 @@ public class TransformationTestResult { @Nullable private Exception analysisException; /** Creates a new {@link Builder}. */ - public Builder() { + public Builder(TransformationResult transformationResult) { + this.transformationResult = transformationResult; this.elapsedTimeMs = C.TIME_UNSET; this.ssim = SSIM_UNSET; } - /** - * Sets the {@link TransformationResult} of the transformation. - * - *
This field must be set. - * - * @param transformationResult The {@link TransformationResult}. - * @return This {@link Builder} - */ - @CanIgnoreReturnValue - public Builder setTransformationResult(TransformationResult transformationResult) { - this.transformationResult = transformationResult; - return this; - } - /** * Sets the file path of the output file. * @@ -130,12 +116,7 @@ public class TransformationTestResult { /** Builds the {@link TransformationTestResult} instance. */ public TransformationTestResult build() { return new TransformationTestResult( - Assertions.checkNotNull(transformationResult), - filePath, - elapsedTimeMs, - ssim, - testException, - analysisException); + transformationResult, filePath, elapsedTimeMs, ssim, testException, analysisException); } } diff --git a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformerAndroidTestRunner.java b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformerAndroidTestRunner.java index e7b98efd1e..0bf8e41813 100644 --- a/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformerAndroidTestRunner.java +++ b/library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformerAndroidTestRunner.java @@ -297,10 +297,7 @@ public class TransformerAndroidTestRunner { // Block here until timeout reached or latch is counted down. boolean timeoutReached = !countDownLatch.await(timeoutSeconds, SECONDS); - - TransformationTestResult.Builder testResultBuilder = - new TransformationTestResult.Builder() - .setElapsedTimeMs(SystemClock.DEFAULT.elapsedRealtime() - startTimeMs); + long elapsedTimeMs = SystemClock.DEFAULT.elapsedRealtime() - startTimeMs; @Nullable Exception unexpectedException = unexpectedExceptionReference.get(); @Nullable @@ -319,20 +316,21 @@ public class TransformerAndroidTestRunner { } if (testException != null) { - return testResultBuilder - .setTransformationResult(checkNotNull(transformationResultReference.get())) + return new TransformationTestResult.Builder(checkNotNull(transformationResultReference.get())) + .setElapsedTimeMs(elapsedTimeMs) .setTestException(testException) .build(); } // No exceptions raised, transformation has succeeded. - testResultBuilder - .setTransformationResult( - checkNotNull(transformationResultReference.get()) - .buildUpon() - .setFileSizeBytes(outputVideoFile.length()) - .build()) - .setFilePath(outputVideoFile.getPath()); + TransformationTestResult.Builder testResultBuilder = + new TransformationTestResult.Builder( + checkNotNull(transformationResultReference.get()) + .buildUpon() + .setFileSizeBytes(outputVideoFile.length()) + .build()) + .setElapsedTimeMs(elapsedTimeMs) + .setFilePath(outputVideoFile.getPath()); if (!requestCalculateSsim) { return testResultBuilder.build();