Move common test logic to SDTestCase
Showing
11 changed files
with
96 additions
and
79 deletions
@@ -107,5 +107,3 @@ FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain; | @@ -107,5 +107,3 @@ FOUNDATION_EXPORT NSString *const SDWebImageErrorDomain; | ||
107 | dispatch_async(dispatch_get_main_queue(), block);\ | 107 | dispatch_async(dispatch_get_main_queue(), block);\ |
108 | } | 108 | } |
109 | #endif | 109 | #endif |
110 | - | ||
111 | -static int64_t kAsyncTestTimeout = 5; |
@@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
8 | 8 | ||
9 | /* Begin PBXBuildFile section */ | 9 | /* Begin PBXBuildFile section */ |
10 | 1E3C51E919B46E370092B5E6 /* SDWebImageDownloaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */; }; | 10 | 1E3C51E919B46E370092B5E6 /* SDWebImageDownloaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */; }; |
11 | + 2D7AF0601F329763000083C2 /* SDTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D7AF05F1F329763000083C2 /* SDTestCase.m */; }; | ||
11 | 433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */; }; | 12 | 433BBBB51D7EF5C00086B6E9 /* SDWebImageDecoderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */; }; |
12 | 433BBBB71D7EF8200086B6E9 /* TestImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB61D7EF8200086B6E9 /* TestImage.gif */; }; | 13 | 433BBBB71D7EF8200086B6E9 /* TestImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB61D7EF8200086B6E9 /* TestImage.gif */; }; |
13 | 433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB81D7EF8260086B6E9 /* TestImage.png */; }; | 14 | 433BBBB91D7EF8260086B6E9 /* TestImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 433BBBB81D7EF8260086B6E9 /* TestImage.png */; }; |
@@ -29,6 +30,8 @@ | @@ -29,6 +30,8 @@ | ||
29 | /* Begin PBXFileReference section */ | 30 | /* Begin PBXFileReference section */ |
30 | 1DAAA77E3CA7387F702040D9 /* Pods_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 31 | 1DAAA77E3CA7387F702040D9 /* Pods_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
31 | 1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDownloaderTests.m; sourceTree = "<group>"; }; | 32 | 1E3C51E819B46E370092B5E6 /* SDWebImageDownloaderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDownloaderTests.m; sourceTree = "<group>"; }; |
33 | + 2D7AF05E1F329763000083C2 /* SDTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDTestCase.h; sourceTree = "<group>"; }; | ||
34 | + 2D7AF05F1F329763000083C2 /* SDTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDTestCase.m; sourceTree = "<group>"; }; | ||
32 | 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDecoderTests.m; sourceTree = "<group>"; }; | 35 | 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDecoderTests.m; sourceTree = "<group>"; }; |
33 | 433BBBB61D7EF8200086B6E9 /* TestImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = TestImage.gif; sourceTree = "<group>"; }; | 36 | 433BBBB61D7EF8200086B6E9 /* TestImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = TestImage.gif; sourceTree = "<group>"; }; |
34 | 433BBBB81D7EF8260086B6E9 /* TestImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestImage.png; sourceTree = "<group>"; }; | 37 | 433BBBB81D7EF8260086B6E9 /* TestImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TestImage.png; sourceTree = "<group>"; }; |
@@ -120,6 +123,8 @@ | @@ -120,6 +123,8 @@ | ||
120 | 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */, | 123 | 433BBBB41D7EF5C00086B6E9 /* SDWebImageDecoderTests.m */, |
121 | 4369C1D01D97F80F007E863A /* SDWebImagePrefetcherTests.m */, | 124 | 4369C1D01D97F80F007E863A /* SDWebImagePrefetcherTests.m */, |
122 | 4369C2731D9804B1007E863A /* SDCategoriesTests.m */, | 125 | 4369C2731D9804B1007E863A /* SDCategoriesTests.m */, |
126 | + 2D7AF05E1F329763000083C2 /* SDTestCase.h */, | ||
127 | + 2D7AF05F1F329763000083C2 /* SDTestCase.m */, | ||
123 | ); | 128 | ); |
124 | path = Tests; | 129 | path = Tests; |
125 | sourceTree = "<group>"; | 130 | sourceTree = "<group>"; |
@@ -253,6 +258,7 @@ | @@ -253,6 +258,7 @@ | ||
253 | files = ( | 258 | files = ( |
254 | 1E3C51E919B46E370092B5E6 /* SDWebImageDownloaderTests.m in Sources */, | 259 | 1E3C51E919B46E370092B5E6 /* SDWebImageDownloaderTests.m in Sources */, |
255 | 4369C2741D9804B1007E863A /* SDCategoriesTests.m in Sources */, | 260 | 4369C2741D9804B1007E863A /* SDCategoriesTests.m in Sources */, |
261 | + 2D7AF0601F329763000083C2 /* SDTestCase.m in Sources */, | ||
256 | 4369C1D11D97F80F007E863A /* SDWebImagePrefetcherTests.m in Sources */, | 262 | 4369C1D11D97F80F007E863A /* SDWebImagePrefetcherTests.m in Sources */, |
257 | DA248D69195475D800390AB0 /* SDImageCacheTests.m in Sources */, | 263 | DA248D69195475D800390AB0 /* SDImageCacheTests.m in Sources */, |
258 | DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */, | 264 | DA248D6B195476AC00390AB0 /* SDWebImageManagerTests.m in Sources */, |
@@ -7,11 +7,7 @@ | @@ -7,11 +7,7 @@ | ||
7 | * file that was distributed with this source code. | 7 | * file that was distributed with this source code. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | -#define EXP_SHORTHAND // required by Expecta | ||
11 | - | ||
12 | -#import <XCTest/XCTest.h> | ||
13 | -#import <Expecta/Expecta.h> | ||
14 | - | 10 | +#import "SDTestCase.h" |
15 | #import <SDWebImage/UIImageView+WebCache.h> | 11 | #import <SDWebImage/UIImageView+WebCache.h> |
16 | #import <SDWebImage/UIImageView+HighlightedWebCache.h> | 12 | #import <SDWebImage/UIImageView+HighlightedWebCache.h> |
17 | #import <SDWebImage/MKAnnotationView+WebCache.h> | 13 | #import <SDWebImage/MKAnnotationView+WebCache.h> |
@@ -20,7 +16,7 @@ | @@ -20,7 +16,7 @@ | ||
20 | 16 | ||
21 | @import FLAnimatedImage; | 17 | @import FLAnimatedImage; |
22 | 18 | ||
23 | -@interface SDCategoriesTests : XCTestCase | 19 | +@interface SDCategoriesTests : SDTestCase |
24 | 20 | ||
25 | @end | 21 | @end |
26 | 22 | ||
@@ -39,7 +35,7 @@ | @@ -39,7 +35,7 @@ | ||
39 | expect(imageView.image).to.equal(image); | 35 | expect(imageView.image).to.equal(image); |
40 | [expectation fulfill]; | 36 | [expectation fulfill]; |
41 | }]; | 37 | }]; |
42 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 38 | + [self waitForExpectationsWithCommonTimeout]; |
43 | } | 39 | } |
44 | 40 | ||
45 | - (void)testUIImageViewSetHighlightedImageWithURL { | 41 | - (void)testUIImageViewSetHighlightedImageWithURL { |
@@ -55,7 +51,7 @@ | @@ -55,7 +51,7 @@ | ||
55 | expect(imageView.highlightedImage).to.equal(image); | 51 | expect(imageView.highlightedImage).to.equal(image); |
56 | [expectation fulfill]; | 52 | [expectation fulfill]; |
57 | }]; | 53 | }]; |
58 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 54 | + [self waitForExpectationsWithCommonTimeout]; |
59 | } | 55 | } |
60 | 56 | ||
61 | - (void)testMKAnnotationViewSetImageWithURL { | 57 | - (void)testMKAnnotationViewSetImageWithURL { |
@@ -71,7 +67,7 @@ | @@ -71,7 +67,7 @@ | ||
71 | expect(annotationView.image).to.equal(image); | 67 | expect(annotationView.image).to.equal(image); |
72 | [expectation fulfill]; | 68 | [expectation fulfill]; |
73 | }]; | 69 | }]; |
74 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 70 | + [self waitForExpectationsWithCommonTimeout]; |
75 | } | 71 | } |
76 | 72 | ||
77 | - (void)testUIButtonSetImageWithURLNormalState { | 73 | - (void)testUIButtonSetImageWithURLNormalState { |
@@ -88,7 +84,7 @@ | @@ -88,7 +84,7 @@ | ||
88 | expect([button imageForState:UIControlStateNormal]).to.equal(image); | 84 | expect([button imageForState:UIControlStateNormal]).to.equal(image); |
89 | [expectation fulfill]; | 85 | [expectation fulfill]; |
90 | }]; | 86 | }]; |
91 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 87 | + [self waitForExpectationsWithCommonTimeout]; |
92 | } | 88 | } |
93 | 89 | ||
94 | - (void)testUIButtonSetImageWithURLHighlightedState { | 90 | - (void)testUIButtonSetImageWithURLHighlightedState { |
@@ -105,7 +101,7 @@ | @@ -105,7 +101,7 @@ | ||
105 | expect([button imageForState:UIControlStateHighlighted]).to.equal(image); | 101 | expect([button imageForState:UIControlStateHighlighted]).to.equal(image); |
106 | [expectation fulfill]; | 102 | [expectation fulfill]; |
107 | }]; | 103 | }]; |
108 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 104 | + [self waitForExpectationsWithCommonTimeout]; |
109 | } | 105 | } |
110 | 106 | ||
111 | - (void)testUIButtonSetBackgroundImageWithURLNormalState { | 107 | - (void)testUIButtonSetBackgroundImageWithURLNormalState { |
@@ -122,7 +118,7 @@ | @@ -122,7 +118,7 @@ | ||
122 | expect([button backgroundImageForState:UIControlStateNormal]).to.equal(image); | 118 | expect([button backgroundImageForState:UIControlStateNormal]).to.equal(image); |
123 | [expectation fulfill]; | 119 | [expectation fulfill]; |
124 | }]; | 120 | }]; |
125 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 121 | + [self waitForExpectationsWithCommonTimeout]; |
126 | } | 122 | } |
127 | 123 | ||
128 | - (void)testFLAnimatedImageViewSetImageWithURL { | 124 | - (void)testFLAnimatedImageViewSetImageWithURL { |
@@ -140,7 +136,7 @@ | @@ -140,7 +136,7 @@ | ||
140 | expect(imageView.animatedImage).toNot.beNil(); | 136 | expect(imageView.animatedImage).toNot.beNil(); |
141 | [expectation fulfill]; | 137 | [expectation fulfill]; |
142 | }]; | 138 | }]; |
143 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 139 | + [self waitForExpectationsWithCommonTimeout]; |
144 | } | 140 | } |
145 | 141 | ||
146 | @end | 142 | @end |
@@ -6,17 +6,12 @@ | @@ -6,17 +6,12 @@ | ||
6 | * file that was distributed with this source code. | 6 | * file that was distributed with this source code. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | -#define EXP_SHORTHAND // required by Expecta | ||
10 | - | ||
11 | - | ||
12 | -#import <XCTest/XCTest.h> | ||
13 | -#import <Expecta/Expecta.h> | ||
14 | - | 9 | +#import "SDTestCase.h" |
15 | #import <SDWebImage/SDImageCache.h> | 10 | #import <SDWebImage/SDImageCache.h> |
16 | 11 | ||
17 | NSString *kImageTestKey = @"TestImageKey.jpg"; | 12 | NSString *kImageTestKey = @"TestImageKey.jpg"; |
18 | 13 | ||
19 | -@interface SDImageCacheTests : XCTestCase | 14 | +@interface SDImageCacheTests : SDTestCase |
20 | @property (strong, nonatomic) SDImageCache *sharedImageCache; | 15 | @property (strong, nonatomic) SDImageCache *sharedImageCache; |
21 | @end | 16 | @end |
22 | 17 | ||
@@ -56,7 +51,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | @@ -56,7 +51,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | ||
56 | }]; | 51 | }]; |
57 | expect([self.sharedImageCache imageFromMemoryCacheForKey:kImageTestKey]).to.equal([self imageForTesting]); | 52 | expect([self.sharedImageCache imageFromMemoryCacheForKey:kImageTestKey]).to.equal([self imageForTesting]); |
58 | }]; | 53 | }]; |
59 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 54 | + [self waitForExpectationsWithCommonTimeout]; |
60 | } | 55 | } |
61 | 56 | ||
62 | - (void)test05ClearMemoryCache{ | 57 | - (void)test05ClearMemoryCache{ |
@@ -72,7 +67,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | @@ -72,7 +67,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | ||
72 | XCTFail(@"Image should be in cache"); | 67 | XCTFail(@"Image should be in cache"); |
73 | } | 68 | } |
74 | }]; | 69 | }]; |
75 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 70 | + [self waitForExpectationsWithCommonTimeout]; |
76 | } | 71 | } |
77 | 72 | ||
78 | // Testing storeImage:forKey: | 73 | // Testing storeImage:forKey: |
@@ -89,7 +84,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | @@ -89,7 +84,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | ||
89 | XCTFail(@"Image should be in cache"); | 84 | XCTFail(@"Image should be in cache"); |
90 | } | 85 | } |
91 | }]; | 86 | }]; |
92 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 87 | + [self waitForExpectationsWithCommonTimeout]; |
93 | } | 88 | } |
94 | 89 | ||
95 | // Testing storeImage:forKey:toDisk:YES | 90 | // Testing storeImage:forKey:toDisk:YES |
@@ -106,7 +101,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | @@ -106,7 +101,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | ||
106 | XCTFail(@"Image should be in cache"); | 101 | XCTFail(@"Image should be in cache"); |
107 | } | 102 | } |
108 | }]; | 103 | }]; |
109 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 104 | + [self waitForExpectationsWithCommonTimeout]; |
110 | } | 105 | } |
111 | 106 | ||
112 | // Testing storeImage:forKey:toDisk:NO | 107 | // Testing storeImage:forKey:toDisk:NO |
@@ -125,7 +120,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | @@ -125,7 +120,7 @@ NSString *kImageTestKey = @"TestImageKey.jpg"; | ||
125 | }]; | 120 | }]; |
126 | [self.sharedImageCache clearMemory]; | 121 | [self.sharedImageCache clearMemory]; |
127 | expect([self.sharedImageCache imageFromMemoryCacheForKey:kImageTestKey]).to.beNil(); | 122 | expect([self.sharedImageCache imageFromMemoryCacheForKey:kImageTestKey]).to.beNil(); |
128 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 123 | + [self waitForExpectationsWithCommonTimeout]; |
129 | } | 124 | } |
130 | 125 | ||
131 | - (void)test09RetrieveImageThroughNSOperation{ | 126 | - (void)test09RetrieveImageThroughNSOperation{ |
Tests/Tests/SDTestCase.h
0 → 100644
1 | +/* | ||
2 | + * This file is part of the SDWebImage package. | ||
3 | + * (c) Olivier Poitrey <rs@dailymotion.com> | ||
4 | + * (c) Matt Galloway | ||
5 | + * | ||
6 | + * For the full copyright and license information, please view the LICENSE | ||
7 | + * file that was distributed with this source code. | ||
8 | + */ | ||
9 | + | ||
10 | +#define EXP_SHORTHAND // required by Expecta | ||
11 | + | ||
12 | + | ||
13 | +#import <XCTest/XCTest.h> | ||
14 | +#import <Expecta/Expecta.h> | ||
15 | + | ||
16 | +extern const int64_t kAsyncTestTimeout; | ||
17 | + | ||
18 | +@interface SDTestCase : XCTestCase | ||
19 | + | ||
20 | +- (void)waitForExpectationsWithCommonTimeout; | ||
21 | +- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler; | ||
22 | + | ||
23 | +@end |
Tests/Tests/SDTestCase.m
0 → 100644
1 | +/* | ||
2 | + * This file is part of the SDWebImage package. | ||
3 | + * (c) Olivier Poitrey <rs@dailymotion.com> | ||
4 | + * (c) Matt Galloway | ||
5 | + * | ||
6 | + * For the full copyright and license information, please view the LICENSE | ||
7 | + * file that was distributed with this source code. | ||
8 | + */ | ||
9 | + | ||
10 | +#import "SDTestCase.h" | ||
11 | + | ||
12 | +const int64_t kAsyncTestTimeout = 5; | ||
13 | + | ||
14 | +@implementation SDTestCase | ||
15 | + | ||
16 | +- (void)waitForExpectationsWithCommonTimeout { | ||
17 | + [self waitForExpectationsWithCommonTimeoutUsingHandler:nil]; | ||
18 | +} | ||
19 | + | ||
20 | +- (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler { | ||
21 | + [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:handler]; | ||
22 | +} | ||
23 | + | ||
24 | +@end |
@@ -7,14 +7,10 @@ | @@ -7,14 +7,10 @@ | ||
7 | * file that was distributed with this source code. | 7 | * file that was distributed with this source code. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | -#define EXP_SHORTHAND // required by Expecta | ||
11 | - | ||
12 | - | ||
13 | -#import <XCTest/XCTest.h> | ||
14 | -#import <Expecta/Expecta.h> | 10 | +#import "SDTestCase.h" |
15 | #import <SDWebImage/SDWebImageDecoder.h> | 11 | #import <SDWebImage/SDWebImageDecoder.h> |
16 | 12 | ||
17 | -@interface SDWebImageDecoderTests : XCTestCase | 13 | +@interface SDWebImageDecoderTests : SDTestCase |
18 | 14 | ||
19 | @end | 15 | @end |
20 | 16 |
@@ -7,12 +7,7 @@ | @@ -7,12 +7,7 @@ | ||
7 | * file that was distributed with this source code. | 7 | * file that was distributed with this source code. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | -#define EXP_SHORTHAND // required by Expecta | ||
11 | - | ||
12 | - | ||
13 | -#import <XCTest/XCTest.h> | ||
14 | -#import <Expecta/Expecta.h> | ||
15 | - | 10 | +#import "SDTestCase.h" |
16 | #import <SDWebImage/SDWebImageDownloader.h> | 11 | #import <SDWebImage/SDWebImageDownloader.h> |
17 | #import <SDWebImage/SDWebImageDownloaderOperation.h> | 12 | #import <SDWebImage/SDWebImageDownloaderOperation.h> |
18 | 13 | ||
@@ -55,7 +50,7 @@ | @@ -55,7 +50,7 @@ | ||
55 | 50 | ||
56 | 51 | ||
57 | 52 | ||
58 | -@interface SDWebImageDownloaderTests : XCTestCase | 53 | +@interface SDWebImageDownloaderTests : SDTestCase |
59 | 54 | ||
60 | @end | 55 | @end |
61 | 56 | ||
@@ -91,7 +86,7 @@ | @@ -91,7 +86,7 @@ | ||
91 | XCTFail(@"Something went wrong"); | 86 | XCTFail(@"Something went wrong"); |
92 | } | 87 | } |
93 | }]; | 88 | }]; |
94 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 89 | + [self waitForExpectationsWithCommonTimeout]; |
95 | } | 90 | } |
96 | 91 | ||
97 | - (void)test05ThatSetAndGetMaxConcurrentDownloadsWorks { | 92 | - (void)test05ThatSetAndGetMaxConcurrentDownloadsWorks { |
@@ -141,7 +136,7 @@ | @@ -141,7 +136,7 @@ | ||
141 | XCTFail(@"Something went wrong"); | 136 | XCTFail(@"Something went wrong"); |
142 | } | 137 | } |
143 | }]; | 138 | }]; |
144 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 139 | + [self waitForExpectationsWithCommonTimeout]; |
145 | [SDWebImageDownloader sharedDownloader].username = nil; | 140 | [SDWebImageDownloader sharedDownloader].username = nil; |
146 | [SDWebImageDownloader sharedDownloader].password = nil; | 141 | [SDWebImageDownloader sharedDownloader].password = nil; |
147 | } | 142 | } |
@@ -158,7 +153,7 @@ | @@ -158,7 +153,7 @@ | ||
158 | // progressive updates | 153 | // progressive updates |
159 | } | 154 | } |
160 | }]; | 155 | }]; |
161 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 156 | + [self waitForExpectationsWithCommonTimeout]; |
162 | } | 157 | } |
163 | 158 | ||
164 | - (void)test10That404CaseCallsCompletionWithError { | 159 | - (void)test10That404CaseCallsCompletionWithError { |
@@ -172,7 +167,7 @@ | @@ -172,7 +167,7 @@ | ||
172 | XCTFail(@"Something went wrong"); | 167 | XCTFail(@"Something went wrong"); |
173 | } | 168 | } |
174 | }]; | 169 | }]; |
175 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 170 | + [self waitForExpectationsWithCommonTimeout]; |
176 | } | 171 | } |
177 | 172 | ||
178 | - (void)test11ThatCancelWorks { | 173 | - (void)test11ThatCancelWorks { |
@@ -193,7 +188,7 @@ | @@ -193,7 +188,7 @@ | ||
193 | [expectation fulfill]; | 188 | [expectation fulfill]; |
194 | }); | 189 | }); |
195 | 190 | ||
196 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 191 | + [self waitForExpectationsWithCommonTimeout]; |
197 | } | 192 | } |
198 | 193 | ||
199 | - (void)test12ThatWeCanUseAnotherSessionForEachDownloadOperation { | 194 | - (void)test12ThatWeCanUseAnotherSessionForEachDownloadOperation { |
@@ -219,7 +214,7 @@ | @@ -219,7 +214,7 @@ | ||
219 | 214 | ||
220 | [operation start]; | 215 | [operation start]; |
221 | 216 | ||
222 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 217 | + [self waitForExpectationsWithCommonTimeout]; |
223 | } | 218 | } |
224 | 219 | ||
225 | - (void)test13ThatDownloadCanContinueWhenTheAppEntersBackground { | 220 | - (void)test13ThatDownloadCanContinueWhenTheAppEntersBackground { |
@@ -232,7 +227,7 @@ | @@ -232,7 +227,7 @@ | ||
232 | XCTFail(@"Something went wrong"); | 227 | XCTFail(@"Something went wrong"); |
233 | } | 228 | } |
234 | }]; | 229 | }]; |
235 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 230 | + [self waitForExpectationsWithCommonTimeout]; |
236 | } | 231 | } |
237 | 232 | ||
238 | - (void)test14ThatPNGWorks { | 233 | - (void)test14ThatPNGWorks { |
@@ -245,7 +240,7 @@ | @@ -245,7 +240,7 @@ | ||
245 | XCTFail(@"Something went wrong"); | 240 | XCTFail(@"Something went wrong"); |
246 | } | 241 | } |
247 | }]; | 242 | }]; |
248 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 243 | + [self waitForExpectationsWithCommonTimeout]; |
249 | } | 244 | } |
250 | 245 | ||
251 | - (void)test15ThatWEBPWorks { | 246 | - (void)test15ThatWEBPWorks { |
@@ -258,7 +253,7 @@ | @@ -258,7 +253,7 @@ | ||
258 | XCTFail(@"Something went wrong"); | 253 | XCTFail(@"Something went wrong"); |
259 | } | 254 | } |
260 | }]; | 255 | }]; |
261 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 256 | + [self waitForExpectationsWithCommonTimeout]; |
262 | } | 257 | } |
263 | 258 | ||
264 | /** | 259 | /** |
@@ -296,7 +291,7 @@ | @@ -296,7 +291,7 @@ | ||
296 | 291 | ||
297 | [[SDWebImageDownloader sharedDownloader] cancel:token1]; | 292 | [[SDWebImageDownloader sharedDownloader] cancel:token1]; |
298 | 293 | ||
299 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 294 | + [self waitForExpectationsWithCommonTimeout]; |
300 | } | 295 | } |
301 | 296 | ||
302 | /** | 297 | /** |
@@ -335,7 +330,7 @@ | @@ -335,7 +330,7 @@ | ||
335 | }]; | 330 | }]; |
336 | expect(token2).toNot.beNil(); | 331 | expect(token2).toNot.beNil(); |
337 | 332 | ||
338 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 333 | + [self waitForExpectationsWithCommonTimeout]; |
339 | } | 334 | } |
340 | 335 | ||
341 | @end | 336 | @end |
@@ -6,17 +6,12 @@ | @@ -6,17 +6,12 @@ | ||
6 | * file that was distributed with this source code. | 6 | * file that was distributed with this source code. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | -#define EXP_SHORTHAND // required by Expecta | ||
10 | - | ||
11 | - | ||
12 | -#import <XCTest/XCTest.h> | ||
13 | -#import <Expecta/Expecta.h> | ||
14 | - | 9 | +#import "SDTestCase.h" |
15 | #import <SDWebImage/SDWebImageManager.h> | 10 | #import <SDWebImage/SDWebImageManager.h> |
16 | 11 | ||
17 | NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg"; | 12 | NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg"; |
18 | 13 | ||
19 | -@interface SDWebImageManagerTests : XCTestCase | 14 | +@interface SDWebImageManagerTests : SDTestCase |
20 | 15 | ||
21 | @end | 16 | @end |
22 | 17 | ||
@@ -45,7 +40,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -45,7 +40,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
45 | }]; | 40 | }]; |
46 | expect([[SDWebImageManager sharedManager] isRunning]).to.equal(YES); | 41 | expect([[SDWebImageManager sharedManager] isRunning]).to.equal(YES); |
47 | 42 | ||
48 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 43 | + [self waitForExpectationsWithCommonTimeout]; |
49 | } | 44 | } |
50 | 45 | ||
51 | - (void)test03ThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync { | 46 | - (void)test03ThatDownloadWithIncorrectURLInvokesCompletionBlockWithAnErrorAsync { |
@@ -65,7 +60,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -65,7 +60,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
65 | expectation = nil; | 60 | expectation = nil; |
66 | }]; | 61 | }]; |
67 | 62 | ||
68 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 63 | + [self waitForExpectationsWithCommonTimeout]; |
69 | } | 64 | } |
70 | 65 | ||
71 | - (void)test04CachedImageExistsForURL { | 66 | - (void)test04CachedImageExistsForURL { |
@@ -91,7 +86,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -91,7 +86,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
91 | XCTFail(@"Image should be in cache"); | 86 | XCTFail(@"Image should be in cache"); |
92 | } | 87 | } |
93 | }]; | 88 | }]; |
94 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 89 | + [self waitForExpectationsWithCommonTimeout]; |
95 | } | 90 | } |
96 | 91 | ||
97 | - (void)test06CancellAll { | 92 | - (void)test06CancellAll { |
@@ -110,7 +105,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | @@ -110,7 +105,7 @@ NSString *workingImageURL = @"http://s3.amazonaws.com/fast-image-cache/demo-imag | ||
110 | [expectation fulfill]; | 105 | [expectation fulfill]; |
111 | }); | 106 | }); |
112 | 107 | ||
113 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 108 | + [self waitForExpectationsWithCommonTimeout]; |
114 | } | 109 | } |
115 | 110 | ||
116 | @end | 111 | @end |
@@ -7,15 +7,10 @@ | @@ -7,15 +7,10 @@ | ||
7 | * file that was distributed with this source code. | 7 | * file that was distributed with this source code. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | -#define EXP_SHORTHAND // required by Expecta | ||
11 | - | ||
12 | - | ||
13 | -#import <XCTest/XCTest.h> | ||
14 | -#import <Expecta/Expecta.h> | ||
15 | - | 10 | +#import "SDTestCase.h" |
16 | #import <SDWebImage/SDWebImagePrefetcher.h> | 11 | #import <SDWebImage/SDWebImagePrefetcher.h> |
17 | 12 | ||
18 | -@interface SDWebImagePrefetcherTests : XCTestCase | 13 | +@interface SDWebImagePrefetcherTests : SDTestCase |
19 | 14 | ||
20 | @end | 15 | @end |
21 | 16 | ||
@@ -51,7 +46,7 @@ | @@ -51,7 +46,7 @@ | ||
51 | [expectation fulfill]; | 46 | [expectation fulfill]; |
52 | }]; | 47 | }]; |
53 | 48 | ||
54 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 49 | + [self waitForExpectationsWithCommonTimeout]; |
55 | } | 50 | } |
56 | 51 | ||
57 | - (void)test03PrefetchWithEmptyArrayWillCallTheCompletionWithAllZeros { | 52 | - (void)test03PrefetchWithEmptyArrayWillCallTheCompletionWithAllZeros { |
@@ -63,7 +58,7 @@ | @@ -63,7 +58,7 @@ | ||
63 | [expectation fulfill]; | 58 | [expectation fulfill]; |
64 | }]; | 59 | }]; |
65 | 60 | ||
66 | - [self waitForExpectationsWithTimeout:kAsyncTestTimeout handler:nil]; | 61 | + [self waitForExpectationsWithCommonTimeout]; |
67 | } | 62 | } |
68 | 63 | ||
69 | // TODO: test the prefetcher delegate works | 64 | // TODO: test the prefetcher delegate works |
@@ -6,16 +6,10 @@ | @@ -6,16 +6,10 @@ | ||
6 | * file that was distributed with this source code. | 6 | * file that was distributed with this source code. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | -#define EXP_SHORTHAND // required by Expecta | ||
10 | - | ||
11 | - | ||
12 | -#import <XCTest/XCTest.h> | ||
13 | -#import <Expecta/Expecta.h> | ||
14 | - | 9 | +#import "SDTestCase.h" |
15 | #import <SDWebImage/UIImage+MultiFormat.h> | 10 | #import <SDWebImage/UIImage+MultiFormat.h> |
16 | 11 | ||
17 | - | ||
18 | -@interface UIImageMultiFormatTests : XCTestCase | 12 | +@interface UIImageMultiFormatTests : SDTestCase |
19 | 13 | ||
20 | @end | 14 | @end |
21 | 15 |
-
Please register or login to post a comment