Add introspection for `NSTabView` (#84)
Add introspection for `NSTabView`
This commit is contained in:
parent
2cf3d5f5a6
commit
fab6cddbaf
|
@ -3,6 +3,8 @@ Changelog
|
|||
|
||||
## master
|
||||
|
||||
- Added `.introspectTabView()` on macOS
|
||||
|
||||
## [0.1.3]
|
||||
|
||||
- Added `introspectTableViewCell`
|
||||
|
|
|
@ -193,5 +193,10 @@ extension View {
|
|||
public func introspectSegmentedControl(customize: @escaping (NSSegmentedControl) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
|
||||
/// Finds a `NSTabView` from a `SwiftUI.TabView`
|
||||
public func introspectTabView(customize: @escaping (NSTabView) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -183,6 +183,26 @@ private struct SegmentedControlTestView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15.0, *)
|
||||
private struct TabViewTestView: View {
|
||||
let spy: () -> Void
|
||||
var body: some View {
|
||||
TabView {
|
||||
Text("Contents")
|
||||
.tabItem {
|
||||
Text("Tab 1")
|
||||
}
|
||||
Text("Contents")
|
||||
.tabItem {
|
||||
Text("Tab 2")
|
||||
}
|
||||
}
|
||||
.introspectTabView { tabView in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15.0, *)
|
||||
class AppKitTests: XCTestCase {
|
||||
|
||||
|
@ -316,5 +336,15 @@ class AppKitTests: XCTestCase {
|
|||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testTabView() {
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
let view = TabViewTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue