Skip to content

Commit ad4134c

Browse files
committed
wip
1 parent 44a1ed2 commit ad4134c

File tree

6 files changed

+56
-14
lines changed

6 files changed

+56
-14
lines changed

Tests/AtomicTransitionTests/MoveTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import XCTest
55

66
final class MoveTests: XCTestCase {
77
let animatorUsed = UnimplementedAnimator()
8-
let uiViewUsed = UIView()
9-
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
8+
let viewUsed = AnimatorTransientView(UIView())
109
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
1110
let containerUsed: UIView = {
1211
let _containerUsed = UIView()

Tests/AtomicTransitionTests/OffsetTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import XCTest
55

66
final class OffsetTests: XCTestCase {
77
let animatorUsed = UnimplementedAnimator()
8-
let uiViewUsed = UIView()
9-
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
8+
let viewUsed = AnimatorTransientView(UIView())
109
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
11-
lazy var contextUsed = MockedContext(containerView: UIView())
10+
let contextUsed = MockedContext(containerView: UIView())
1211

1312
func testInsertion() {
1413
AtomicTransition.offset(x: 100, y: 200).prepare(animatorUsed, or: viewUsed, for: .insertion, in: contextUsed)

Tests/AtomicTransitionTests/OpacityTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import XCTest
55

66
final class OpacityTests: XCTestCase {
77
let animatorUsed = UnimplementedAnimator()
8-
let uiViewUsed = UIView()
9-
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
8+
let viewUsed = AnimatorTransientView(UIView())
109
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
11-
lazy var contextUsed = MockedContext(containerView: UIView())
10+
let contextUsed = MockedContext(containerView: UIView())
1211

1312
func testInsertion() {
1413
AtomicTransition.opacity.prepare(animatorUsed, or: viewUsed, for: .insertion, in: contextUsed)

Tests/AtomicTransitionTests/RotateTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import XCTest
66

77
final class RotateTests: XCTestCase {
88
let animatorUsed = UnimplementedAnimator()
9-
let uiViewUsed = UIView()
10-
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
9+
let viewUsed = AnimatorTransientView(UIView())
1110
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
12-
lazy var contextUsed = MockedContext(containerView: UIView())
11+
let contextUsed = MockedContext(containerView: UIView())
1312

1413
func testInsertion() {
1514
AtomicTransition.rotate(.radians(.pi)).prepare(animatorUsed, or: viewUsed, for: .insertion, in: contextUsed)

Tests/AtomicTransitionTests/ScaleTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import XCTest
66

77
final class ScaleTests: XCTestCase {
88
let animatorUsed = UnimplementedAnimator()
9-
let uiViewUsed = UIView()
10-
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
9+
let viewUsed = AnimatorTransientView(UIView())
1110
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
12-
lazy var contextUsed = MockedContext(containerView: UIView())
11+
let contextUsed = MockedContext(containerView: UIView())
1312

1413
func testInsertion() {
1514
AtomicTransition.scale(0.5).prepare(animatorUsed, or: viewUsed, for: .insertion, in: contextUsed)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@_spi(package) @testable import Animator
2+
@_spi(package) import AtomicTransition
3+
import XCTest
4+
5+
final class ZPositionTests: XCTestCase {
6+
let animatorUsed = UnimplementedAnimator()
7+
let uiViewUsed = UIView()
8+
lazy var viewUsed = AnimatorTransientView(uiViewUsed)
9+
let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity)
10+
let anotherUIViewA = UIView()
11+
let anotherUIViewB = UIView()
12+
let operation = AtomicTransition.Operation.random()
13+
lazy var containerView: UIView = {
14+
let _containerView = UIView()
15+
_containerView.addSubview(anotherUIViewA)
16+
_containerView.addSubview(uiViewUsed)
17+
_containerView.addSubview(anotherUIViewB)
18+
return _containerView
19+
}()
20+
lazy var contextUsed = MockedContext(containerView: containerView)
21+
22+
func testInitialState() {
23+
XCTAssertIdentical(containerView.subviews[0], anotherUIViewA)
24+
XCTAssertIdentical(containerView.subviews[1], uiViewUsed)
25+
XCTAssertIdentical(containerView.subviews[2], anotherUIViewB)
26+
}
27+
28+
func testFront() {
29+
AtomicTransition.zPosition(.front).prepare(animatorUsed, or: viewUsed, for: operation, in: contextUsed)
30+
31+
XCTAssertIdentical(containerView.subviews[0], anotherUIViewA)
32+
XCTAssertIdentical(containerView.subviews[1], anotherUIViewB)
33+
XCTAssertIdentical(containerView.subviews[2], uiViewUsed)
34+
}
35+
36+
func testBack() {
37+
AtomicTransition.zPosition(.back).prepare(animatorUsed, or: viewUsed, for: operation, in: contextUsed)
38+
39+
XCTAssertIdentical(containerView.subviews[0], uiViewUsed)
40+
XCTAssertIdentical(containerView.subviews[1], anotherUIViewA)
41+
XCTAssertIdentical(containerView.subviews[2], anotherUIViewB)
42+
}
43+
44+
// TODO: assert for (x, y | x | y) conveniences equality when this is done:
45+
// https://github.com/davdroman/swiftui-navigation-transitions/discussions/6
46+
// func testConveniences() {}
47+
}

0 commit comments

Comments
 (0)