Skip to content

Commit ae478b6

Browse files
committed
Fix test again by trying to use the large frame animated image, avoid animation stopped before changing binding value
1 parent 7ae9429 commit ae478b6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Tests/AnimatedImageTests.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class AnimatedImageTests: XCTestCase {
5454

5555
func testAnimatedImageWithData() throws {
5656
let expectation = self.expectation(description: "AnimatedImage data initializer")
57-
let imageData = try XCTUnwrap(TestUtils.testImageData(name: "TestImageAnimated.apng"))
57+
let imageData = try XCTUnwrap(TestUtils.testImageData(name: "TestLoopCount.gif"))
5858
let imageView = AnimatedImage(data: imageData)
5959
ViewHosting.host(view: imageView)
6060
let animatedImageView = try imageView.inspect().actualView().platformView().wrapped
6161
if let animatedImage = animatedImageView.image as? SDAnimatedImage {
62-
XCTAssertEqual(animatedImage.animatedImageLoopCount, 0)
63-
XCTAssertEqual(animatedImage.animatedImageFrameCount, 101)
62+
XCTAssertEqual(animatedImage.animatedImageLoopCount, 1)
63+
XCTAssertEqual(animatedImage.animatedImageFrameCount, 2)
6464
} else {
6565
XCTFail("SDAnimatedImageView.image invalid")
6666
}
@@ -96,14 +96,14 @@ class AnimatedImageTests: XCTestCase {
9696
let expectation = self.expectation(description: "AnimatedImage binding control")
9797
var isStopped = false
9898
// Use wrapper to make the @Binding works
99-
let wrapperView = AnimatedImage.WrapperView(name: "TestLoopCount.gif", bundle: TestUtils.testImageBundle(), isAnimating: true) { wrapperView, view, context in
99+
let wrapperView = AnimatedImage.WrapperView(name: "TestImageAnimated.apng", bundle: TestUtils.testImageBundle(), isAnimating: true) { wrapperView, view, context in
100100
guard let animatedImageView = view as? SDAnimatedImageView else {
101101
XCTFail("AnimatedImage's view should be SDAnimatedImageView")
102102
return
103103
}
104104
if let animatedImage = animatedImageView.image as? SDAnimatedImage {
105-
XCTAssertEqual(animatedImage.animatedImageLoopCount, 1)
106-
XCTAssertEqual(animatedImage.animatedImageFrameCount, 2)
105+
XCTAssertEqual(animatedImage.animatedImageLoopCount, 0)
106+
XCTAssertEqual(animatedImage.animatedImageFrameCount, 101)
107107
} else {
108108
XCTFail("AnimatedImage's image should be SDAnimatedImage")
109109
}
@@ -122,7 +122,6 @@ class AnimatedImageTests: XCTestCase {
122122
wrapperView.isAnimating = false
123123
} else {
124124
// Extra `updateUIView` from SwiftUI, ignore
125-
// During my test, iOS 13.3 (on macOS 10.15 simulator) called 2 times, iOS 13.0.0 (on macOS 10.15 simulator) called 1 time. iOS 13.3.3 (on macOS 10.14 simulator) called 2 times. Unregulated at all. Thanks Apple :)
126125
}
127126
}
128127
} else {

0 commit comments

Comments
 (0)