Switched all the tests from using https://s3.amazonaws.com/fast-image-cache/demo-images/* images which are big and sometimes fail to arrive in 5 seconds (before the test can timeout) to smaller images, basically using http://via.placeholder.com/ like http://via.placeholder.com/50x50.jpg or http://via.placeholder.com/200x200.png
This should speed up the tests a bit and also avoid some of the random failures due to timeout
This commit is contained in:
parent
90c90a06bc
commit
86151183f6
|
@ -76,6 +76,7 @@
|
|||
@"http://littlesvr.ca/apng/images/world-cup-2014-42.webp",
|
||||
@"https://isparta.github.io/compare-webp/image/gif_webp/webp/2.webp",
|
||||
@"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png",
|
||||
@"http://via.placeholder.com/200x200.jpg"
|
||||
nil];
|
||||
|
||||
for (int i=0; i<100; i++) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"UIImageView setImageWithURL"];
|
||||
|
||||
UIImageView *imageView = [[UIImageView alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage050.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[imageView sd_setImageWithURL:originalImageURL
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
expect(image).toNot.beNil();
|
||||
|
@ -42,7 +42,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"UIImageView setHighlightedImageWithURL"];
|
||||
|
||||
UIImageView *imageView = [[UIImageView alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage051.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[imageView sd_setHighlightedImageWithURL:originalImageURL
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
expect(image).toNot.beNil();
|
||||
|
@ -58,7 +58,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"MKAnnotationView setImageWithURL"];
|
||||
|
||||
MKAnnotationView *annotationView = [[MKAnnotationView alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage052.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[annotationView sd_setImageWithURL:originalImageURL
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
expect(image).toNot.beNil();
|
||||
|
@ -74,7 +74,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"UIButton setImageWithURL normalState"];
|
||||
|
||||
UIButton *button = [[UIButton alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage053.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[button sd_setImageWithURL:originalImageURL
|
||||
forState:UIControlStateNormal
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
|
@ -91,7 +91,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"UIButton setImageWithURL highlightedState"];
|
||||
|
||||
UIButton *button = [[UIButton alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage054.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[button sd_setImageWithURL:originalImageURL
|
||||
forState:UIControlStateHighlighted
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
|
@ -108,7 +108,7 @@
|
|||
XCTestExpectation *expectation = [self expectationWithDescription:@"UIButton setBackgroundImageWithURL normalState"];
|
||||
|
||||
UIButton *button = [[UIButton alloc] init];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage055.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[button sd_setBackgroundImageWithURL:originalImageURL
|
||||
forState:UIControlStateNormal
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
|
|
|
@ -13,11 +13,13 @@
|
|||
#import <XCTest/XCTest.h>
|
||||
#import <Expecta/Expecta.h>
|
||||
|
||||
extern const int64_t kAsyncTestTimeout;
|
||||
FOUNDATION_EXPORT const int64_t kAsyncTestTimeout;
|
||||
FOUNDATION_EXPORT NSString * _Nonnull const kTestJpegURL;
|
||||
FOUNDATION_EXPORT NSString * _Nonnull const kTestPNGURL;
|
||||
|
||||
@interface SDTestCase : XCTestCase
|
||||
|
||||
- (void)waitForExpectationsWithCommonTimeout;
|
||||
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler;
|
||||
- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(nullable XCWaitCompletionHandler)handler;
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#import "SDTestCase.h"
|
||||
|
||||
const int64_t kAsyncTestTimeout = 5;
|
||||
NSString *const kTestJpegURL = @"http://via.placeholder.com/50x50.jpg";
|
||||
NSString *const kTestPNGURL = @"http://via.placeholder.com/50x50.png";
|
||||
|
||||
@implementation SDTestCase
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
|
||||
- (void)test04ThatASimpleDownloadWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Simple download"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage004.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:0 progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
|
@ -145,7 +145,7 @@
|
|||
|
||||
- (void)test09ThatProgressiveJPEGWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Progressive JPEG download"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage009.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderProgressiveDownload progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
|
@ -175,7 +175,7 @@
|
|||
- (void)test11ThatCancelWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Cancel"];
|
||||
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage011.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
SDWebImageDownloadToken *token = [[SDWebImageDownloader sharedDownloader]
|
||||
downloadImageWithURL:imageURL options:0 progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
XCTFail(@"Should not get here");
|
||||
|
@ -195,7 +195,7 @@
|
|||
|
||||
- (void)test12ThatWeCanUseAnotherSessionForEachDownloadOperation {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Owned session"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage012.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:imageURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:15];
|
||||
request.HTTPShouldUsePipelining = YES;
|
||||
|
@ -221,7 +221,7 @@
|
|||
|
||||
- (void)test13ThatDownloadCanContinueWhenTheAppEntersBackground {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Simple download"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage013.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:SDWebImageDownloaderContinueInBackground progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
|
@ -233,8 +233,8 @@
|
|||
}
|
||||
|
||||
- (void)test14ThatPNGWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"WEBP"];
|
||||
NSURL *imageURL = [NSURL URLWithString:@"https://nr-platform.s3.amazonaws.com/uploads/platform/published_extension/branding_icon/275/AmazonS3.png"];
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"PNG"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestPNGURL];
|
||||
[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:imageURL options:0 progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
|
||||
if (image && data && !error && finished) {
|
||||
[expectation fulfill];
|
||||
|
@ -282,7 +282,7 @@
|
|||
- (void)test20ThatDownloadingSameURLTwiceAndCancellingFirstWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Correct image downloads"];
|
||||
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage020.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
|
||||
SDWebImageDownloadToken *token1 = [[SDWebImageDownloader sharedDownloader]
|
||||
downloadImageWithURL:imageURL
|
||||
|
@ -320,7 +320,7 @@
|
|||
- (void)test21ThatCancelingDownloadThenRequestingAgainWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Correct image downloads"];
|
||||
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage021.jpg"];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
|
||||
SDWebImageDownloadToken *token1 = [[SDWebImageDownloader sharedDownloader]
|
||||
downloadImageWithURL:imageURL
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#import "SDTestCase.h"
|
||||
#import <SDWebImage/SDWebImageManager.h>
|
||||
|
||||
NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg";
|
||||
|
||||
@interface SDWebImageManagerTests : SDTestCase
|
||||
|
||||
@end
|
||||
|
@ -25,7 +23,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag
|
|||
- (void)test02ThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
|
||||
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
|
||||
|
||||
NSURL *originalImageURL = [NSURL URLWithString:workingImageURL];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
|
||||
[[SDWebImageManager sharedManager] loadImageWithURL:originalImageURL
|
||||
options:SDWebImageRefreshCached
|
||||
|
@ -65,7 +63,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag
|
|||
|
||||
- (void)test04CachedImageExistsForURL {
|
||||
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image exists in cache"];
|
||||
NSURL *imageURL = [NSURL URLWithString:workingImageURL];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageManager sharedManager] cachedImageExistsForURL:imageURL completion:^(BOOL isInCache) {
|
||||
if (isInCache) {
|
||||
[expectation fulfill];
|
||||
|
@ -78,7 +76,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag
|
|||
|
||||
- (void)test05DiskImageExistsForURL {
|
||||
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image exists in disk cache"];
|
||||
NSURL *imageURL = [NSURL URLWithString:workingImageURL];
|
||||
NSURL *imageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDWebImageManager sharedManager] diskImageExistsForURL:imageURL completion:^(BOOL isInCache) {
|
||||
if (isInCache) {
|
||||
[expectation fulfill];
|
||||
|
@ -92,7 +90,9 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag
|
|||
- (void)test06CancellAll {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Cancel"];
|
||||
|
||||
NSURL *imageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage006.jpg"];
|
||||
// need a bigger image here, that is why we don't use kTestJpegURL
|
||||
// if the image is too small, it will get downloaded before we can cancel :)
|
||||
NSURL *imageURL = [NSURL URLWithString:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg"];
|
||||
[[SDWebImageManager sharedManager] loadImageWithURL:imageURL options:0 progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
XCTFail(@"Should not get here");
|
||||
}];
|
||||
|
@ -110,7 +110,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag
|
|||
|
||||
- (void)test07ThatLoadImageWithSDWebImageRefreshCachedWorks {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Image download twice with SDWebImageRefresh failed"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage007.jpg"];
|
||||
NSURL *originalImageURL = [NSURL URLWithString:kTestJpegURL];
|
||||
[[SDImageCache sharedImageCache] clearDiskOnCompletion:nil];
|
||||
|
||||
[[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) {
|
||||
|
|
|
@ -24,13 +24,9 @@
|
|||
- (void)test02PrefetchMultipleImages {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Correct prefetch of multiple images"];
|
||||
|
||||
NSMutableArray *imageURLs = [NSMutableArray array];
|
||||
|
||||
for (int i=40; i<43; i++) {
|
||||
NSString *imageURLString = [NSString stringWithFormat:@"https://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage%03d.jpg", i];
|
||||
NSURL *imageURL = [NSURL URLWithString:imageURLString];
|
||||
[imageURLs addObject:imageURL];
|
||||
}
|
||||
NSArray *imageURLs = @[@"http://via.placeholder.com/20x20.jpg",
|
||||
@"http://via.placeholder.com/30x30.jpg",
|
||||
@"http://via.placeholder.com/40x40.jpg"];
|
||||
|
||||
__block int numberOfPrefetched = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue