From 325c187e9fb106e673a5a35de59ce088614c88b0 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Mon, 27 Jan 2020 17:34:53 +0800 Subject: [PATCH] Update the test case for WebImage static url loading --- Tests/WebImageTests.swift | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Tests/WebImageTests.swift b/Tests/WebImageTests.swift index be8556a..f1c2cac 100644 --- a/Tests/WebImageTests.swift +++ b/Tests/WebImageTests.swift @@ -39,24 +39,22 @@ class WebImageTests: XCTestCase { func testWebImageWithAnimatedURL() throws { let expectation = self.expectation(description: "WebImage animated url initializer") - let imageUrl = URL(string: "http://apng.onevcat.com/assets/elephant.png") + let imageUrl = URL(string: "https://apng.onevcat.com/assets/elephant.png") let binding = Binding(wrappedValue: true) let imageView = WebImage(url: imageUrl, isAnimating: binding) let introspectView = imageView.onSuccess { image, cacheType in if let animatedImage = image as? SDAnimatedImage { - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - XCTAssertTrue(imageView.isAnimating) - #if os(iOS) || os(tvOS) - let displayImage = try? imageView.inspect().group().image(0).uiImage() - #else - let displayImage = try? imageView.inspect().group().image(0).nsImage() - #endif - XCTAssertNotNil(displayImage) - // Check display image should match the animated poster frame - let posterImage = animatedImage.animatedImageFrame(at: 0) - XCTAssertEqual(displayImage?.size, posterImage?.size) - expectation.fulfill() - } + XCTAssertTrue(imageView.isAnimating) + #if os(iOS) || os(tvOS) + let displayImage = try? imageView.inspect().group().image(0).uiImage() + #else + let displayImage = try? imageView.inspect().group().image(0).nsImage() + #endif + XCTAssertNotNil(displayImage) + // Check display image should match the animated poster frame + let posterImage = animatedImage.animatedImageFrame(at: 0) + XCTAssertEqual(displayImage?.size, posterImage?.size) + expectation.fulfill() } else { XCTFail("WebImage animated image invalid") }