Skip to content

Commit

Permalink
Add appear test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Jun 2, 2024
1 parent 833728b commit 9728864
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Sources/OpenSwiftUI/Core/Update/Update.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,24 @@ enum Update {

@inline(__always)
static func dispatchActions() {
// FIXME
for action in actions {
action()
guard !actions.isEmpty else {
return
}

let actions = Update.actions
Update.actions = []
performOnMainThread {
// TODO: Signpost.postUpdateActions
begin()
for action in actions {
let oldDepth = depth
action()
let newDepth = depth
if newDepth != oldDepth {
fatalError("Action caused unbalanced updates.")
}
}
end()
}
}

Expand Down Expand Up @@ -107,5 +122,5 @@ extension Update {
// FIXME: migrate to use @_extern(c, "xx") in Swift 6
extension MovableLock {
@_silgen_name("_MovableLockSyncMain")
static func syncMain(lock: MovableLock ,body: @escaping () -> Void)
static func syncMain(lock: MovableLock, body: @escaping () -> Void)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AppearanceActionModifierTests.swift
// OpenSwiftUICompatibilityTests

import Testing

@MainActor
struct AppearanceActionModifierTests {
@Test
func appear() async throws {
struct ContentView: View {
var confirmation: Confirmation

var body: some View {
AnyView(EmptyView())
.onAppear {
confirmation()
}
}
}

await confirmation { confirmation in
#if os(iOS)
let vc = UIHostingController(rootView: ContentView(confirmation: confirmation))
vc.triggerLayout()
workaroundIssue87(vc)
#endif
}
}

// TODO: Add disappear support and test case
}

0 comments on commit 9728864

Please sign in to comment.