diff --git a/Tests/Podfile b/Tests/Podfile index fb5409f..f366e6a 100644 --- a/Tests/Podfile +++ b/Tests/Podfile @@ -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 \ No newline at end of file +end diff --git a/Tests/Tests/SDImageCacheTests.m b/Tests/Tests/SDImageCacheTests.m index 4858efd..9451e68 100644 --- a/Tests/Tests/SDImageCacheTests.m +++ b/Tests/Tests/SDImageCacheTests.m @@ -10,7 +10,6 @@ #import -#import #import #import "SDImageCache.h" diff --git a/Tests/Tests/SDWebImageManagerTests.m b/Tests/Tests/SDWebImageManagerTests.m index 9465fbf..ebb52a4 100644 --- a/Tests/Tests/SDWebImageManagerTests.m +++ b/Tests/Tests/SDWebImageManagerTests.m @@ -10,7 +10,6 @@ #import -#import #import #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 diff --git a/Tests/Tests/UIImageMultiFormatTests.m b/Tests/Tests/UIImageMultiFormatTests.m index a757da8..00b3954 100644 --- a/Tests/Tests/UIImageMultiFormatTests.m +++ b/Tests/Tests/UIImageMultiFormatTests.m @@ -10,7 +10,6 @@ #import -#import #import #import "UIImage+MultiFormat.h"