-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...nSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewProxyTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...enSwiftUICompatibilityTests/SwiftUICore/View/IdentifiedView/IdentifiedViewTreeTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Tests/OpenSwiftUITests/View/IdentifiedView/IdentifiedViewTreeTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// IdentifiedViewTreeTests.swift | ||
// OpenSwiftUITests | ||
|
||
import Testing | ||
import OpenSwiftUI | ||
@_spi(ForOpenSwiftUIOnly) | ||
import OpenSwiftUICore | ||
#if os(iOS) | ||
import UIKit | ||
#endif | ||
|
||
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() | ||
} | ||
} | ||
} | ||
} |