Switch to built in XCTest async

This commit is contained in:
Matt Galloway 2014-09-15 11:55:12 +01:00
parent 5f4d7f44b4
commit 66a6873b2c
4 changed files with 13 additions and 11 deletions

View File

@ -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

View File

@ -10,7 +10,6 @@
#import <XCTest/XCTest.h>
#import <XCTestAsync/XCTestAsync.h>
#import <Expecta.h>
#import "SDImageCache.h"

View File

@ -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

View File

@ -10,7 +10,6 @@
#import <XCTest/XCTest.h>
#import <XCTestAsync/XCTestAsync.h>
#import <Expecta.h>
#import "UIImage+MultiFormat.h"