Add utility testing Player.Listener in transformer tests

PiperOrigin-RevId: 596891721
This commit is contained in:
christosts 2024-01-09 04:34:41 -08:00 committed by Copybara-Service
parent 6f8249184b
commit 4198f7e242
3 changed files with 6 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 B

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package androidx.media3.transformer.mh.performance; package androidx.media3.transformer;
import android.os.ConditionVariable; import android.os.ConditionVariable;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -26,8 +26,8 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/** A listener for testing previewing performance. */ /** Utility {@link Player.Listener} for testing. */
/* package */ class PerformanceTestListener implements Player.Listener, AnalyticsListener { public final class PlayerTestListener implements Player.Listener, AnalyticsListener {
private final ConditionVariable playerReady; private final ConditionVariable playerReady;
private final ConditionVariable playerEnded; private final ConditionVariable playerEnded;
@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* @param testTimeoutMs The timeout value in milliseconds for which {@link * @param testTimeoutMs The timeout value in milliseconds for which {@link
* #waitUntilPlayerReady()} and {@link #waitUntilPlayerEnded()} waits. * #waitUntilPlayerReady()} and {@link #waitUntilPlayerEnded()} waits.
*/ */
public PerformanceTestListener(long testTimeoutMs) { public PlayerTestListener(long testTimeoutMs) {
playerReady = new ConditionVariable(); playerReady = new ConditionVariable();
playerEnded = new ConditionVariable(); playerEnded = new ConditionVariable();
playbackException = new AtomicReference<>(); playbackException = new AtomicReference<>();

View File

@ -28,6 +28,7 @@ import androidx.media3.common.PlaybackException;
import androidx.media3.exoplayer.DecoderCounters; import androidx.media3.exoplayer.DecoderCounters;
import androidx.media3.exoplayer.ExoPlayer; import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.util.EventLogger; import androidx.media3.exoplayer.util.EventLogger;
import androidx.media3.transformer.PlayerTestListener;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.platform.app.InstrumentationRegistry;
@ -66,7 +67,7 @@ public class VideoEffectsPreviewPerformanceTest {
*/ */
@Test @Test
public void exoplayerEffectsPreviewTest() throws PlaybackException, TimeoutException { public void exoplayerEffectsPreviewTest() throws PlaybackException, TimeoutException {
PerformanceTestListener listener = new PerformanceTestListener(TEST_TIMEOUT_MS); PlayerTestListener listener = new PlayerTestListener(TEST_TIMEOUT_MS);
instrumentation.runOnMainSync( instrumentation.runOnMainSync(
() -> { () -> {
player = new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build(); player = new ExoPlayer.Builder(ApplicationProvider.getApplicationContext()).build();