Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions Tests/OpenSwiftUICoreTests/View/VariadicViewTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// VariadicViewTests.swift
// OpenSwiftUICoreTests

import Foundation
import OpenSwiftUICore
import Testing

struct PassthroughUnaryViewRoot: _VariadicView.UnaryViewRoot {
func body(children: _VariadicView.Children) -> some View {
children
}
}

struct PassthroughMultiViewRoot: _VariadicView.MultiViewRoot {
func body(children: _VariadicView.Children) -> some View {
children
}
}

@MainActor
struct VariadicViewTests {

#if canImport(Darwin)
@Test
func nestedUnaryViewRoot() {
struct ContentView: View {
var body: some View {
_VariadicView.Tree(PassthroughUnaryViewRoot()) {
_VariadicView.Tree(PassthroughUnaryViewRoot()) {
Color.red
Color.blue
}
}
}
}

let graph = ViewGraph(
rootViewType: ContentView.self,
requestedOutputs: [.displayList]
)
graph.instantiateOutputs()
graph.setRootView(ContentView())
graph.setProposedSize(CGSize(width: 100, height: 100))
let (displayList, _) = graph.displayList()
let expectRegex = try! Regex(
#"""
\(display-list
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(content-seed \d+\)
\(color #[0-9A-F]{8}\)\)\)\)
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(content-seed \d+\)
\(color #[0-9A-F]{8}\)\)\)\)\)\)\)
"""#)
#expect(displayList.description.contains(expectRegex))
}

@Test
func nestedMultiViewRoot() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR adds only the repro test, if the underlying crash is still present this will abort the whole test run (fatal error) rather than reporting a normal test failure; is this intended to land only together with the fix or be marked as an expected failure until then?

Severity: medium

Other Locations
  • Tests/OpenSwiftUICoreTests/View/VariadicViewTests.swift:26

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

struct ContentView: View {
var body: some View {
_VariadicView.Tree(PassthroughMultiViewRoot()) {
_VariadicView.Tree(PassthroughMultiViewRoot()) {
Color.red
Color.blue
}
}
}
}

let graph = ViewGraph(
rootViewType: ContentView.self,
requestedOutputs: [.displayList]
)
graph.instantiateOutputs()
graph.setRootView(ContentView())
graph.setProposedSize(CGSize(width: 100, height: 100))
let (displayList, _) = graph.displayList()
let expectRegex = try! Regex(
#"""
\(display-list
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(content-seed \d+\)
\(color #[0-9A-F]{8}\)\)\)\)
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(effect
\(item #:identity \d+ #:version \d+
\(frame \([^)]+\)\)
\(content-seed \d+\)
\(color #[0-9A-F]{8}\)\)\)\)\)\)\)
"""#)
#expect(displayList.description.contains(expectRegex))
}
#endif
}
Loading