11package org .schabi .newpipe .extractor .services ;
22
3+ import org .schabi .newpipe .extractor .Image ;
34import org .schabi .newpipe .extractor .InfoItem ;
45import org .schabi .newpipe .extractor .ListExtractor ;
56import org .schabi .newpipe .extractor .Page ;
1011import org .schabi .newpipe .extractor .playlist .PlaylistInfoItem ;
1112import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
1213
14+ import javax .annotation .Nullable ;
15+ import java .util .Collection ;
1316import java .util .HashSet ;
1417import java .util .List ;
1518import java .util .Set ;
1619
17- import static org .junit .jupiter .api .Assertions .*;
18- import static org .schabi .newpipe .extractor .ExtractorAsserts .*;
20+ import static org .junit .jupiter .api .Assertions .assertEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
23+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25+ import static org .junit .jupiter .api .Assertions .fail ;
26+ import static org .schabi .newpipe .extractor .ExtractorAsserts .assertEmptyErrors ;
27+ import static org .schabi .newpipe .extractor .ExtractorAsserts .assertGreaterOrEqual ;
28+ import static org .schabi .newpipe .extractor .ExtractorAsserts .assertIsSecureUrl ;
29+ import static org .schabi .newpipe .extractor .ExtractorAsserts .assertNotEmpty ;
1930import static org .schabi .newpipe .extractor .StreamingService .LinkType ;
2031import static org .schabi .newpipe .extractor .utils .Utils .isNullOrEmpty ;
2132
@@ -28,9 +39,9 @@ public static void defaultTestListOfItems(StreamingService expectedService, List
2839 for (InfoItem item : itemsList ) {
2940 assertIsSecureUrl (item .getUrl ());
3041
31- final String thumbnailUrl = item .getThumbnailUrl ();
32- if (!isNullOrEmpty (thumbnailUrl )) {
33- assertIsSecureUrl ( thumbnailUrl );
42+ final List < Image > thumbnails = item .getThumbnails ();
43+ if (!isNullOrEmpty (thumbnails )) {
44+ defaultTestImageCollection ( thumbnails );
3445 }
3546 assertNotNull (item .getInfoType (), "InfoItem type not set: " + item );
3647 assertEquals (expectedService .getServiceId (), item .getServiceId (), "Unexpected item service id" );
@@ -44,9 +55,9 @@ public static void defaultTestListOfItems(StreamingService expectedService, List
4455 assertExpectedLinkType (expectedService , uploaderUrl , LinkType .CHANNEL );
4556 }
4657
47- final String uploaderAvatarUrl = streamInfoItem .getUploaderAvatarUrl ();
48- if (!isNullOrEmpty (uploaderAvatarUrl )) {
49- assertIsSecureUrl ( uploaderAvatarUrl );
58+ final List < Image > uploaderAvatars = streamInfoItem .getUploaderAvatars ();
59+ if (!isNullOrEmpty (uploaderAvatars )) {
60+ defaultTestImageCollection ( uploaderAvatars );
5061 }
5162
5263 assertExpectedLinkType (expectedService , streamInfoItem .getUrl (), LinkType .STREAM );
@@ -134,4 +145,16 @@ public static void defaultTestGetPageInNewExtractor(ListExtractor<? extends Info
134145 final ListExtractor .InfoItemsPage <? extends InfoItem > page = newExtractor .getPage (nextPage );
135146 defaultTestListOfItems (extractor .getService (), page .getItems (), page .getErrors ());
136147 }
148+
149+ public static void defaultTestImageCollection (
150+ @ Nullable final Collection <Image > imageCollection ) {
151+ assertNotNull (imageCollection );
152+ imageCollection .forEach (image -> {
153+ assertIsSecureUrl (image .getUrl ());
154+ assertGreaterOrEqual (Image .HEIGHT_UNKNOWN , image .getHeight (),
155+ "Unexpected image height: " + image .getHeight ());
156+ assertGreaterOrEqual (Image .WIDTH_UNKNOWN , image .getWidth (),
157+ "Unexpected image width: " + image .getWidth ());
158+ });
159+ }
137160}
0 commit comments