You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XCTFail("AnimatedImage's view should be SDAnimatedImageView")
103
102
return
@@ -108,33 +107,32 @@ class AnimatedImageTests: XCTestCase {
108
107
}else{
109
108
XCTFail("AnimatedImage's image should be SDAnimatedImage")
110
109
}
111
-
// View update times before stable from SwiftUI, different behavior for AppKit/UIKit
112
-
#if os(macOS)
113
-
letstableViewUpdateCount=1
114
-
#else
115
-
letstableViewUpdateCount=2
116
-
#endif
117
-
switch viewUpdateCount {
118
-
case stableViewUpdateCount:
119
-
// #1 SwiftUI's own updateUIView call
110
+
// Wait 1 second for SwiftUI's own `updateUIView` callback finished.
111
+
// It's suck that the actual callback behavior is different on different iOS version or Simulator version, so I can assume which is the last callback using the callback count.
112
+
if !isStopped {
113
+
// # SwiftUI's own updateUIView call
120
114
#if os(iOS) || os(tvOS)
121
115
XCTAssertTrue(animatedImageView.isAnimating)
122
116
#else
123
117
XCTAssertTrue(animatedImageView.animates)
124
118
#endif
125
-
DispatchQueue.main.async{
126
-
wrapperView.isAnimating =false
119
+
DispatchQueue.main.asyncAfter(deadline:.now()+1){
120
+
if !isStopped {
121
+
isStopped =true
122
+
wrapperView.isAnimating =false
123
+
}else{
124
+
// 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 :)
0 commit comments