Run ExoPlayerTest with preloading enabled and disabled
Replace with parametrized test when https://issuetracker.google.com/316040980 is resolved. PiperOrigin-RevId: 631096883
This commit is contained in:
parent
0ab6ea5668
commit
4841f8f8b3
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
package androidx.media3.exoplayer;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Unit test for {@link ExoPlayer} with playlist preloading enabled. */
|
||||
// TODO(issuetracker.google.com/316040980): Replace this class with a parameterized ExoPlayerTest
|
||||
// when resolved.
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExoPlayerWithPreloadingEnabledTest extends ExoPlayerTest {
|
||||
|
||||
@Override
|
||||
protected long getTargetPreloadDurationUs() {
|
||||
return 5_000_000L;
|
||||
}
|
||||
}
|
@ -284,6 +284,16 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExoPlayer#setPreloadConfiguration(ExoPlayer.PreloadConfiguration)
|
||||
* @return This builder.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setPreloadConfiguration(ExoPlayer.PreloadConfiguration preloadConfiguration) {
|
||||
testPlayerBuilder.setPreloadConfiguration(preloadConfiguration);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an {@link ActionSchedule} to be run by the test runner. The first action will be
|
||||
* executed immediately before {@link ExoPlayer#prepare()}.
|
||||
|
@ -56,6 +56,7 @@ public class TestExoPlayerBuilder {
|
||||
private long seekForwardIncrementMs;
|
||||
private boolean deviceVolumeControlEnabled;
|
||||
private boolean suppressPlaybackWhenUnsuitableOutput;
|
||||
@Nullable private ExoPlayer.PreloadConfiguration preloadConfiguration;
|
||||
|
||||
public TestExoPlayerBuilder(Context context) {
|
||||
this.context = context;
|
||||
@ -160,6 +161,18 @@ public class TestExoPlayerBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preload configuration.
|
||||
*
|
||||
* @see ExoPlayer#setPreloadConfiguration(ExoPlayer.PreloadConfiguration)
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public TestExoPlayerBuilder setPreloadConfiguration(
|
||||
ExoPlayer.PreloadConfiguration preloadConfiguration) {
|
||||
this.preloadConfiguration = preloadConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Renderer Renderers} that have been set with {@link #setRenderers} or null if
|
||||
* no {@link Renderer Renderers} have been explicitly set. Note that these renderers may not be
|
||||
@ -357,6 +370,10 @@ public class TestExoPlayerBuilder {
|
||||
if (mediaSourceFactory != null) {
|
||||
builder.setMediaSourceFactory(mediaSourceFactory);
|
||||
}
|
||||
return builder.build();
|
||||
ExoPlayer exoPlayer = builder.build();
|
||||
if (preloadConfiguration != null) {
|
||||
exoPlayer.setPreloadConfiguration(preloadConfiguration);
|
||||
}
|
||||
return exoPlayer;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user