10
10
11
11
12
12
#import < XCTest/XCTest.h>
13
- #import < XCTestAsync/XCTestAsync.h>
14
13
#import < Expecta.h>
15
14
16
15
#import " SDWebImageManager.h"
@@ -37,31 +36,37 @@ - (void)tearDown
37
36
}
38
37
39
38
- (void )testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
39
+ __block XCTestExpectation *expectation = [self expectationWithDescription: @" Image download completes" ];
40
+
40
41
NSURL *originalImageURL = [NSURL URLWithString: @" http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705" ];
41
42
42
43
[[SDWebImageManager sharedManager ] downloadImageWithURL: originalImageURL options: SDWebImageRefreshCached progress: nil completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
43
44
expect (image).toNot .beNil ();
44
45
expect (error).to .beNil ();
45
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
55
- (void )testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
56
+ __block XCTestExpectation *expectation = [self expectationWithDescription: @" Image download completes" ];
57
+
54
58
NSURL *originalImageURL = [NSURL URLWithString: @" http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png" ];
55
59
56
60
[[SDWebImageManager sharedManager ] downloadImageWithURL: originalImageURL options: SDWebImageRefreshCached progress: nil completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
57
61
expect (image).to .beNil ();
58
62
expect (error).toNot .beNil ();
59
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
72
@end
0 commit comments