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 {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"Cancel Query Should Callback Once In Sync"];
|
||||
expectation.expectedFulfillmentCount = 1;
|
||||
NSString *key = @"test15CancelQueryShouldCallbackOnceInSync";
|
||||
[SDImageCache.sharedImageCache removeImageFromMemoryForKey:key];
|
||||
[SDImageCache.sharedImageCache removeImageFromDiskForKey:key];
|
||||
__block BOOL callced = NO;
|
||||
SDImageCacheToken *token = [SDImageCache.sharedImageCache queryCacheOperationForKey:key done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
|
||||
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();
|
||||
[token cancel]; // sync
|
||||
expect(callced).beTruthy();
|
||||
});
|
||||
|
||||
[self waitForExpectationsWithCommonTimeout];
|
||||
if (callced == NO) {
|
||||
XCTFail("Callback called not in sync but async");
|
||||
}
|
||||
}
|
||||
|
||||
- (void)test20InitialCacheSize{
|
||||
|
|
Loading…
Reference in New Issue