@@ -7,17 +7,15 @@ import XCTest
77
88final class PreferredContentSizeTests : XCTestCase {
99 func test_preferredContentSize( ) throws {
10- // FIXME: actually solve whatever the problem is here
11- try XCTSkipUnless ( UIApplication . shared. delegate != nil )
12-
1310 let maxWidth : CGFloat = 50
1411 let maxHeight : CGFloat = 50
1512
13+ // fudged offset to avoid safe area interference
14+ let origin = CGPoint ( x: 50 , y: 50 )
15+
1616 func assertPreferredContentSize( in axes: Axis . Set ) {
1717 let screen = TestScreen ( model: . constant( state: State ( axes: axes) ) )
1818 let viewController = screen. buildViewController ( in: . empty)
19- viewController. view. frame = CGRect ( x: 0 , y: 0 , width: maxWidth, height: maxHeight)
20- viewController. view. layoutIfNeeded ( )
2119
2220 func assertContentSize(
2321 _ contentSize: CGSize ,
@@ -41,16 +39,24 @@ final class PreferredContentSizeTests: XCTestCase {
4139 )
4240 }
4341
44- assertContentSize ( CGSize ( width: 20 , height: 20 ) )
45- assertContentSize ( CGSize ( width: 40 , height: 20 ) )
46- assertContentSize ( CGSize ( width: 20 , height: 40 ) )
47- assertContentSize (
48- CGSize ( width: 100 , height: 100 ) ,
49- expected: CGSize (
50- width: axes. contains ( . horizontal) ? maxWidth : 100 ,
51- height: axes. contains ( . vertical) ? maxHeight : 100
42+ show ( viewController: viewController) { _ in
43+ viewController. view. frame = CGRect (
44+ origin: origin,
45+ size: CGSize ( width: maxWidth, height: maxHeight)
46+ )
47+ viewController. view. layoutIfNeeded ( )
48+
49+ assertContentSize ( CGSize ( width: 20 , height: 20 ) )
50+ assertContentSize ( CGSize ( width: 40 , height: 20 ) )
51+ assertContentSize ( CGSize ( width: 20 , height: 40 ) )
52+ assertContentSize (
53+ CGSize ( width: 100 , height: 100 ) ,
54+ expected: CGSize (
55+ width: axes. contains ( . horizontal) ? maxWidth : 100 ,
56+ height: axes. contains ( . vertical) ? maxHeight : 100
57+ )
5258 )
53- )
59+ }
5460 }
5561
5662 assertPreferredContentSize ( in: [ ] )
@@ -116,10 +122,12 @@ private struct TestView: View {
116122 }
117123 }
118124 }
125+ . ignoresSafeArea ( )
119126 }
120127
121128 var box : some View {
122129 Color . red. frame ( width: store. width, height: store. height)
130+ . ignoresSafeArea ( )
123131 }
124132}
125133
0 commit comments