Update unit test
The `test15CancelQueryShouldCallbackOnceInSync` should use a better way to check
This commit is contained in:
parent
c60958ca1c
commit
a6cce6677b
|
@ -226,25 +226,19 @@ static NSString *kTestImageKeyPNG = @"TestImageKey.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)test15CancelQueryShouldCallbackOnceInSync {
|
- (void)test15CancelQueryShouldCallbackOnceInSync {
|
||||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Cancel Query Should Callback Once In Sync"];
|
|
||||||
expectation.expectedFulfillmentCount = 1;
|
|
||||||
NSString *key = @"test15CancelQueryShouldCallbackOnceInSync";
|
NSString *key = @"test15CancelQueryShouldCallbackOnceInSync";
|
||||||
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:key];
|
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:key];
|
||||||
[SDImageCache.sharedImageCache removeImageFromDiskForKey:key];
|
[SDImageCache.sharedImageCache removeImageFromDiskForKey:key];
|
||||||
__block BOOL callced = NO;
|
__block BOOL callced = NO;
|
||||||
SDImageCacheToken *token = [SDImageCache.sharedImageCache queryCacheOperationForKey:key done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
|
SDImageCacheToken *token = [SDImageCache.sharedImageCache queryCacheOperationForKey:key done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
|
||||||
callced = YES;
|
callced = YES;
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), dispatch_get_main_queue(), ^{
|
|
||||||
[expectation fulfill]; // callback once fulfill once
|
|
||||||
});
|
|
||||||
}];
|
}];
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0), dispatch_get_main_queue(), ^{
|
expect(callced).beFalsy();
|
||||||
expect(callced).beFalsy();
|
[token cancel]; // sync
|
||||||
[token cancel]; // sync
|
expect(callced).beTruthy();
|
||||||
expect(callced).beTruthy();
|
if (callced == NO) {
|
||||||
});
|
XCTFail("Callback called not in sync but async");
|
||||||
|
}
|
||||||
[self waitForExpectationsWithCommonTimeout];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)test20InitialCacheSize{
|
- (void)test20InitialCacheSize{
|
||||||
|
|
Loading…
Reference in New Issue