-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable perception tracking in UI/NS views/controllers representables (…
…#223) * Disable perception tracking when creating UI/NS views/controllers in a representable. * clean up * wip * fix watchos * fix watchos * Update Tests/UIKitNavigationTests/ObserveTests.swift
- Loading branch information
Showing
3 changed files
with
48 additions
and
4 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
36 changes: 36 additions & 0 deletions
36
Tests/UIKitNavigationTests/ViewControllerRepresentingTests.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,36 @@ | ||
#if canImport(UIKit) && !os(watchOS) | ||
import UIKitNavigation | ||
import SwiftUI | ||
import XCTest | ||
|
||
@available(iOS 16, tvOS 16, *) | ||
class ViewControllerRepresentingTests: XCTestCase { | ||
@MainActor | ||
func testPerceptionCheckingInNavigationStackController() async throws { | ||
struct RootView: View { | ||
@UIBindable var model = AppModel() | ||
var body: some View { | ||
UIViewControllerRepresenting { | ||
NavigationStackController(path: $model.path) { | ||
UIViewController() | ||
} | ||
} | ||
} | ||
} | ||
|
||
try await render(RootView()) | ||
} | ||
|
||
@MainActor | ||
private func render(_ view: some View) async throws { | ||
let image = ImageRenderer(content: view).cgImage | ||
_ = image | ||
try await Task.sleep(for: .seconds(0.1)) | ||
} | ||
} | ||
|
||
@Perceptible | ||
private class AppModel: HashableObject { | ||
var path: [Int] = [] | ||
} | ||
#endif |