Authored by Matt Galloway

Switch to built in XCTest async

@@ -3,7 +3,6 @@ workspace '../SDWebImage' @@ -3,7 +3,6 @@ workspace '../SDWebImage'
3 3
4 def import_pods 4 def import_pods
5 pod 'Expecta' # A Matcher Framework for Objective-C/Cocoa 5 pod 'Expecta' # A Matcher Framework for Objective-C/Cocoa
6 - pod 'XCTestAsync' # Extension to XCTest for asynchronous testing  
7 pod 'SDWebImage', :path => '../' 6 pod 'SDWebImage', :path => '../'
8 end 7 end
9 8
@@ -11,4 +10,4 @@ target :ios do @@ -11,4 +10,4 @@ target :ios do
11 platform :ios, '5.0' 10 platform :ios, '5.0'
12 link_with 'Tests' 11 link_with 'Tests'
13 import_pods 12 import_pods
14 -end  
  13 +end
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 10
11 11
12 #import <XCTest/XCTest.h> 12 #import <XCTest/XCTest.h>
13 -#import <XCTestAsync/XCTestAsync.h>  
14 #import <Expecta.h> 13 #import <Expecta.h>
15 14
16 #import "SDImageCache.h" 15 #import "SDImageCache.h"
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 10
11 11
12 #import <XCTest/XCTest.h> 12 #import <XCTest/XCTest.h>
13 -#import <XCTestAsync/XCTestAsync.h>  
14 #import <Expecta.h> 13 #import <Expecta.h>
15 14
16 #import "SDWebImageManager.h" 15 #import "SDWebImageManager.h"
@@ -37,20 +36,25 @@ static int64_t kAsyncTestTimeout = 5; @@ -37,20 +36,25 @@ static int64_t kAsyncTestTimeout = 5;
37 } 36 }
38 37
39 - (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync { 38 - (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
  39 + __block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
  40 +
40 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"]; 41 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"];
41 42
42 [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 43 [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
43 expect(image).toNot.beNil(); 44 expect(image).toNot.beNil();
44 expect(error).to.beNil(); 45 expect(error).to.beNil();
45 expect(originalImageURL).to.equal(imageURL); 46 expect(originalImageURL).to.equal(imageURL);
46 -  
47 - XCAsyncSuccess(); 47 +
  48 + [expectation fulfill];
  49 + expectation = nil;
48 }]; 50 }];
49 -  
50 - XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out"); 51 +
  52 + [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
51 } 53 }
52 54
53 - (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync { 55 - (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
  56 + __block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
  57 +
54 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"]; 58 NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
55 59
56 [[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 60 [[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; @@ -58,10 +62,11 @@ static int64_t kAsyncTestTimeout = 5;
58 expect(error).toNot.beNil(); 62 expect(error).toNot.beNil();
59 expect(originalImageURL).to.equal(imageURL); 63 expect(originalImageURL).to.equal(imageURL);
60 64
61 - XCAsyncSuccess(); 65 + [expectation fulfill];
  66 + expectation = nil;
62 }]; 67 }];
63 68
64 - XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out"); 69 + [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
65 } 70 }
66 71
67 @end 72 @end
@@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
10 10
11 11
12 #import <XCTest/XCTest.h> 12 #import <XCTest/XCTest.h>
13 -#import <XCTestAsync/XCTestAsync.h>  
14 #import <Expecta.h> 13 #import <Expecta.h>
15 14
16 #import "UIImage+MultiFormat.h" 15 #import "UIImage+MultiFormat.h"