Skip to content

Commit b0ff851

Browse files
committed
Merge pull request SDWebImage#898 from mattjgalloway/xctest_async
Switch to built in XCTest async
2 parents c3c5578 + 66a6873 commit b0ff851

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

Tests/Podfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ workspace '../SDWebImage'
33

44
def import_pods
55
pod 'Expecta' # A Matcher Framework for Objective-C/Cocoa
6-
pod 'XCTestAsync' # Extension to XCTest for asynchronous testing
76
pod 'SDWebImage', :path => '../'
87
end
98

109
target :ios do
1110
platform :ios, '5.0'
1211
link_with 'Tests'
1312
import_pods
14-
end
13+
end

Tests/Tests/SDImageCacheTests.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
#import <XCTest/XCTest.h>
13-
#import <XCTestAsync/XCTestAsync.h>
1413
#import <Expecta.h>
1514

1615
#import "SDImageCache.h"

Tests/Tests/SDWebImageManagerTests.m

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
#import <XCTest/XCTest.h>
13-
#import <XCTestAsync/XCTestAsync.h>
1413
#import <Expecta.h>
1514

1615
#import "SDWebImageManager.h"
@@ -37,31 +36,37 @@ - (void)tearDown
3736
}
3837

3938
- (void)testThatDownloadInvokesCompletionBlockWithCorrectParamsAsync {
39+
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
40+
4041
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.jpg?20120509154705"];
4142

4243
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
4344
expect(image).toNot.beNil();
4445
expect(error).to.beNil();
4546
expect(originalImageURL).to.equal(imageURL);
46-
47-
XCAsyncSuccess();
47+
48+
[expectation fulfill];
49+
expectation = nil;
4850
}];
49-
50-
XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
51+
52+
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
5153
}
5254

5355
- (void)testThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync {
56+
__block XCTestExpectation *expectation = [self expectationWithDescription:@"Image download completes"];
57+
5458
NSURL *originalImageURL = [NSURL URLWithString:@"http://static2.dmcdn.net/static/video/656/177/44771656:jpeg_preview_small.png"];
5559

5660
[[SDWebImageManager sharedManager] downloadImageWithURL:originalImageURL options:SDWebImageRefreshCached progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
5761
expect(image).to.beNil();
5862
expect(error).toNot.beNil();
5963
expect(originalImageURL).to.equal(imageURL);
6064

61-
XCAsyncSuccess();
65+
[expectation fulfill];
66+
expectation = nil;
6267
}];
6368

64-
XCAsyncFailAfter(kAsyncTestTimeout, @"Download image timed out");
69+
[self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil];
6570
}
6671

6772
@end

Tests/Tests/UIImageMultiFormatTests.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
#import <XCTest/XCTest.h>
13-
#import <XCTestAsync/XCTestAsync.h>
1413
#import <Expecta.h>
1514

1615
#import "UIImage+MultiFormat.h"

0 commit comments

Comments
 (0)