Parcourir la source

Revert "Test serial setImage calls in tests (to resolve CI errors)"

This reverts commit 32e93b602d655bb982a9dc38c2ac1a9668cbb70a.
Dominique Stranz il y a 6 ans
Parent
commit
3a8de6b94b
1 fichiers modifiés avec 46 ajouts et 27 suppressions
  1. 46 27
      Tests/KingfisherTests/ImageViewExtensionTests.swift

+ 46 - 27
Tests/KingfisherTests/ImageViewExtensionTests.swift

@@ -660,26 +660,35 @@ class ImageViewExtensionTests: XCTestCase {
         
         
         let options: KingfisherOptionsInfo = [.cacheMemoryOnly, .memoryCacheExpiration(.seconds(0.15))]
         let options: KingfisherOptionsInfo = [.cacheMemoryOnly, .memoryCacheExpiration(.seconds(0.15))]
         
         
+        let group = DispatchGroup()
+        
+        group.enter()
         imageView.kf.setImage(with: url, options: options) { result in
         imageView.kf.setImage(with: url, options: options) { result in
             XCTAssertNotNil(result.value?.image)
             XCTAssertNotNil(result.value?.image)
             XCTAssertTrue(result.value!.cacheType == .none)
             XCTAssertTrue(result.value!.cacheType == .none)
-            
-            delay(0.1) {
-                self.imageView.kf.setImage(with: url, options: options) { result in
-                    XCTAssertNotNil(result.value?.image)
-                    XCTAssertTrue(result.value!.cacheType == .memory)
-                    
-                    delay(0.1) {
-                        self.imageView.kf.setImage(with: url, options: options) { result in
-                            XCTAssertNotNil(result.value?.image)
-                            XCTAssertTrue(result.value!.cacheType == .memory)
-                            exp.fulfill()
-                        }
-                    }
-                }
+            group.leave()
+        }
+        
+        group.enter()
+        delay(0.1) {
+            self.imageView.kf.setImage(with: url, options: options) { result in
+                XCTAssertNotNil(result.value?.image)
+                XCTAssertTrue(result.value!.cacheType == .memory)
+                group.leave()
             }
             }
         }
         }
         
         
+        group.enter()
+        delay(0.2) {
+            self.imageView.kf.setImage(with: url, options: options) { result in
+                XCTAssertNotNil(result.value?.image)
+                XCTAssertTrue(result.value!.cacheType == .memory)
+                group.leave()
+            }
+        }
+        
+        group.notify(queue: .main, execute: exp.fulfill)
+        
         waitForExpectations(timeout: 3, handler: nil)
         waitForExpectations(timeout: 3, handler: nil)
     }
     }
     
     
@@ -690,25 +699,35 @@ class ImageViewExtensionTests: XCTestCase {
         
         
         let options: KingfisherOptionsInfo = [.cacheMemoryOnly, .memoryCacheExpirationNotExtendable, .memoryCacheExpiration(.seconds(0.15))]
         let options: KingfisherOptionsInfo = [.cacheMemoryOnly, .memoryCacheExpirationNotExtendable, .memoryCacheExpiration(.seconds(0.15))]
   
   
+        let group = DispatchGroup()
+        
+        group.enter()
         imageView.kf.setImage(with: url, options: options) { result in
         imageView.kf.setImage(with: url, options: options) { result in
             XCTAssertNotNil(result.value?.image)
             XCTAssertNotNil(result.value?.image)
             XCTAssertTrue(result.value!.cacheType == .none)
             XCTAssertTrue(result.value!.cacheType == .none)
-            delay(0.1) {
-                self.imageView.kf.setImage(with: url, options: options) { result in
-                    XCTAssertNotNil(result.value?.image)
-                    XCTAssertTrue(result.value!.cacheType == .memory)
-                    
-                    delay(0.1) {
-                        self.imageView.kf.setImage(with: url, options: options) { result in
-                            XCTAssertNotNil(result.value?.image)
-                            XCTAssertTrue(result.value!.cacheType == .none)
-                            exp.fulfill()
-                        }
-                    }
-                }
+            group.leave()
+        }
+        
+        group.enter()
+        delay(0.1) {
+            self.imageView.kf.setImage(with: url, options: options) { result in
+                XCTAssertNotNil(result.value?.image)
+                XCTAssertTrue(result.value!.cacheType == .memory)
+                group.leave()
             }
             }
         }
         }
         
         
+        group.enter()
+        delay(0.2) {
+            self.imageView.kf.setImage(with: url, options: options) { result in
+                XCTAssertNotNil(result.value?.image)
+                XCTAssertTrue(result.value!.cacheType == .none)
+                group.leave()
+            }
+        }
+        
+        group.notify(queue: .main, execute: exp.fulfill)
+        
         waitForExpectations(timeout: 3, handler: nil)
         waitForExpectations(timeout: 3, handler: nil)
     }
     }
 }
 }