[YouTube] Edit YoutubeStreamExtractorDefaultTest.AudioTrackLanguage to test audio locale property

The Hindi audio track language presence test has been changed from audio track
label to audio locale.
This commit is contained in:
AudricV 2023-01-31 19:16:14 +01:00
parent 034f82dae7
commit 7f0269c4c7
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
1 changed files with 12 additions and 8 deletions

View File

@ -49,6 +49,7 @@ import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamSegment;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.utils.LocaleCompat;
import java.io.IOException;
import java.net.MalformedURLException;
@ -56,6 +57,8 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import javax.annotation.Nullable;
@ -547,19 +550,20 @@ public class YoutubeStreamExtractorDefaultTest {
@Test
void testCheckAudioStreams() throws Exception {
assertFalse(extractor.getAudioStreams().isEmpty());
final List<AudioStream> audioStreams = extractor.getAudioStreams();
assertFalse(audioStreams.isEmpty());
for (final AudioStream audioStream : extractor.getAudioStreams()) {
assertNotNull(audioStream.getAudioTrackName());
for (final AudioStream stream : audioStreams) {
assertNotNull(stream.getAudioTrackName());
}
assertTrue(extractor.getAudioStreams()
.stream()
assertTrue(audioStreams.stream()
.anyMatch(audioStream -> "English".equals(audioStream.getAudioTrackName())));
assertTrue(extractor.getAudioStreams()
.stream()
.anyMatch(audioStream -> "Hindi".equals(audioStream.getAudioTrackName())));
final Locale hindiLocale = LocaleCompat.forLanguageTag("hi");
assertTrue(audioStreams.stream()
.anyMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), hindiLocale)));
}
}