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