1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-10-26 13:01:25 +03:00
Macaw/MacawTests/Animation/ControlStatesTests.swift
2019-06-04 11:30:48 +07:00

110 lines
3.6 KiB
Swift

//
// ControlStatesTests.swift
// Macaw
//
// Created by Victor Sukochev on 20/02/2017.
// Copyright © 2017 Exyte. All rights reserved.
//
import XCTest
#if os(OSX)
@testable import MacawOSX
#elseif os(iOS)
@testable import Macaw
#endif
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()
let animation = group.contentsVar.animation { t -> [Node] in
return [self.testNode]
} as! ContentsAnimation
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")
}
}