Update the test case for WebImage static url loading

This commit is contained in:
DreamPiggy 2020-01-27 17:34:53 +08:00
parent d5c32e94c5
commit 325c187e9f
1 changed files with 12 additions and 14 deletions

View File

@ -39,24 +39,22 @@ class WebImageTests: XCTestCase {
func testWebImageWithAnimatedURL() throws { func testWebImageWithAnimatedURL() throws {
let expectation = self.expectation(description: "WebImage animated url initializer") 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<Bool>(wrappedValue: true) let binding = Binding<Bool>(wrappedValue: true)
let imageView = WebImage(url: imageUrl, isAnimating: binding) let imageView = WebImage(url: imageUrl, isAnimating: binding)
let introspectView = imageView.onSuccess { image, cacheType in let introspectView = imageView.onSuccess { image, cacheType in
if let animatedImage = image as? SDAnimatedImage { if let animatedImage = image as? SDAnimatedImage {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { XCTAssertTrue(imageView.isAnimating)
XCTAssertTrue(imageView.isAnimating) #if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) let displayImage = try? imageView.inspect().group().image(0).uiImage()
let displayImage = try? imageView.inspect().group().image(0).uiImage() #else
#else let displayImage = try? imageView.inspect().group().image(0).nsImage()
let displayImage = try? imageView.inspect().group().image(0).nsImage() #endif
#endif XCTAssertNotNil(displayImage)
XCTAssertNotNil(displayImage) // Check display image should match the animated poster frame
// Check display image should match the animated poster frame let posterImage = animatedImage.animatedImageFrame(at: 0)
let posterImage = animatedImage.animatedImageFrame(at: 0) XCTAssertEqual(displayImage?.size, posterImage?.size)
XCTAssertEqual(displayImage?.size, posterImage?.size) expectation.fulfill()
expectation.fulfill()
}
} else { } else {
XCTFail("WebImage animated image invalid") XCTFail("WebImage animated image invalid")
} }