diff --git a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/UIHostingView.swift b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/UIHostingView.swift index 2ad42f3d..d3e77ffe 100644 --- a/Sources/OpenSwiftUI/Integration/Hosting/UIKit/UIHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/Hosting/UIKit/UIHostingView.swift @@ -7,7 +7,9 @@ // ID: FAF0B683EB49BE9BABC9009857940A1E #if os(iOS) -@_spi(ForOpenSwiftUIOnly) public import OpenSwiftUICore +@_spi(ForOpenSwiftUIOnly) +@_spi(Private) +public import OpenSwiftUICore public import UIKit @available(macOS, unavailable) diff --git a/Sources/OpenSwiftUI/Test/TestApp.swift b/Sources/OpenSwiftUI/Test/TestApp.swift index f2bfab83..1fd057d9 100644 --- a/Sources/OpenSwiftUI/Test/TestApp.swift +++ b/Sources/OpenSwiftUI/Test/TestApp.swift @@ -6,6 +6,9 @@ // Status: WIP // ID: A519B5B95CA8FF4E3445832668F0B2D2 +@_spi(Testing) +import OpenSwiftUICore + public struct _TestApp { public init() { preconditionFailure("TODO") diff --git a/Sources/OpenSwiftUICore/View/Input/ViewOutputs.swift b/Sources/OpenSwiftUICore/View/Input/ViewOutputs.swift index acc22ffc..6a99fedd 100644 --- a/Sources/OpenSwiftUICore/View/Input/ViewOutputs.swift +++ b/Sources/OpenSwiftUICore/View/Input/ViewOutputs.swift @@ -13,7 +13,7 @@ public struct _ViewOutputs { private var _layoutComputer: OptionalAttribute - init() { + package init() { preferences = PreferencesOutputs() _layoutComputer = OptionalAttribute() } diff --git a/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewProxyTests.swift b/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewProxyTests.swift new file mode 100644 index 00000000..cd174092 --- /dev/null +++ b/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewProxyTests.swift @@ -0,0 +1,26 @@ +// +// IdentifiedViewProxyTests.swift +// OpenSwiftUICompatibilityTests + +import Testing +#if os(iOS) +import UIKit +#endif + +@MainActor +struct IdentifiedViewProxyTests { + @Test + func boundingRect() async { + #if os(iOS) && OPENSWIFTUI_COMPATIBILITY_TEST // FIXME: add _identified modifier + let identifier = "Test" + let hosting = UIHostingController(rootView: AnyView(EmptyView())._identified(by: identifier)) + await confirmation { @MainActor confirmation in + hosting._forEachIdentifiedView { proxy in + confirmation() + #expect(proxy.identifier == AnyHashable(identifier)) + #expect(proxy.boundingRect == .zero) + } + } + #endif + } +} diff --git a/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewTreeTests.swift b/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewTreeTests.swift new file mode 100644 index 00000000..3f3e830a --- /dev/null +++ b/Tests/OpenSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewTreeTests.swift @@ -0,0 +1,17 @@ +// +// IdentifiedViewTreeTests.swift +// OpenSwiftUICompatibilityTests + +import Testing + +struct IdentifiedViewTreeTests { + @Test + func forEachEmpty() async { + let tree = _IdentifiedViewTree.empty + await confirmation(expectedCount: 0) { confirm in + tree.forEach { _ in + confirm() + } + } + } +} diff --git a/Tests/OpenSwiftUITests/View/IdentifiedView/IdentifiedViewTreeTests.swift b/Tests/OpenSwiftUITests/View/IdentifiedView/IdentifiedViewTreeTests.swift new file mode 100644 index 00000000..d4d3f22a --- /dev/null +++ b/Tests/OpenSwiftUITests/View/IdentifiedView/IdentifiedViewTreeTests.swift @@ -0,0 +1,60 @@ +// +// IdentifiedViewTreeTests.swift +// OpenSwiftUITests + +import Testing +import OpenSwiftUI +@_spi(ForOpenSwiftUIOnly) +import OpenSwiftUICore +#if os(iOS) +import UIKit +#endif + +#if canImport(Darwin) +struct IdentifiedViewTreeTests { + private func helper(identifier: AnyHashable) -> _IdentifiedViewProxy { + return _IdentifiedViewProxy( + identifier: identifier, + size: .zero, + position: .zero, + transform: .init(), + accessibilityNode: nil, + platform: .init(.init(inputs: .invalidInputs(.invalid), outputs: _ViewOutputs())) + ) + } + + @Test + func forEachProxy() async { + let tree = _IdentifiedViewTree.proxy(helper(identifier: "1")) + await confirmation(expectedCount: 1) { confirm in + tree.forEach { _ in + confirm() + } + } + } + + @Test + func forEachArray() async { + let tree = _IdentifiedViewTree.array([ + .proxy(helper(identifier: "1")), + .empty, + .array([.proxy(helper(identifier: "2"))]) + ]) + await confirmation(expectedCount: 2) { confirm in + tree.forEach { _ in + confirm() + } + } + } + + @Test + func forEachEmpty() async { + let tree = _IdentifiedViewTree.empty + await confirmation(expectedCount: 0) { confirm in + tree.forEach { _ in + confirm() + } + } + } +} +#endif