|
|
@@ -459,6 +459,45 @@ class KingfisherManagerTests: XCTestCase {
|
|
|
|
|
|
waitForExpectations(timeout: 5, handler: nil)
|
|
|
}
|
|
|
+
|
|
|
+ func testWaitForCacheOnRetrieveImage() {
|
|
|
+ cleanDefaultCache()
|
|
|
+ let expectation = self.expectation(description: "wait for caching image on retrieve image")
|
|
|
+ let URLString = testKeys[0]
|
|
|
+ _ = stubRequest("GET", URLString).andReturn(200)?.withBody(testImageData)
|
|
|
+
|
|
|
+ let url = URL(string: URLString)!
|
|
|
+
|
|
|
+ self.manager.retrieveImage(with: url, options: [.waitForCache], progressBlock: nil) {
|
|
|
+ image, error, cacheType, imageURL in
|
|
|
+ XCTAssertNotNil(image)
|
|
|
+ XCTAssertEqual(cacheType, .memory)
|
|
|
+
|
|
|
+ expectation.fulfill()
|
|
|
+ }
|
|
|
+
|
|
|
+ waitForExpectations(timeout: 5, handler: nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ func testWaitForCacheOnRetrieveImageWithProcessor() {
|
|
|
+ cleanDefaultCache()
|
|
|
+ let expectation = self.expectation(description: "wait for caching image on retrieve image with processor")
|
|
|
+ let URLString = testKeys[0]
|
|
|
+ _ = stubRequest("GET", URLString).andReturn(200)?.withBody(testImageData)
|
|
|
+
|
|
|
+ let url = URL(string: URLString)!
|
|
|
+
|
|
|
+ let p = RoundCornerImageProcessor(cornerRadius: 20)
|
|
|
+ self.manager.retrieveImage(with: url, options: [.processor(p), .waitForCache], progressBlock: nil) {
|
|
|
+ image, error, cacheType, imageURL in
|
|
|
+ XCTAssertNotNil(image)
|
|
|
+ XCTAssertEqual(cacheType, .memory)
|
|
|
+
|
|
|
+ expectation.fulfill()
|
|
|
+ }
|
|
|
+
|
|
|
+ waitForExpectations(timeout: 5, handler: nil)
|
|
|
+ }
|
|
|
|
|
|
func testImageShouldOnlyFromMemoryCacheOrRefreshCanBeGotFromMemory() {
|
|
|
let expectation = self.expectation(description: "only from memory cache or refresh")
|