mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Add missing overrides in DefaultTrackSelector.Parameters.Builder
Also add a test for this to avoid missing any others in future. Also
flesh out the existing test for the deprecated builder, to assert the
return type is correctly updated.
PiperOrigin-RevId: 688948768
(cherry picked from commit 7b66209bca)
This commit is contained in:
parent
a03bd8248c
commit
fbbe48cd47
2 changed files with 45 additions and 5 deletions
|
|
@ -1292,6 +1292,13 @@ public class DefaultTrackSelector extends MappingTrackSelector
|
|||
return this;
|
||||
}
|
||||
|
||||
@CanIgnoreReturnValue
|
||||
@Override
|
||||
public Builder setAudioOffloadPreferences(AudioOffloadPreferences audioOffloadPreferences) {
|
||||
super.setAudioOffloadPreferences(audioOffloadPreferences);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to allow adaptive audio selections where adaptation may not be completely
|
||||
* seamless.
|
||||
|
|
@ -1393,6 +1400,15 @@ public class DefaultTrackSelector extends MappingTrackSelector
|
|||
return setIgnoredTextSelectionFlags(disabledTextTrackSelectionFlags);
|
||||
}
|
||||
|
||||
// Image
|
||||
|
||||
@CanIgnoreReturnValue
|
||||
@Override
|
||||
public Builder setPrioritizeImageOverVideoEnabled(boolean isPrioritizeImageOverVideoEnabled) {
|
||||
super.setPrioritizeImageOverVideoEnabled(isPrioritizeImageOverVideoEnabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
// General
|
||||
|
||||
@CanIgnoreReturnValue
|
||||
|
|
|
|||
|
|
@ -2970,12 +2970,32 @@ public final class DefaultTrackSelectorTest {
|
|||
assertThat(selectionOverrideFromBundle).isEqualTo(selectionOverrideToBundle);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link DefaultTrackSelector.Parameters.Builder} must override every method in {@link
|
||||
* TrackSelectionParameters.Builder} in order to 'fix' the return type to correctly allow chaining
|
||||
* the method calls.
|
||||
*/
|
||||
@Test
|
||||
public void parametersBuilderOverridesAllTrackSelectionParametersBuilderMethods()
|
||||
throws Exception {
|
||||
List<Method> methods = TestUtil.getPublicMethods(TrackSelectionParameters.Builder.class);
|
||||
for (Method method : methods) {
|
||||
Method declaredMethod =
|
||||
Parameters.Builder.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
|
||||
assertThat(declaredMethod.getDeclaringClass()).isEqualTo(Parameters.Builder.class);
|
||||
if (method.getReturnType().equals(TrackSelectionParameters.Builder.class)) {
|
||||
assertThat(declaredMethod.getReturnType()).isEqualTo(Parameters.Builder.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The deprecated {@link DefaultTrackSelector.ParametersBuilder} is implemented by delegating to
|
||||
* an instance of {@link DefaultTrackSelector.Parameters.Builder}. However, it <b>also</b> extends
|
||||
* {@link TrackSelectionParameters.Builder}, and for the delegation-pattern to work correctly it
|
||||
* needs to override <b>every</b> setter method from the superclass (otherwise the setter won't be
|
||||
* propagated to the delegate). This test ensures that invariant.
|
||||
* propagated to the delegate). This test ensures that invariant. It also ensures the return type
|
||||
* is updated to correctly allow chaining the method calls.
|
||||
*
|
||||
* <p>The test can be removed when the deprecated {@link DefaultTrackSelector.ParametersBuilder}
|
||||
* is removed.
|
||||
|
|
@ -2986,11 +3006,15 @@ public final class DefaultTrackSelectorTest {
|
|||
throws Exception {
|
||||
List<Method> methods = TestUtil.getPublicMethods(TrackSelectionParameters.Builder.class);
|
||||
for (Method method : methods) {
|
||||
assertThat(
|
||||
DefaultTrackSelector.ParametersBuilder.class
|
||||
.getDeclaredMethod(method.getName(), method.getParameterTypes())
|
||||
.getDeclaringClass())
|
||||
Method declaredMethod =
|
||||
DefaultTrackSelector.ParametersBuilder.class.getDeclaredMethod(
|
||||
method.getName(), method.getParameterTypes());
|
||||
assertThat(declaredMethod.getDeclaringClass())
|
||||
.isEqualTo(DefaultTrackSelector.ParametersBuilder.class);
|
||||
if (method.getReturnType().equals(TrackSelectionParameters.Builder.class)) {
|
||||
assertThat(declaredMethod.getReturnType())
|
||||
.isEqualTo(DefaultTrackSelector.ParametersBuilder.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue