-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathExampleViewControllerTests.swift
41 lines (33 loc) · 1.1 KB
/
ExampleViewControllerTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import XCTest
import SnapshotTesting
@testable import DemoApp
class ExampleViewControllerTests: XCTestCase {
var sut: ExampleViewController!
var window: UIWindow!
override func setUp() {
sut = ExampleViewController()
window = UIWindow(frame: CGRect(x: 0, y: 0, width: 220, height: 100))
window.rootViewController = sut
window.isHidden = false
}
override func tearDown() {
window = nil
sut = nil
}
func testAnimation() {
let animator = UIViewPropertyAnimator(duration: 1, curve: .linear, animations: {
self.sut.animate()
})
(0...10).map { CGFloat($0) / 10.0 }.forEach { animationProgress in
animator.fractionComplete = animationProgress
assertSnapshot(
matching: window,
as: .image(drawHierarchyInKeyWindow: true),
named: "animation_\(String(format: "%02.0f", animationProgress * 10))"
)
}
animator.pauseAnimation()
animator.stopAnimation(false)
animator.finishAnimation(at: .current)
}
}