Add NSButton Introspection (#85)
This commit is contained in:
parent
07a80dd280
commit
4232b86790
|
@ -3,6 +3,7 @@ Changelog
|
|||
|
||||
## master
|
||||
|
||||
- Added `.introspectButton()` on macOS
|
||||
- Fix UITextField with cornerRadius
|
||||
- Added `.introspectTabView()` on macOS
|
||||
|
||||
|
|
|
@ -198,5 +198,10 @@ extension View {
|
|||
public func introspectTabView(customize: @escaping (NSTabView) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
|
||||
/// Finds a `NSButton` from a `SwiftUI.Button`
|
||||
public func introspectButton(customize: @escaping (NSButton) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -203,6 +203,17 @@ private struct TabViewTestView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15.0, *)
|
||||
private struct ButtonTestView: View {
|
||||
let spy: () -> Void
|
||||
var body: some View {
|
||||
Button("Test", action: {})
|
||||
.introspectButton { button in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15.0, *)
|
||||
class AppKitTests: XCTestCase {
|
||||
|
||||
|
@ -346,5 +357,15 @@ class AppKitTests: XCTestCase {
|
|||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testButton() {
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
let view = ButtonTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue