Switch to built in XCTest async
This commit is contained in:
parent
5f4d7f44b4
commit
66a6873b2c
|
@ -3,7 +3,6 @@ workspace '../SDWebImage'
|
|||
|
||||
def import_pods
|
||||
pod 'Expecta' # A Matcher Framework for Objective-C/Cocoa
|
||||
pod 'XCTestAsync' # Extension to XCTest for asynchronous testing
|
||||
pod 'SDWebImage', :path => '../'
|
||||
end
|
||||
|
||||
|
@ -11,4 +10,4 @@ target :ios do
|
|||
platform :ios, '5.0'
|
||||
link_with 'Tests'
|
||||
import_pods
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <XCTestAsync/XCTestAsync.h>
|
||||
#import <Expecta.h>
|
||||
|
||||
#import "SDImageCache.h"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <XCTestAsync/XCTestAsync.h>
|
||||
#import <Expecta.h>
|
||||
|
||||
#import "SDWebImageManager.h"
|
||||
|
@ -37,20 +36,25 @@ static int64_t kAsyncTestTimeout = 5;
|
|||
}
|
||||
|
||||
- (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
|
||||
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
|
||||
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"];
|
||||
|
||||
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
expect(image).toNot.beNil();
|
||||
expect(error).to.beNil();
|
||||
expect(originalImageURL).to.equal(imageURL);
|
||||
|
||||
XCAsyncSuccess();
|
||||
|
||||
[expectation fulfill];
|
||||
expectation = nil;
|
||||
}];
|
||||
|
||||
XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
|
||||
|
||||
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
|
||||
}
|
||||
|
||||
- (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
|
||||
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
|
||||
|
||||
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
|
||||
|
||||
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
|
@ -58,10 +62,11 @@ static int64_t kAsyncTestTimeout = 5;
|
|||
expect(error).toNot.beNil();
|
||||
expect(originalImageURL).to.equal(imageURL);
|
||||
|
||||
XCAsyncSuccess();
|
||||
[expectation fulfill];
|
||||
expectation = nil;
|
||||
}];
|
||||
|
||||
XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
|
||||
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <XCTestAsync/XCTestAsync.h>
|
||||
#import <Expecta.h>
|
||||
|
||||
#import "UIImage+MultiFormat.h"
|
||||
|
|
Loading…
Reference in New Issue