Skip to content

Commit 5ce4276

Browse files
committed
Update ZIndex test case
1 parent 755d057 commit 5ce4276

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// ZIndexCompatibilityTests.swift
3+
// OpenSwiftUICompatibilityTests
4+
5+
import Foundation
6+
import Testing
7+
import SnapshotTesting
8+
9+
@MainActor
10+
@Suite(.snapshots(record: .never, diffTool: diffTool))
11+
struct ZStackIndexUITests {
12+
@Test
13+
func zIndexExample() {
14+
struct ContentView: View {
15+
var body: some View {
16+
VStack {
17+
// TODO: Path & Shape is not implemented yet.
18+
Color.yellow
19+
// Rectangle()
20+
// .fill(Color.yellow)
21+
.frame(width: 100, height: 100, alignment: .center)
22+
.zIndex(1) // Top layer.
23+
Color.red
24+
// Rectangle()
25+
// .fill(Color.red)
26+
.frame(width: 100, height: 100, alignment: .center)
27+
.rotationEffect(.degrees(45))
28+
// Here a zIndex of 0 is the default making
29+
// this the bottom layer.
30+
}
31+
}
32+
}
33+
withKnownIssue {
34+
openSwiftUIAssertSnapshot(
35+
of: ContentView(),
36+
size: CGSize(width: 200, height: 200)
37+
)
38+
}
39+
}
40+
}

Tests/OpenSwiftUICoreTests/Layout/ZIndexTests.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
// OpenSwiftUICoreTests
44

55
import OpenAttributeGraphShims
6+
@_spi(ForOpenSwiftUIOnly)
67
import OpenSwiftUICore
78
import Testing
89

910
@MainActor
1011
struct ZIndexTests {
1112
@Test
12-
func indexOrder() {
13-
struct ContentView: View {
14-
var body: some View {
15-
Color.red
16-
.zIndex(0.5)
17-
}
18-
}
19-
// TODO: Add a test helper to hook into makeViewList and retrieve the zIndex value to verify it
13+
func traitCollectionZIndex() {
14+
var collection = ViewTraitCollection()
15+
#expect(collection.zIndex.isApproximatelyEqual(to: 0.0))
16+
collection.zIndex = 1.5
17+
#expect(collection.zIndex.isApproximatelyEqual(to: 1.5))
2018
}
2119
}

0 commit comments

Comments
 (0)