use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method selectBaseUrl_excludeByPriority_excludesAllBaseUrlsOfSamePriority.
@Test
public void selectBaseUrl_excludeByPriority_excludesAllBaseUrlsOfSamePriority() {
Random mockRandom = mock(Random.class);
when(mockRandom.nextInt(anyInt())).thenReturn(0);
BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList(mockRandom);
List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
"a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
1), new BaseUrl(/* url= */
"b", /* serviceLocation= */
"b", /* priority= */
1, /* weight= */
99), new BaseUrl(/* url= */
"c", /* serviceLocation= */
"c", /* priority= */
2, /* weight= */
1));
baseUrlExclusionList.exclude(baseUrls.get(0), 5000);
ShadowSystemClock.advanceBy(Duration.ofMillis(4999));
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrls).url).isEqualTo("c");
ShadowSystemClock.advanceBy(Duration.ofMillis(1));
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrls).url).isEqualTo("a");
}
use of androidx.media3.exoplayer.dash.manifest.BaseUrl in project media by androidx.
the class BaseUrlExclusionListTest method selectBaseUrl_samePriority_choiceFromSameElementsRandomOnlyOnceSameAfterwards.
@Test
public void selectBaseUrl_samePriority_choiceFromSameElementsRandomOnlyOnceSameAfterwards() {
List<BaseUrl> baseUrlsVideo = ImmutableList.of(new BaseUrl(/* url= */
"a/v", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
99), new BaseUrl(/* url= */
"b/v", /* serviceLocation= */
"b", /* priority= */
1, /* weight= */
1));
List<BaseUrl> baseUrlsAudio = ImmutableList.of(new BaseUrl(/* url= */
"a/a", /* serviceLocation= */
"a", /* priority= */
1, /* weight= */
99), new BaseUrl(/* url= */
"b/a", /* serviceLocation= */
"b", /* priority= */
1, /* weight= */
1));
Random mockRandom = mock(Random.class);
BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList(mockRandom);
when(mockRandom.nextInt(anyInt())).thenReturn(99);
for (int i = 0; i < 5; i++) {
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrlsVideo).serviceLocation).isEqualTo("b");
assertThat(baseUrlExclusionList.selectBaseUrl(baseUrlsAudio).serviceLocation).isEqualTo("b");
}
// Random is used only once.
verify(mockRandom).nextInt(/* bound= */
100);
verifyNoMoreInteractions(mockRandom);
}
Aggregations