mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-21 01:47:44 +03:00
Simple animation state tests and fixes
This commit is contained in:
parent
dd176bbd92
commit
844dfc8372
@ -8,6 +8,7 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
5713C4E21E51EC8F00BBA4D9 /* TouchEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5713C4E11E51EC8F00BBA4D9 /* TouchEvent.swift */; };
|
||||
5713C4F31E5AD46800BBA4D9 /* ControlStatesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5713C4F21E5AD46800BBA4D9 /* ControlStatesTests.swift */; };
|
||||
572CEFC71E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572CEFC51E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift */; };
|
||||
572CEFC81E2CED4B008C7C83 /* SWXMLHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572CEFC61E2CED4B008C7C83 /* SWXMLHash.swift */; };
|
||||
57A27BCF1E44C4EC0057BD3A /* ContentsInterpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57A27BCE1E44C4EC0057BD3A /* ContentsInterpolation.swift */; };
|
||||
@ -149,6 +150,7 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
5713C4E11E51EC8F00BBA4D9 /* TouchEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TouchEvent.swift; sourceTree = "<group>"; };
|
||||
5713C4F21E5AD46800BBA4D9 /* ControlStatesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlStatesTests.swift; sourceTree = "<group>"; };
|
||||
572CEFC51E2CED4B008C7C83 /* SWXMLHash+TypeConversion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SWXMLHash+TypeConversion.swift"; sourceTree = "<group>"; };
|
||||
572CEFC61E2CED4B008C7C83 /* SWXMLHash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWXMLHash.swift; sourceTree = "<group>"; };
|
||||
57A27BCE1E44C4EC0057BD3A /* ContentsInterpolation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentsInterpolation.swift; sourceTree = "<group>"; };
|
||||
@ -287,6 +289,14 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
5713C4F11E5AD35900BBA4D9 /* Animation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5713C4F21E5AD46800BBA4D9 /* ControlStatesTests.swift */,
|
||||
);
|
||||
path = Animation;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572CEFC31E2CED4B008C7C83 /* Dependencies */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -587,6 +597,7 @@
|
||||
57FCD27A1D76EA4600CC0FB6 /* MacawTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5713C4F11E5AD35900BBA4D9 /* Animation */,
|
||||
57CAB1241D7832E000FD8E47 /* svg */,
|
||||
57CAB1221D782DFC00FD8E47 /* TestUtils.swift */,
|
||||
57FCD27B1D76EA4600CC0FB6 /* MacawTests.swift */,
|
||||
@ -825,6 +836,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5713C4F31E5AD46800BBA4D9 /* ControlStatesTests.swift in Sources */,
|
||||
57FCD27C1D76EA4600CC0FB6 /* MacawTests.swift in Sources */,
|
||||
57CAB1231D782DFC00FD8E47 /* TestUtils.swift in Sources */,
|
||||
);
|
||||
|
104
MacawTests/Animation/ControlStatesTests.swift
Normal file
104
MacawTests/Animation/ControlStatesTests.swift
Normal file
@ -0,0 +1,104 @@
|
||||
//
|
||||
// ControlStatesTests.swift
|
||||
// Macaw
|
||||
//
|
||||
// Created by Victor Sukochev on 20/02/2017.
|
||||
// Copyright © 2017 Exyte. All rights reserved.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Macaw
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
}
|
@ -38,12 +38,16 @@ internal class CombineAnimation: BasicAnimation {
|
||||
}
|
||||
|
||||
open override func stop() {
|
||||
super.stop()
|
||||
|
||||
animations.forEach { animation in
|
||||
animation.stop()
|
||||
}
|
||||
}
|
||||
|
||||
open override func pause() {
|
||||
super.pause()
|
||||
|
||||
animations.forEach { animation in
|
||||
animation.pause()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user