mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-19 17:07:13 +03:00
CombineAnimation correct states tests
This commit is contained in:
parent
8d19a32442
commit
159c8adb7f
@ -13,12 +13,16 @@ class CombineAnimationTests: XCTestCase {
|
||||
|
||||
var testView: MacawView!
|
||||
var testGroup: Group!
|
||||
var window: UIWindow!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
testGroup = [Shape(form:Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0))].group()
|
||||
testView = MacawView(node: testGroup, frame: CGRect.zero)
|
||||
|
||||
window = UIWindow()
|
||||
window.addSubview(testView)
|
||||
}
|
||||
|
||||
func testStates() {
|
||||
@ -38,36 +42,47 @@ class CombineAnimationTests: XCTestCase {
|
||||
|
||||
// PAUSE
|
||||
let pauseExpectation = expectation(description: "pause expectation")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
|
||||
pauseExpectation.fulfill()
|
||||
}
|
||||
|
||||
self.waitForExpectations(timeout: 2.0) { error in
|
||||
self.waitForExpectations(timeout: 7.0) { error in
|
||||
XCTAssertNil(error, "Async test failed")
|
||||
}
|
||||
|
||||
animation.pause()
|
||||
|
||||
let pauseEffectExpectation = expectation(description: "pause effect expectation")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
|
||||
pauseEffectExpectation.fulfill()
|
||||
}
|
||||
|
||||
self.waitForExpectations(timeout: 7.0) { error in
|
||||
XCTAssertNil(error, "Async test failed")
|
||||
}
|
||||
|
||||
XCTAssert(animation.paused && anim1.paused && anim2.paused && anim3.paused, "Inner animations incorrect state: pause")
|
||||
XCTAssert(!animation.manualStop && !anim1.manualStop && !anim2.manualStop && !anim3.manualStop, "Inner animations incorrect state: pause")
|
||||
XCTAssert(testGroup.place.dx != 0.0, "Transform animation wrong node state on pause")
|
||||
XCTAssert(testGroup.place.dx != 0.0 && testGroup.place.dx != 1.0, "Transform animation wrong node state on pause")
|
||||
XCTAssert(testGroup.opacity != 1.0 && testGroup.opacity != 0.0, "Opacity animation wrong node state on pause")
|
||||
|
||||
animation.play()
|
||||
animation.stop()
|
||||
|
||||
// STOP
|
||||
let stopExpectation = expectation(description: "stop expectation")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
|
||||
stopExpectation.fulfill()
|
||||
}
|
||||
|
||||
self.waitForExpectations(timeout: 2.0) { error in
|
||||
self.waitForExpectations(timeout: 7.0) { error in
|
||||
XCTAssertNil(error, "Async test failed")
|
||||
}
|
||||
|
||||
XCTAssert(animation.manualStop && anim1.manualStop && anim2.manualStop && anim3.manualStop, "Inner animations incorrect state: stop")
|
||||
XCTAssert(!animation.paused && !anim1.paused && !anim2.paused && !anim3.paused, "Inner animations incorrect state: stop")
|
||||
XCTAssert(testGroup.place.dx == 0.0, "Transform animation wrong node state on stop")
|
||||
XCTAssert(testGroup.opacity == 1.0, "Opacity animation wrong node state on stop")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func addOpacityAnimation(_ animation: BasicAnimation, sceneLayer: CALayer, anima
|
||||
animation.pausedProgress = 0.0
|
||||
animation.progress = 0.0
|
||||
node.opacityVar.value = opacityAnimation.getVFunc()(0.0)
|
||||
} else {
|
||||
} else if finished {
|
||||
animation.pausedProgress = 1.0
|
||||
animation.progress = 1.0
|
||||
node.opacityVar.value = opacityAnimation.getVFunc()(1.0)
|
||||
|
@ -34,7 +34,7 @@ func addTransformAnimation(_ animation: BasicAnimation, sceneLayer: CALayer, ani
|
||||
animation.pausedProgress = 0.0
|
||||
animation.progress = 0.0
|
||||
node.placeVar.value = transformAnimation.getVFunc()(0.0)
|
||||
} else {
|
||||
} else if finished {
|
||||
animation.pausedProgress = 1.0
|
||||
animation.progress = 1.0
|
||||
node.placeVar.value = transformAnimation.getVFunc()(1.0)
|
||||
|
Loading…
Reference in New Issue
Block a user