|
17 | 17 |
|
18 | 18 | import static androidx.media3.exoplayer.dash.manifest.BaseUrl.DEFAULT_DVB_PRIORITY;
|
19 | 19 | import static androidx.media3.exoplayer.dash.manifest.BaseUrl.DEFAULT_WEIGHT;
|
| 20 | +import static androidx.media3.exoplayer.dash.manifest.BaseUrl.PRIORITY_UNSET; |
20 | 21 | import static androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS;
|
21 | 22 | import static com.google.common.truth.Truth.assertThat;
|
22 | 23 | import static org.mockito.ArgumentMatchers.anyInt;
|
@@ -274,4 +275,85 @@ public void getPriorityCount_correctPriorityCount() {
|
274 | 275 | assertThat(BaseUrlExclusionList.getPriorityCount(baseUrls)).isEqualTo(3);
|
275 | 276 | assertThat(BaseUrlExclusionList.getPriorityCount(ImmutableList.of())).isEqualTo(0);
|
276 | 277 | }
|
| 278 | + |
| 279 | + @Test |
| 280 | + public void getPriorityCountAfterExclusion_priorityUnset_correctPriorityCount() { |
| 281 | + List<BaseUrl> baseUrls = |
| 282 | + ImmutableList.of( |
| 283 | + new BaseUrl( |
| 284 | + /* url= */ "a", |
| 285 | + /* serviceLocation= */ "a", |
| 286 | + /* priority= */ PRIORITY_UNSET, |
| 287 | + /* weight= */ 1), |
| 288 | + new BaseUrl( |
| 289 | + /* url= */ "b", |
| 290 | + /* serviceLocation= */ "b", |
| 291 | + /* priority= */ PRIORITY_UNSET, |
| 292 | + /* weight= */ 1), |
| 293 | + new BaseUrl( |
| 294 | + /* url= */ "c", |
| 295 | + /* serviceLocation= */ "c", |
| 296 | + /* priority= */ PRIORITY_UNSET, |
| 297 | + /* weight= */ 1), |
| 298 | + new BaseUrl( |
| 299 | + /* url= */ "d", |
| 300 | + /* serviceLocation= */ "d", |
| 301 | + /* priority= */ PRIORITY_UNSET, |
| 302 | + /* weight= */ 1), |
| 303 | + new BaseUrl( |
| 304 | + /* url= */ "e", |
| 305 | + /* serviceLocation= */ "e", |
| 306 | + /* priority= */ PRIORITY_UNSET, |
| 307 | + /* weight= */ 1)); |
| 308 | + BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList(); |
| 309 | + |
| 310 | + // Empty base URL list. |
| 311 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(ImmutableList.of())) |
| 312 | + .isEqualTo(0); |
| 313 | + |
| 314 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(5); |
| 315 | + // Exclude base urls. |
| 316 | + baseUrlExclusionList.exclude(baseUrls.get(0), DEFAULT_LOCATION_EXCLUSION_MS); |
| 317 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(4); |
| 318 | + baseUrlExclusionList.exclude(baseUrls.get(1), 2 * DEFAULT_LOCATION_EXCLUSION_MS); |
| 319 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3); |
| 320 | + baseUrlExclusionList.exclude(baseUrls.get(3), 3 * DEFAULT_LOCATION_EXCLUSION_MS); |
| 321 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(2); |
| 322 | + // Time passes. |
| 323 | + ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS)); |
| 324 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3); |
| 325 | + ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS)); |
| 326 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(4); |
| 327 | + ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS)); |
| 328 | + assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(5); |
| 329 | + } |
| 330 | + |
| 331 | + @Test |
| 332 | + public void getPriorityCount_priorityUnset_correctPriorityCount() { |
| 333 | + List<BaseUrl> baseUrls = |
| 334 | + ImmutableList.of( |
| 335 | + new BaseUrl( |
| 336 | + /* url= */ "a", |
| 337 | + /* serviceLocation= */ "a", |
| 338 | + /* priority= */ PRIORITY_UNSET, |
| 339 | + /* weight= */ 1), |
| 340 | + new BaseUrl( |
| 341 | + /* url= */ "b", |
| 342 | + /* serviceLocation= */ "b", |
| 343 | + /* priority= */ PRIORITY_UNSET, |
| 344 | + /* weight= */ 1), |
| 345 | + new BaseUrl( |
| 346 | + /* url= */ "c", |
| 347 | + /* serviceLocation= */ "c", |
| 348 | + /* priority= */ PRIORITY_UNSET, |
| 349 | + /* weight= */ 1), |
| 350 | + new BaseUrl( |
| 351 | + /* url= */ "d", |
| 352 | + /* serviceLocation= */ "d", |
| 353 | + /* priority= */ PRIORITY_UNSET, |
| 354 | + /* weight= */ 1)); |
| 355 | + |
| 356 | + assertThat(BaseUrlExclusionList.getPriorityCount(baseUrls)).isEqualTo(4); |
| 357 | + assertThat(BaseUrlExclusionList.getPriorityCount(ImmutableList.of())).isEqualTo(0); |
| 358 | + } |
277 | 359 | }
|
0 commit comments