add test case

This commit is contained in:
kinarobin 2021-01-02 18:11:57 +08:00
parent 5a0e31b81b
commit 8ab5eb29cd
1 changed files with 21 additions and 0 deletions

View File

@ -311,6 +311,27 @@
}
}
- (void)test22DoNotDecodeImageWhenApplicationWillTerminate {
/// Just create SDImageCodersManager advance
[SDImageCodersManager sharedManager];
XCTestExpectation *expectation = [self expectationWithDescription:@"doNotDecodeImageWhenApplicationWillTerminate"];
NSString *testImagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestImageLarge" ofType:@"png"];
NSData *testImageData = [NSData dataWithContentsOfFile:testImagePath];
[[SDImageCache sharedImageCache] storeImageDataToDisk:testImageData forKey:@"TestImageLarge"];
NSOperation *operation = [[SDImageCache sharedImageCache] queryCacheOperationForKey:@"TestImageLarge" done:^(UIImage *image, NSData *data, SDImageCacheType cacheType) {
expect(data).to.equal(testImageData);
expect(image).to.beNil;
[[SDImageCache sharedImageCache] removeImageForKey:@"TestImageLarge" withCompletion:^{
[expectation fulfill];
}];
}];
expect(operation).toNot.beNil;
[operation start];
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillTerminateNotification object:nil];
[self waitForExpectationsWithCommonTimeout];
}
#pragma mark - Utils
- (void)verifyCoder:(id<SDImageCoder>)coder