Skip to content

Commit ffc9166

Browse files
committed
Added test case test48CacheUseConcurrentIOQueue
1 parent c60e671 commit ffc9166

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Tests/Tests/SDImageCacheTests.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,27 @@ - (void)test47DiskCacheExtendedData {
650650
[self waitForExpectationsWithCommonTimeout];
651651
}
652652

653+
- (void)test48CacheUseConcurrentIOQueue {
654+
XCTestExpectation *expectation = [self expectationWithDescription:@"SDImageCache concurrent ioQueue"];
655+
expectation.expectedFulfillmentCount = 2;
656+
657+
SDImageCacheConfig *config = [SDImageCacheConfig new];
658+
dispatch_queue_attr_t attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_BACKGROUND, 0);
659+
config.ioQueueAttributes = attr;
660+
661+
SDImageCache *cache = [[SDImageCache alloc] initWithNamespace:@"Concurrent" diskCacheDirectory:@"/" config:config];
662+
NSData *pngData = [NSData dataWithContentsOfFile:[self testPNGPath]];
663+
[cache queryCacheOperationForKey:@"Key1" done:^(UIImage * _Nullable image, NSData * _Nullable data, SDImageCacheType cacheType) {
664+
expect(data).beNil();
665+
[expectation fulfill];
666+
}];
667+
[cache storeImageData:pngData forKey:@"Key1" completion:^{
668+
[expectation fulfill];
669+
}];
670+
671+
[self waitForExpectationsWithCommonTimeout];
672+
}
673+
653674
#pragma mark - SDImageCache & SDImageCachesManager
654675
- (void)test49SDImageCacheQueryOp {
655676
XCTestExpectation *expectation = [self expectationWithDescription:@"SDImageCache query op works"];

0 commit comments

Comments
 (0)