File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ Changelog
3
3
4
4
## master
5
5
6
+ - Added ` .introspectButton() ` on macOS
6
7
- Fix UITextField with cornerRadius
7
8
- Added ` .introspectTabView() ` on macOS
8
9
Original file line number Diff line number Diff line change @@ -198,5 +198,10 @@ extension View {
198
198
public func introspectTabView( customize: @escaping ( NSTabView ) -> ( ) ) -> some View {
199
199
return introspect ( selector: TargetViewSelector . siblingContaining, customize: customize)
200
200
}
201
+
202
+ /// Finds a `NSButton` from a `SwiftUI.Button`
203
+ public func introspectButton( customize: @escaping ( NSButton ) -> ( ) ) -> some View {
204
+ return introspect ( selector: TargetViewSelector . siblingContaining, customize: customize)
205
+ }
201
206
}
202
207
#endif
Original file line number Diff line number Diff line change @@ -203,6 +203,17 @@ private struct TabViewTestView: View {
203
203
}
204
204
}
205
205
206
+ @available ( macOS 10 . 15 . 0 , * )
207
+ private struct ButtonTestView : View {
208
+ let spy : ( ) -> Void
209
+ var body : some View {
210
+ Button ( " Test " , action: { } )
211
+ . introspectButton { button in
212
+ self . spy ( )
213
+ }
214
+ }
215
+ }
216
+
206
217
@available ( macOS 10 . 15 . 0 , * )
207
218
class AppKitTests : XCTestCase {
208
219
@@ -346,5 +357,15 @@ class AppKitTests: XCTestCase {
346
357
TestUtils . present ( view: view)
347
358
wait ( for: [ expectation] , timeout: TestUtils . Constants. timeout)
348
359
}
360
+
361
+ func testButton( ) {
362
+
363
+ let expectation = XCTestExpectation ( )
364
+ let view = ButtonTestView ( spy: {
365
+ expectation. fulfill ( )
366
+ } )
367
+ TestUtils . present ( view: view)
368
+ wait ( for: [ expectation] , timeout: TestUtils . Constants. timeout)
369
+ }
349
370
}
350
371
#endif
You can’t perform that action at this time.
0 commit comments