Add .introspectColorWell() (#87)
This commit is contained in:
parent
4232b86790
commit
6569a749d4
|
@ -3,6 +3,7 @@ Changelog
|
|||
|
||||
## master
|
||||
|
||||
- Added `.introspectColorWell()` on iOS and macOS
|
||||
- Added `.introspectButton()` on macOS
|
||||
- Fix UITextField with cornerRadius
|
||||
- Added `.introspectTabView()` on macOS
|
||||
|
|
|
@ -127,6 +127,13 @@ extension View {
|
|||
public func introspectSegmentedControl(customize: @escaping (UISegmentedControl) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
|
||||
/// Finds a `UIColorWell` from a `SwiftUI.ColorPicker`
|
||||
@available(iOS 14.0, *)
|
||||
@available(tvOS, unavailable)
|
||||
public func introspectColorWell(customize: @escaping (UIColorWell) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -203,5 +210,11 @@ extension View {
|
|||
public func introspectButton(customize: @escaping (NSButton) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
|
||||
/// Finds a `NSColorWell` from a `SwiftUI.ColorPicker`
|
||||
@available(macOS 11.0, *)
|
||||
public func introspectColorWell(customize: @escaping (NSColorWell) -> ()) -> some View {
|
||||
return introspect(selector: TargetViewSelector.siblingContaining, customize: customize)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -214,6 +214,19 @@ private struct ButtonTestView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(macOS 11.0, *)
|
||||
private struct ColorWellTestView: View {
|
||||
@State private var color = Color.black
|
||||
let spy: () -> Void
|
||||
|
||||
var body: some View {
|
||||
ColorPicker("Picker", selection: $color)
|
||||
.introspectColorWell { colorWell in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 10.15.0, *)
|
||||
class AppKitTests: XCTestCase {
|
||||
|
||||
|
@ -367,5 +380,17 @@ class AppKitTests: XCTestCase {
|
|||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
func testColorPicker() {
|
||||
|
||||
if #available(macOS 11.0, *) {
|
||||
let expectation = XCTestExpectation()
|
||||
let view = ColorWellTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -217,7 +217,7 @@ private struct TextFieldTestView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 11.0, *)
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 11.0, tvOS 13.0, *)
|
||||
@available(tvOS, unavailable, message: "TextEditor is not available in tvOS.")
|
||||
private struct TextEditorTestView: View {
|
||||
let spy: () -> Void
|
||||
|
@ -302,6 +302,20 @@ private struct SegmentedControlTestView: View {
|
|||
}
|
||||
}
|
||||
|
||||
@available(iOS 14.0, tvOS 13.0, macOS 11.0, *)
|
||||
@available(tvOS, unavailable)
|
||||
private struct ColorWellTestView: View {
|
||||
@State private var color = Color.black
|
||||
let spy: () -> Void
|
||||
|
||||
var body: some View {
|
||||
ColorPicker("Picker", selection: $color)
|
||||
.introspectColorWell { colorWell in
|
||||
self.spy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 13.0, tvOS 13.0, macOS 10.15.0, *)
|
||||
class UIKitTests: XCTestCase {
|
||||
func testNavigation() {
|
||||
|
@ -512,7 +526,7 @@ class UIKitTests: XCTestCase {
|
|||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 15.0, *)
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 11.0, *)
|
||||
@available(tvOS, unavailable, message: "TextEditor is not available in tvOS.")
|
||||
func testTextEditor() {
|
||||
|
||||
|
@ -523,6 +537,18 @@ class UIKitTests: XCTestCase {
|
|||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
|
||||
@available(iOS 14.0, macCatalyst 14.0, macOS 11.0, *)
|
||||
@available(tvOS, unavailable, message: "ColorPicker is not available in tvOS.")
|
||||
func testColorPicker() {
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
let view = ColorWellTestView(spy: {
|
||||
expectation.fulfill()
|
||||
})
|
||||
TestUtils.present(view: view)
|
||||
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue