Skip to content

Commit b6af7dc

Browse files
committed
Test flexible frame emission
1 parent ad528fa commit b6af7dc

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,32 @@ struct ModifierTests {
110110
#expect(frame?.args["height"] == .double(50))
111111
}
112112

113+
@Test("A fixed frame with default center alignment emits no alignment")
114+
func frameDefaultAlignment() {
115+
let node = ViewHost(Text("x").frame(width: 100, height: 50)).evaluate()
116+
let frame = node.modifiers.first { $0.kind == "frame" }
117+
#expect(frame?.args["horizontal"] == nil)
118+
#expect(frame?.args["vertical"] == nil)
119+
}
120+
121+
@Test("maxWidth .infinity becomes a fill flag, not a number")
122+
func frameFill() {
123+
let node = ViewHost(Text("x").frame(maxWidth: .infinity, alignment: .leading)).evaluate()
124+
let frame = node.modifiers.first { $0.kind == "frame" }
125+
#expect(frame?.args["fillWidth"] == .bool(true))
126+
#expect(frame?.args["maxWidth"] == nil)
127+
#expect(frame?.args["horizontal"] == .string("leading"))
128+
}
129+
130+
@Test("Bounded frame emits its min and max")
131+
func frameBounds() {
132+
let node = ViewHost(Text("x").frame(minWidth: 40, maxWidth: 200, minHeight: 20)).evaluate()
133+
let frame = node.modifiers.first { $0.kind == "frame" }
134+
#expect(frame?.args["minWidth"] == .double(40))
135+
#expect(frame?.args["maxWidth"] == .double(200))
136+
#expect(frame?.args["minHeight"] == .double(20))
137+
}
138+
113139
@Test("Named font emits its style")
114140
func fontStyle() {
115141
let node = ViewHost(Text("x").font(.headline)).evaluate()

0 commit comments

Comments
 (0)