瀏覽代碼

Use placehold.co to replace the down site via.placeholder.com

This only effect test cases
DreamPiggy 2 年之前
父節點
當前提交
106a8d1a15

+ 1 - 1
Examples/SDWebImage Demo/MasterViewController.m

@@ -74,7 +74,7 @@
                     @"https://raw.githubusercontent.com/icons8/flat-color-icons/master/pdf/stack_of_photos.pdf",
                     @"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
                     @"https://res.cloudinary.com/dwpjzbyux/raw/upload/v1666474070/RawDemo/raw_vebed5.NEF",
-                    @"https://via.placeholder.com/200x200.jpg",
+                    @"https://placehold.co/200x200.jpg",
                     nil];
 
         for (int i=1; i<25; i++) {

+ 2 - 2
Tests/Tests/SDTestCase.m

@@ -11,9 +11,9 @@
 
 const int64_t kAsyncTestTimeout = 5;
 const int64_t kMinDelayNanosecond = NSEC_PER_MSEC * 100; // 0.1s
-NSString *const kTestJPEGURL = @"https://via.placeholder.com/50x50.jpg";
+NSString *const kTestJPEGURL = @"https://placehold.co/50x50.jpg";
 NSString *const kTestProgressiveJPEGURL = @"https://raw.githubusercontent.com/ibireme/YYImage/master/Demo/YYImageDemo/mew_progressive.jpg";
-NSString *const kTestPNGURL = @"https://via.placeholder.com/50x50.png";
+NSString *const kTestPNGURL = @"https://placehold.co/50x50.png";
 NSString *const kTestGIFURL = @"https://media.giphy.com/media/UEsrLdv7ugRTq/giphy.gif";
 NSString *const kTestAPNGPURL = @"https://upload.wikimedia.org/wikipedia/commons/1/14/Animated_PNG_example_bouncing_beach_ball.png";
 

+ 3 - 3
Tests/Tests/SDWebImageDownloaderTests.m

@@ -13,7 +13,7 @@
 #import "SDWebImageTestLoader.h"
 #import <compression.h>
 
-#define kPlaceholderTestURLTemplate @"https://via.placeholder.com/10000x%d.png"
+#define kPlaceholderTestURLTemplate @"https://placehold.co/10000x%d.png"
 
 /**
  *  Category for SDWebImageDownloader so we can access the operationClass
@@ -174,7 +174,7 @@
 - (void)test11ThatCancelWorks {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Cancel"];
     
-    NSURL *imageURL = [NSURL URLWithString:@"https://via.placeholder.com/1000x1000.png"];
+    NSURL *imageURL = [NSURL URLWithString:@"https://placehold.co/1000x1000.png"];
     SDWebImageDownloadToken *token = [[SDWebImageDownloader sharedDownloader]
                                       downloadImageWithURL:imageURL options:0 progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
                                           expect(error).notTo.beNil();
@@ -779,7 +779,7 @@
     // We move the logic into SDWebImageDownloaderOperation, which decode each callback's thumbnail size with different decoding pipeline, and callback independently
     // Note the progressiveLoad does not support this and always callback first size
     
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/501x501.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/501x501.png"];
     NSString *fullSizeKey = [SDWebImageManager.sharedManager cacheKeyForURL:url];
     [SDImageCache.sharedImageCache removeImageFromDiskForKey:fullSizeKey];
     for (int i = 490; i < 500; i++) {

+ 12 - 12
Tests/Tests/SDWebImageManagerTests.m

@@ -106,7 +106,7 @@
 
 - (void)test07ThatLoadImageWithSDWebImageRefreshCachedWorks {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Image download twice with SDWebImageRefresh failed"];
-    NSURL *originalImageURL = [NSURL URLWithString:@"https://via.placeholder.com/10x10.png"];
+    NSURL *originalImageURL = [NSURL URLWithString:@"https://placehold.co/10x10.png"];
     __block BOOL firstCompletion = NO;
     [[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
         expect(image).toNot.beNil();
@@ -116,7 +116,7 @@
         // Because we call completion before remove the operation from queue, so need a dispatch to avoid get the same operation again. Attention this trap.
         // One way to solve this is use another `NSURL instance` because we use `NSURL` as key but not `NSString`. However, this is implementation detail and no guarantee in the future.
         dispatch_async(dispatch_get_main_queue(), ^{
-            NSURL *newImageURL = [NSURL URLWithString:@"https://via.placeholder.com/10x10.png"];
+            NSURL *newImageURL = [NSURL URLWithString:@"https://placehold.co/10x10.png"];
             [[SDWebImageManager sharedManager] loadImageWithURL:newImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage * _Nullable image2, NSData * _Nullable data2, NSError * _Nullable error2, SDImageCacheType cacheType2, BOOL finished2, NSURL * _Nullable imageURL2) {
                 expect(image2).toNot.beNil();
                 expect(error2).to.beNil();
@@ -133,7 +133,7 @@
 
 - (void)test08ThatImageTransformerWork {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Image transformer work"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/80x60.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/80x60.png"];
     SDWebImageTestTransformer *transformer = [[SDWebImageTestTransformer alloc] init];
     
     transformer.testImage = [[UIImage alloc] initWithContentsOfFile:[self testJPEGPath]];
@@ -294,7 +294,7 @@
 
 - (void)test13ThatScaleDownLargeImageUseThumbnailDecoding {
     XCTestExpectation *expectation = [self expectationWithDescription:@"SDWebImageScaleDownLargeImages should translate to thumbnail decoding"];
-    NSURL *originalImageURL = [NSURL URLWithString:@"https://via.placeholder.com/2000x2000.png"]; // Max size for this API
+    NSURL *originalImageURL = [NSURL URLWithString:@"https://placehold.co/2000x2000.png"]; // Max size for this API
     NSUInteger defaultLimitBytes = SDImageCoderHelper.defaultScaleDownLimitBytes;
     SDImageCoderHelper.defaultScaleDownLimitBytes = 1000 * 1000 * 4; // Limit 1000x1000 pixel
     // From v5.5.0, the `SDWebImageScaleDownLargeImages` translate to `SDWebImageContextImageThumbnailPixelSize`, and works for progressive loading
@@ -336,7 +336,7 @@
 
 - (void)test14ThatCustomCacheAndLoaderWorks {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Custom Cache and Loader during manger query"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/100x100.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/100x100.png"];
     SDWebImageContext *context = @{
         SDWebImageContextImageCache : SDWebImageTestCache.sharedCache,
         SDWebImageContextImageLoader : SDWebImageTestLoader.sharedLoader
@@ -360,7 +360,7 @@
 
 - (void)test15ThatQueryCacheTypeWork {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Image query cache type works"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/101x101.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/101x101.png"];
     NSString *key = [SDWebImageManager.sharedManager cacheKeyForURL:url];
     NSData *testImageData = [NSData dataWithContentsOfFile:[self testJPEGPath]];
     [SDImageCache.sharedImageCache storeImageDataToDisk:testImageData forKey:key];
@@ -383,7 +383,7 @@
 
 - (void)test15ThatOriginalQueryCacheTypeWork {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Image original query cache type with transformer works"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/102x102.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/102x102.png"];
     SDWebImageTestTransformer *transformer = [[SDWebImageTestTransformer alloc] init];
     transformer.testImage = [[UIImage alloc] initWithContentsOfFile:[self testJPEGPath]];
     NSString *originalKey = [SDWebImageManager.sharedManager cacheKeyForURL:url];
@@ -419,7 +419,7 @@
 
 - (void)test16ThatTransformerUseDifferentCacheForOriginalAndTransformedImage {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Image transformer use different cache instance for original image and transformed image works"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/103x103.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/103x103.png"];
     SDWebImageTestTransformer *transformer = [[SDWebImageTestTransformer alloc] init];
     transformer.testImage = [[UIImage alloc] initWithContentsOfFile:[self testJPEGPath]];
     NSString *originalKey = [SDWebImageManager.sharedManager cacheKeyForURL:url];
@@ -505,7 +505,7 @@
         CGContextFillRect(context, CGRectMake(0, 0, fullSize.width, fullSize.height));
     }];
     expect(fullSizeImage.size).equal(fullSize);
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/500x500.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/500x500.png"];
     NSString *fullSizeKey = [SDWebImageManager.sharedManager cacheKeyForURL:url];
     NSData *fullSizeData = fullSizeImage.sd_imageData;
     [SDImageCache.sharedImageCache storeImageDataToDisk:fullSizeData forKey:fullSizeKey];
@@ -535,7 +535,7 @@
     // We move the logic into SDWebImageDownloaderOperation, which decode each callback's thumbnail size with different decoding pipeline, and callback independently
     // Note the progressiveLoad does not support this and always callback first size
     
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/501x501.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/501x501.png"];
     NSString *fullSizeKey = [SDWebImageManager.sharedManager cacheKeyForURL:url];
     [SDImageCache.sharedImageCache removeImageFromDiskForKey:fullSizeKey];
     for (int i = 490; i < 500; i++) {
@@ -563,7 +563,7 @@
 
 - (void)test20ThatContextPassDecodeOptionsWorks {
     XCTestExpectation *expectation = [self expectationWithDescription:@"The SDWebImageContextImageDecodeOptions should passed to the coder"];
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/502x502.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/502x502.png"];
     SDImageCoderOptions *originalDecodeOptions = @{@"Foo": @"Bar", SDImageCoderDecodeScaleFactor : @(2)}; // This will be override
     
     [SDWebImageManager.sharedManager loadImageWithURL:url options:0 context:@{SDWebImageContextImageScaleFactor : @(1), SDWebImageContextImageDecodeOptions : originalDecodeOptions} progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
@@ -579,7 +579,7 @@
 - (void)test21ThatQueryOriginalDiskCacheFromThumbnailShouldNotWriteBackDiskCache {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Using original disk cache to do thumbnail decoding or transformer, should not save back disk data again"];
     
-    NSURL *url = [NSURL URLWithString:@"https://via.placeholder.com/503x503.png"];
+    NSURL *url = [NSURL URLWithString:@"https://placehold.co/503x503.png"];
     NSString *originalKey = url.absoluteString;
     // 1. Store the disk data to original cache
     CGSize fullSize = CGSizeMake(503, 503);

+ 14 - 14
Tests/Tests/SDWebImagePrefetcherTests.m

@@ -34,9 +34,9 @@
 - (void)test02PrefetchMultipleImages {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Correct prefetch of multiple images"];
     
-    NSArray *imageURLs = @[@"https://via.placeholder.com/20x20.jpg",
-                           @"https://via.placeholder.com/30x30.jpg",
-                           @"https://via.placeholder.com/40x40.jpg"];
+    NSArray *imageURLs = @[@"https://placehold.co/20x20.jpg",
+                           @"https://placehold.co/30x30.jpg",
+                           @"https://placehold.co/40x40.jpg"];
     
     __block NSUInteger numberOfPrefetched = 0;
     
@@ -72,10 +72,10 @@
 - (void)test04PrefetchWithMultipleArrayDifferentQueueWorks {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Prefetch with multiple array at different queue failed"];
     
-    NSArray *imageURLs1 = @[@"https://via.placeholder.com/20x20.jpg",
-                            @"https://via.placeholder.com/30x30.jpg"];
-    NSArray *imageURLs2 = @[@"https://via.placeholder.com/30x30.jpg",
-                           @"https://via.placeholder.com/40x40.jpg"];
+    NSArray *imageURLs1 = @[@"https://placehold.co/20x20.jpg",
+                            @"https://placehold.co/30x30.jpg"];
+    NSArray *imageURLs2 = @[@"https://placehold.co/30x30.jpg",
+                           @"https://placehold.co/40x40.jpg"];
     dispatch_queue_t queue1 = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
     dispatch_queue_t queue2 = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
     __block int numberOfPrefetched1 = 0;
@@ -120,7 +120,7 @@
     // This test also test large URLs and thread-safe problem. You can tested with 2000 urls and get the correct result locally. However, due to the limit of CI, 20 is enough.
     NSMutableArray<NSURL *> *imageURLs = [NSMutableArray arrayWithCapacity:20];
     for (size_t i = 1; i <= 20; i++) {
-        NSString *url = [NSString stringWithFormat:@"https://via.placeholder.com/%zux%zu.jpg", i, i];
+        NSString *url = [NSString stringWithFormat:@"https://placehold.co/%zux%zu.jpg", i, i];
         [imageURLs addObject:[NSURL URLWithString:url]];
     }
     self.prefetcher = [SDWebImagePrefetcher new];
@@ -141,9 +141,9 @@
 }
 
 - (void)test06PrefetchCancelToken {
-    NSArray *imageURLs = @[@"https://via.placeholder.com/20x20.jpg",
-                           @"https://via.placeholder.com/30x30.jpg",
-                           @"https://via.placeholder.com/40x40.jpg"];
+    NSArray *imageURLs = @[@"https://placehold.co/20x20.jpg",
+                           @"https://placehold.co/30x30.jpg",
+                           @"https://placehold.co/40x40.jpg"];
     SDWebImagePrefetcher *prefetcher = [[SDWebImagePrefetcher alloc] init];
     SDWebImagePrefetchToken *token = [prefetcher prefetchURLs:imageURLs];
     expect(prefetcher.runningTokens.count).equal(1);
@@ -154,9 +154,9 @@
 - (void)test07DownloaderCancelDuringPrefetching {
     XCTestExpectation *expectation = [self expectationWithDescription:@"Downloader cancel during prefetch should not hung up"];
     
-    NSArray *imageURLs = @[@"https://via.placeholder.com/5000x5000.jpg",
-                           @"https://via.placeholder.com/6000x6000.jpg",
-                           @"https://via.placeholder.com/7000x7000.jpg"];
+    NSArray *imageURLs = @[@"https://placehold.co/5000x5000.jpg",
+                           @"https://placehold.co/6000x6000.jpg",
+                           @"https://placehold.co/7000x7000.jpg"];
     for (NSString *url in imageURLs) {
         [SDImageCache.sharedImageCache removeImageFromDiskForKey:url];
     }