File tree Expand file tree Collapse file tree
Sources/OpenSwiftUI/Integration/Hosting/UIKit/View
Tests/OpenSwiftUITests/Integration/Hosting/UIKit/View Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -212,7 +212,7 @@ package class UIHostingViewBase {
212212 }
213213 var result = traitCollection. resolvedEnvironment ( base: EnvironmentValues ( environment. plist) )
214214 result. configureForPlatform ( traitCollection: traitCollection)
215- return environment
215+ return result
216216 }
217217
218218 package func endUpdateEnvironment( _ environment: EnvironmentValues ) {
Original file line number Diff line number Diff line change 55#if os(iOS) || os(visionOS)
66import Foundation
77import Testing
8- @ testable import OpenSwiftUI
8+ import OpenSwiftUI
99@_spi ( ForOpenSwiftUIOnly)
1010import OpenSwiftUICore
1111import UIKit
1212import OpenSwiftUITestsSupport
1313
1414@MainActor
1515struct UIHostingViewBaseTests {
16+ @Test
17+ func startUpdateEnvironmentReturnsResolvedTraitEnvironment( ) {
18+ let uiView = UIView ( )
19+ let base = UIHostingViewBase ( rootViewType: EmptyView . self, options: [ ] )
20+ base. uiView = uiView
21+ base. traitCollectionOverride = UITraitCollection ( traitsFrom: [
22+ UITraitCollection ( layoutDirection: . rightToLeft) ,
23+ UITraitCollection ( displayScale: 3.0 ) ,
24+ ] )
25+
26+ var inheritedEnvironment = EnvironmentValues ( )
27+ inheritedEnvironment. layoutDirection = . leftToRight
28+ inheritedEnvironment. displayScale = 1.0
29+ base. inheritedEnvironment = inheritedEnvironment
30+
31+ let environment = base. startUpdateEnvironment ( )
32+ #expect( environment. layoutDirection == . rightToLeft)
33+ #expect( environment. displayScale == 3.0 )
34+ }
35+
1636 @Test ( . bug( id: " #406 " ) )
1737 func uiWindowSceneDeallocIssue( ) async throws {
1838 struct ContentView : View {
You can’t perform that action at this time.
0 commit comments