2
2
// SPDX-License-Identifier: BSD-3-Clause
3
3
4
4
import XCTest
5
- import SwiftWin32
5
+ @ testable import SwiftWin32
6
6
7
7
final class ViewTests : XCTestCase {
8
8
func testConvertSameParent( ) {
@@ -13,7 +13,7 @@ final class ViewTests: XCTestCase {
13
13
14
14
let password : View =
15
15
View ( frame: Rect ( x: 4.0 , y: 113.0 , width: 254.0 , height: 17.0 ) )
16
-
16
+
17
17
window. addSubview ( password)
18
18
window. addSubview ( textfield)
19
19
@@ -60,7 +60,7 @@ final class ViewTests: XCTestCase {
60
60
XCTAssertEqual ( point. x, 80.12346855145998 , accuracy: accuracy)
61
61
XCTAssertEqual ( point. y, - 140.97315764408575 , accuracy: accuracy)
62
62
63
-
63
+
64
64
let inputRect = Rect ( origin: Point ( x: 45 , y: 115 ) , size: Size ( width: 13 , height: 14 ) )
65
65
var rect = grandChild. convert ( inputRect, to: childB)
66
66
XCTAssertEqual ( rect. origin. x, 123.17714789769627 , accuracy: accuracy)
@@ -112,7 +112,7 @@ final class ViewTests: XCTestCase {
112
112
point = grandChild. convert ( inputPoint, from: childA)
113
113
XCTAssertEqual ( point. x, - 129.11445551798738 , accuracy: accuracy)
114
114
XCTAssertEqual ( point. y, 98.14414561159256 , accuracy: accuracy)
115
-
115
+
116
116
let inputRect = Rect ( origin: Point ( x: 45 , y: 115 ) , size: Size ( width: 13 , height: 14 ) )
117
117
var rect = grandChild. convert ( inputRect, to: childB)
118
118
XCTAssertEqual ( rect. origin. x, 123.17714789769627 , accuracy: accuracy)
@@ -133,9 +133,31 @@ final class ViewTests: XCTestCase {
133
133
XCTAssertEqual ( rect. size. height, 2.0132111355644327 , accuracy: accuracy)
134
134
}
135
135
136
+ func testViewTraitCollection( ) {
137
+ let window : Window =
138
+ Window ( frame: Rect ( x: 0.0 , y: 0.0 , width: 640 , height: 480 ) )
139
+
140
+ let view : View = View ( frame: . zero)
141
+ XCTAssertTrue ( view. traitCollection === TraitCollection . current)
142
+
143
+ window. addSubview ( view)
144
+ XCTAssertTrue ( view. traitCollection === TraitCollection . current)
145
+
146
+ let session : SceneSession =
147
+ SceneSession ( identifier: UUID ( ) . uuidString, role: . windowApplication)
148
+ let scene : WindowScene =
149
+ WindowScene ( session: session,
150
+ connectionOptions: Scene . ConnectionOptions ( ) )
151
+
152
+ window. windowScene = scene
153
+ // FIXME(compnerd) the view.window is not setup properly
154
+ // XCTAssertTrue(view.traitCollection === scene.screen.traitCollection)
155
+ }
156
+
136
157
static var allTests = [
137
158
( " testConvertSameParent " , testConvertSameParent) ,
138
159
( " testConvertWithRotationsAndBounds " , testConvertWithRotationsAndBounds) ,
139
160
( " testConvertWithAllTransformsAndBounds " , testConvertWithAllTransformsAndBounds) ,
161
+ ( " testViewTraitCollection " , testViewTraitCollection) ,
140
162
]
141
163
}
0 commit comments