|
|
@@ -653,7 +653,7 @@ class ImageViewExtensionTests: XCTestCase {
|
|
|
waitForExpectations(timeout: 3, handler: nil)
|
|
|
}
|
|
|
|
|
|
- func testImageCacheExtendingExpirationTask() {
|
|
|
+ func testMemoryImageCacheExtendingExpirationTask() {
|
|
|
let exp = expectation(description: #function)
|
|
|
let url = testURLs[0]
|
|
|
stub(url, data: testImageData)
|
|
|
@@ -688,7 +688,7 @@ class ImageViewExtensionTests: XCTestCase {
|
|
|
waitForExpectations(timeout: 3, handler: nil)
|
|
|
}
|
|
|
|
|
|
- func testImageCacheNotExtendingExpirationTask() {
|
|
|
+ func testMemoryImageCacheNotExtendingExpirationTask() {
|
|
|
let exp = expectation(description: #function)
|
|
|
let url = testURLs[0]
|
|
|
stub(url, data: testImageData)
|
|
|
@@ -720,6 +720,73 @@ class ImageViewExtensionTests: XCTestCase {
|
|
|
|
|
|
waitForExpectations(timeout: 3, handler: nil)
|
|
|
}
|
|
|
+
|
|
|
+ func testDiskImageCacheExtendingExpirationTask() {
|
|
|
+ let exp = expectation(description: #function)
|
|
|
+ let url = testURLs[0]
|
|
|
+ stub(url, data: testImageData)
|
|
|
+
|
|
|
+ let options: KingfisherOptionsInfo = [.memoryCacheExpiration(.expired),
|
|
|
+ .diskCacheExpiration(.seconds(1)),
|
|
|
+ .diskCacheAccessExtendingExpiration(.cacheTime)] // default option
|
|
|
+
|
|
|
+ imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .none)
|
|
|
+
|
|
|
+ delay(1, block: {
|
|
|
+ self.imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .disk)
|
|
|
+ delay(1, block: {
|
|
|
+ self.imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .disk)
|
|
|
+
|
|
|
+ exp.fulfill()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ waitForExpectations(timeout: 3, handler: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ func testDiskImageCacheNotExtendingExpirationTask() {
|
|
|
+ let exp = expectation(description: #function)
|
|
|
+ let url = testURLs[0]
|
|
|
+ stub(url, data: testImageData)
|
|
|
+
|
|
|
+ let options: KingfisherOptionsInfo = [.memoryCacheExpiration(.expired),
|
|
|
+ .diskCacheExpiration(.seconds(1)),
|
|
|
+ .diskCacheAccessExtendingExpiration(.none)]
|
|
|
+
|
|
|
+ imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .none)
|
|
|
+
|
|
|
+ delay(1, block: {
|
|
|
+ self.imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .disk)
|
|
|
+
|
|
|
+ delay(1, block: {
|
|
|
+ self.imageView.kf.setImage(with: url, options: options) { result in
|
|
|
+ XCTAssertNotNil(result.value?.image)
|
|
|
+ XCTAssertTrue(result.value!.cacheType == .none)
|
|
|
+
|
|
|
+ exp.fulfill()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ waitForExpectations(timeout: 3, handler: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension View: Placeholder {}
|