diff --git a/core_settings.gradle b/core_settings.gradle index b508243371..bd217a37e5 100644 --- a/core_settings.gradle +++ b/core_settings.gradle @@ -29,6 +29,7 @@ include modulePrefix + 'library-extractor' include modulePrefix + 'library-hls' include modulePrefix + 'library-smoothstreaming' include modulePrefix + 'library-ui' +include modulePrefix + 'robolectricutils' include modulePrefix + 'testutils' include modulePrefix + 'testdata' include modulePrefix + 'extension-av1' @@ -56,6 +57,7 @@ project(modulePrefix + 'library-extractor').projectDir = new File(rootDir, 'libr project(modulePrefix + 'library-hls').projectDir = new File(rootDir, 'library/hls') project(modulePrefix + 'library-smoothstreaming').projectDir = new File(rootDir, 'library/smoothstreaming') project(modulePrefix + 'library-ui').projectDir = new File(rootDir, 'library/ui') +project(modulePrefix + 'robolectricutils').projectDir = new File(rootDir, 'robolectricutils') project(modulePrefix + 'testutils').projectDir = new File(rootDir, 'testutils') project(modulePrefix + 'testdata').projectDir = new File(rootDir, 'testdata') project(modulePrefix + 'extension-av1').projectDir = new File(rootDir, 'extensions/av1') diff --git a/library/core/build.gradle b/library/core/build.gradle index ddeb734947..45c8e785c6 100644 --- a/library/core/build.gradle +++ b/library/core/build.gradle @@ -71,6 +71,7 @@ dependencies { testImplementation 'com.squareup.okhttp3:mockwebserver:' + mockWebServerVersion testImplementation 'org.robolectric:robolectric:' + robolectricVersion testImplementation project(modulePrefix + 'testutils') + testImplementation project(modulePrefix + 'robolectricutils') } ext { diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java index f37610d982..5fd7453beb 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/Mp4PlaybackTest.java @@ -23,8 +23,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; -import com.google.android.exoplayer2.e2etest.util.PlaybackOutput; -import com.google.android.exoplayer2.e2etest.util.ShadowMediaCodecConfig; +import com.google.android.exoplayer2.robolectric.PlaybackOutput; +import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.DumpFileAsserts; import com.google.android.exoplayer2.testutil.TestExoPlayer; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java index edc546897a..5b201b9a9c 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/e2etest/TsPlaybackTest.java @@ -21,8 +21,8 @@ import androidx.test.core.app.ApplicationProvider; import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; -import com.google.android.exoplayer2.e2etest.util.PlaybackOutput; -import com.google.android.exoplayer2.e2etest.util.ShadowMediaCodecConfig; +import com.google.android.exoplayer2.robolectric.PlaybackOutput; +import com.google.android.exoplayer2.robolectric.ShadowMediaCodecConfig; import com.google.android.exoplayer2.testutil.AutoAdvancingFakeClock; import com.google.android.exoplayer2.testutil.DumpFileAsserts; import com.google.android.exoplayer2.testutil.TestExoPlayer; diff --git a/robolectricutils/README.md b/robolectricutils/README.md new file mode 100644 index 0000000000..430a907c2d --- /dev/null +++ b/robolectricutils/README.md @@ -0,0 +1,10 @@ +# ExoPlayer Robolectric utils + +Provides test infrastructure for ExoPlayer Robolectric-based tests. + +## Links + +* [Javadoc][]: Classes matching `com.google.android.exoplayer2.robolectric` + belong to this module. + +[Javadoc]: https://exoplayer.dev/doc/reference/index.html diff --git a/robolectricutils/build.gradle b/robolectricutils/build.gradle new file mode 100644 index 0000000000..f5a86822b7 --- /dev/null +++ b/robolectricutils/build.gradle @@ -0,0 +1,35 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +apply from: "$gradle.ext.exoplayerSettingsDir/common_library_config.gradle" + +dependencies { + compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion + compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion + compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion + implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + implementation 'org.robolectric:robolectric:' + robolectricVersion + implementation project(modulePrefix + 'library-core') + implementation project(modulePrefix + 'testutils') +} + +ext { + javadocTitle = 'Robolectric utils' +} +apply from: '../javadoc_library.gradle' + +ext { + releaseArtifact = 'exoplayer-robolectricutils' + releaseDescription = 'Robolectric utils for ExoPlayer.' +} +apply from: '../publish.gradle' diff --git a/robolectricutils/src/main/AndroidManifest.xml b/robolectricutils/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..0548a1b32b --- /dev/null +++ b/robolectricutils/src/main/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + + diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/PlaybackOutput.java b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/PlaybackOutput.java similarity index 98% rename from library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/PlaybackOutput.java rename to robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/PlaybackOutput.java index f9c32d34b5..264b4bcc2f 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/PlaybackOutput.java +++ b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/PlaybackOutput.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.e2etest.util; +package com.google.android.exoplayer2.robolectric; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.metadata.Metadata; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/ShadowMediaCodecConfig.java b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/ShadowMediaCodecConfig.java similarity index 98% rename from library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/ShadowMediaCodecConfig.java rename to robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/ShadowMediaCodecConfig.java index 89e120e2e8..81014caea1 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/ShadowMediaCodecConfig.java +++ b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/ShadowMediaCodecConfig.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.e2etest.util; +package com.google.android.exoplayer2.robolectric; import android.media.MediaCodecInfo; import android.media.MediaFormat; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/TeeCodec.java b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/TeeCodec.java similarity index 98% rename from library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/TeeCodec.java rename to robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/TeeCodec.java index a14787e959..172350414e 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/e2etest/util/TeeCodec.java +++ b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/TeeCodec.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.e2etest.util; +package com.google.android.exoplayer2.robolectric; import com.google.android.exoplayer2.testutil.Dumper; import com.google.android.exoplayer2.util.MimeTypes; diff --git a/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/package-info.java b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/package-info.java new file mode 100644 index 0000000000..0dd7ab81ae --- /dev/null +++ b/robolectricutils/src/main/java/com/google/android/exoplayer2/robolectric/package-info.java @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@NonNullApi +package com.google.android.exoplayer2.robolectric; + +import com.google.android.exoplayer2.util.NonNullApi;