Skip to content

Commit

Permalink
Merge pull request #1107 from Isira-Seneviratne/Locale_forLanguageTag
Browse files Browse the repository at this point in the history
Use Locale.forLanguageTag() in tests
  • Loading branch information
TobiGr authored Sep 18, 2023
2 parents 90aed06 + 1779032 commit 3be76a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This class contains a simple implementation of {@link Locale#forLanguageTag(String)} for Android
* API levels below 21 (Lollipop). This is needed as core library desugaring does not backport that
* method as of this writing.
*
* <br>
* Relevant issue: https://issuetracker.google.com/issues/171182330
*/
public final class LocaleCompat {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.schabi.newpipe.extractor.services.media_ccc;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContainsImageUrlInImageCollection;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.schabi.newpipe.downloader.DownloaderTestImpl;
Expand All @@ -10,19 +15,13 @@
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.utils.LocaleCompat;

import javax.annotation.Nullable;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertContainsImageUrlInImageCollection;
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC;
import javax.annotation.Nullable;

/**
* Test {@link MediaCCCStreamExtractor}
Expand Down Expand Up @@ -96,7 +95,7 @@ public void testAudioStreams() throws Exception {
super.testAudioStreams();
final List<AudioStream> audioStreams = extractor.getAudioStreams();
assertEquals(2, audioStreams.size());
final Locale expectedLocale = LocaleCompat.forLanguageTag("deu");
final Locale expectedLocale = Locale.forLanguageTag("deu");
assertTrue(audioStreams.stream().allMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), expectedLocale)));
}
Expand Down Expand Up @@ -174,7 +173,7 @@ public void testAudioStreams() throws Exception {
super.testAudioStreams();
final List<AudioStream> audioStreams = extractor.getAudioStreams();
assertEquals(2, audioStreams.size());
final Locale expectedLocale = LocaleCompat.forLanguageTag("eng");
final Locale expectedLocale = Locale.forLanguageTag("eng");
assertTrue(audioStreams.stream().allMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), expectedLocale)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
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;
Expand Down Expand Up @@ -560,7 +559,7 @@ void testCheckAudioStreams() throws Exception {
.anyMatch(audioStream ->
"English original".equals(audioStream.getAudioTrackName())));

final Locale hindiLocale = LocaleCompat.forLanguageTag("hi");
final Locale hindiLocale = Locale.forLanguageTag("hi");
assertTrue(audioStreams.stream()
.anyMatch(audioStream ->
Objects.equals(audioStream.getAudioLocale(), hindiLocale)));
Expand Down

0 comments on commit 3be76a6

Please sign in to comment.