1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-10-26 13:01:25 +03:00
Macaw/MacawTests/Animation/ControlStatesTests.swift

110 lines
3.6 KiB
Swift
Raw Normal View History

2017-02-20 11:37:00 +03:00
//
// ControlStatesTests.swift
// Macaw
//
// Created by Victor Sukochev on 20/02/2017.
// Copyright © 2017 Exyte. All rights reserved.
//
import XCTest
2019-05-29 12:44:06 +03:00
#if os(OSX)
@testable import MacawOSX
#elseif os(iOS)
2017-02-20 11:37:00 +03:00
@testable import Macaw
2019-05-29 12:44:06 +03:00
#endif
2017-02-20 11:37:00 +03:00
class ControlStatesTests: XCTestCase {
var testNode: Node!
override func setUp() {
super.setUp()
testNode = Shape(form:Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0))
}
func testTransformAnimation() {
let animation = testNode.placeVar.animation(to: .identity) as! TransformAnimation
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.pause()
XCTAssert( animation.paused && !animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.stop()
XCTAssert( !animation.paused && animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
}
func testOpacityAnimation() {
let animation = testNode.opacityVar.animation(to: 0.0) as! OpacityAnimation
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.pause()
XCTAssert( animation.paused && !animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.stop()
XCTAssert( !animation.paused && animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
}
func testContentsAnimation() {
let group = [testNode].group()
2017-03-09 17:08:17 +03:00
let animation = group.contentsVar.animation { t -> [Node] in
2017-02-20 11:37:00 +03:00
return [self.testNode]
2017-03-09 17:08:17 +03:00
} as! ContentsAnimation
2017-02-20 11:37:00 +03:00
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.pause()
XCTAssert( animation.paused && !animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.stop()
XCTAssert( !animation.paused && animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
}
func testCombineAnimation() {
let animation = [
testNode.placeVar.animation(to: .identity),
testNode.opacityVar.animation(to: 0.0)
].combine() as! CombineAnimation
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.pause()
XCTAssert( animation.paused && !animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
animation.stop()
XCTAssert( !animation.paused && animation.manualStop, "Wrong animation state: pause")
animation.play()
XCTAssert(!(animation.paused || animation.manualStop), "Wrong animation state: play")
}
}