Commit 8bb44615 by sheenachhabra Committed by Tofunmi Adigun-Hameed

Enable nullness checker for Muxer module androidTest library

PiperOrigin-RevId: 538742957
(cherry picked from commit f582e41aab795398ea0e7ef2a70c6282b6ead634)
parent 7becf584
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.muxer; package com.google.android.exoplayer2.muxer;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.content.Context; import android.content.Context;
import android.media.MediaCodec; import android.media.MediaCodec;
import android.media.MediaExtractor; import android.media.MediaExtractor;
...@@ -30,6 +32,7 @@ import java.io.IOException; ...@@ -30,6 +32,7 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
...@@ -53,26 +56,23 @@ public class Mp4MuxerEndToEndTest { ...@@ -53,26 +56,23 @@ public class Mp4MuxerEndToEndTest {
return ImmutableList.of(H264_MP4, H265_HDR10_MP4, H265_WITH_METADATA_TRACK_MP4, AV1_MP4); return ImmutableList.of(H264_MP4, H265_HDR10_MP4, H265_WITH_METADATA_TRACK_MP4, AV1_MP4);
} }
@Parameter public String inputFile; @Parameter public @MonotonicNonNull String inputFile;
@Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder();
private static final String MP4_FILE_ASSET_DIRECTORY = "media/mp4/"; private static final String MP4_FILE_ASSET_DIRECTORY = "media/mp4/";
private final Context context = ApplicationProvider.getApplicationContext();
private Context context; private @MonotonicNonNull String outputPath;
private String outputPath; private @MonotonicNonNull FileOutputStream outputStream;
private FileOutputStream outputStream;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
context = ApplicationProvider.getApplicationContext();
outputPath = temporaryFolder.newFile("muxeroutput.mp4").getPath(); outputPath = temporaryFolder.newFile("muxeroutput.mp4").getPath();
outputStream = new FileOutputStream(outputPath); outputStream = new FileOutputStream(outputPath);
} }
@After @After
public void tearDown() throws IOException { public void tearDown() throws IOException {
outputStream.close(); checkNotNull(outputStream).close();
} }
@Test @Test
...@@ -80,9 +80,9 @@ public class Mp4MuxerEndToEndTest { ...@@ -80,9 +80,9 @@ public class Mp4MuxerEndToEndTest {
Mp4Muxer mp4Muxer = null; Mp4Muxer mp4Muxer = null;
try { try {
mp4Muxer = new Mp4Muxer.Builder(outputStream).build(); mp4Muxer = new Mp4Muxer.Builder(checkNotNull(outputStream)).build();
mp4Muxer.setModificationTime(/* timestampMs= */ 500_000_000L); mp4Muxer.setModificationTime(/* timestampMs= */ 500_000_000L);
feedInputDataToMuxer(mp4Muxer, inputFile); feedInputDataToMuxer(mp4Muxer, checkNotNull(inputFile));
} finally { } finally {
if (mp4Muxer != null) { if (mp4Muxer != null) {
mp4Muxer.close(); mp4Muxer.close();
...@@ -90,14 +90,14 @@ public class Mp4MuxerEndToEndTest { ...@@ -90,14 +90,14 @@ public class Mp4MuxerEndToEndTest {
} }
FakeExtractorOutput fakeExtractorOutput = FakeExtractorOutput fakeExtractorOutput =
TestUtil.extractAllSamplesFromFilePath(new Mp4Extractor(), outputPath); TestUtil.extractAllSamplesFromFilePath(new Mp4Extractor(), checkNotNull(outputPath));
DumpFileAsserts.assertOutput( DumpFileAsserts.assertOutput(
context, fakeExtractorOutput, AndroidMuxerTestUtil.getExpectedDumpFilePath(inputFile)); context, fakeExtractorOutput, AndroidMuxerTestUtil.getExpectedDumpFilePath(inputFile));
} }
@Test @Test
public void createMp4File_muxerNotClosed_createsPartiallyWrittenValidFile() throws IOException { public void createMp4File_muxerNotClosed_createsPartiallyWrittenValidFile() throws IOException {
Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(outputStream).build(); Mp4Muxer mp4Muxer = new Mp4Muxer.Builder(checkNotNull(outputStream)).build();
mp4Muxer.setModificationTime(/* timestampMs= */ 500_000_000L); mp4Muxer.setModificationTime(/* timestampMs= */ 500_000_000L);
feedInputDataToMuxer(mp4Muxer, H265_HDR10_MP4); feedInputDataToMuxer(mp4Muxer, H265_HDR10_MP4);
...@@ -107,7 +107,7 @@ public class Mp4MuxerEndToEndTest { ...@@ -107,7 +107,7 @@ public class Mp4MuxerEndToEndTest {
// Video sample written = 94 out of 127. // Video sample written = 94 out of 127.
// Output is still a valid MP4 file. // Output is still a valid MP4 file.
FakeExtractorOutput fakeExtractorOutput = FakeExtractorOutput fakeExtractorOutput =
TestUtil.extractAllSamplesFromFilePath(new Mp4Extractor(), outputPath); TestUtil.extractAllSamplesFromFilePath(new Mp4Extractor(), checkNotNull(outputPath));
DumpFileAsserts.assertOutput( DumpFileAsserts.assertOutput(
context, context,
fakeExtractorOutput, fakeExtractorOutput,
......
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