wip
This commit is contained in:
parent
07496b849d
commit
bc6d83d716
|
@ -0,0 +1,24 @@
|
|||
#if os(macOS)
|
||||
import SwiftUI
|
||||
|
||||
// MARK: SwiftUI.DatePicker { ... }.datePickerStyle(.field)
|
||||
|
||||
public struct DatePickerWithFieldStyleType: IntrospectableViewType {
|
||||
public enum Style {
|
||||
case field
|
||||
}
|
||||
}
|
||||
|
||||
extension IntrospectableViewType where Self == DatePickerWithFieldStyleType {
|
||||
public static func datePicker(style: Self.Style) -> Self { .init() }
|
||||
}
|
||||
|
||||
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
|
||||
extension macOSViewVersion<DatePickerWithFieldStyleType, NSDatePicker> {
|
||||
public static let v10_15 = Self(for: .v10_15)
|
||||
public static let v11 = Self(for: .v11)
|
||||
public static let v12 = Self(for: .v12)
|
||||
public static let v13 = Self(for: .v13)
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -26,6 +26,7 @@
|
|||
D57506942A27EED200A628E4 /* DatePickerWithStepperFieldStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506932A27EED200A628E4 /* DatePickerWithStepperFieldStyleTests.swift */; };
|
||||
D57506962A27F0E200A628E4 /* DatePickerWithCompactFieldStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506952A27F0E200A628E4 /* DatePickerWithCompactFieldStyleTests.swift */; };
|
||||
D57506982A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506972A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift */; };
|
||||
D575069A2A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506992A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift */; };
|
||||
D58119C42A211B8A0081F853 /* ListCellTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58119C32A211B8A0081F853 /* ListCellTests.swift */; };
|
||||
D58119C62A227E930081F853 /* ViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58119C52A227E930081F853 /* ViewTests.swift */; };
|
||||
D58119C82A22AC130081F853 /* ToggleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58119C72A22AC130081F853 /* ToggleTests.swift */; };
|
||||
|
@ -81,6 +82,7 @@
|
|||
D57506932A27EED200A628E4 /* DatePickerWithStepperFieldStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerWithStepperFieldStyleTests.swift; sourceTree = "<group>"; };
|
||||
D57506952A27F0E200A628E4 /* DatePickerWithCompactFieldStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerWithCompactFieldStyleTests.swift; sourceTree = "<group>"; };
|
||||
D57506972A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerWithGraphicalStyleTests.swift; sourceTree = "<group>"; };
|
||||
D57506992A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerWithFieldStyleTests.swift; sourceTree = "<group>"; };
|
||||
D58119C32A211B8A0081F853 /* ListCellTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListCellTests.swift; sourceTree = "<group>"; };
|
||||
D58119C52A227E930081F853 /* ViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewTests.swift; sourceTree = "<group>"; };
|
||||
D58119C72A22AC130081F853 /* ToggleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleTests.swift; sourceTree = "<group>"; };
|
||||
|
@ -133,6 +135,7 @@
|
|||
D58119D92A23B7700081F853 /* ColorPickerTests.swift */,
|
||||
D58119D32A23AC100081F853 /* DatePickerTests.swift */,
|
||||
D57506952A27F0E200A628E4 /* DatePickerWithCompactFieldStyleTests.swift */,
|
||||
D57506992A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift */,
|
||||
D57506972A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift */,
|
||||
D57506932A27EED200A628E4 /* DatePickerWithStepperFieldStyleTests.swift */,
|
||||
D57506912A27EE4700A628E4 /* DatePickerWithWheelStyleTests.swift */,
|
||||
|
@ -357,6 +360,7 @@
|
|||
D58CE15829C621DD0081BFB0 /* TestUtils.swift in Sources */,
|
||||
D57506782A27BBBD00A628E4 /* PickerWithSegmentedStyleTests.swift in Sources */,
|
||||
D58119CE2A23A4A70081F853 /* TabViewWithPageStyleTests.swift in Sources */,
|
||||
D575069A2A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift in Sources */,
|
||||
D58119D42A23AC100081F853 /* DatePickerTests.swift in Sources */,
|
||||
D575068C2A27D40500A628E4 /* ToggleWithSwitchStyleTests.swift in Sources */,
|
||||
D58119C42A211B8A0081F853 /* ListCellTests.swift in Sources */,
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#if os(macOS)
|
||||
import SwiftUI
|
||||
import SwiftUIIntrospect
|
||||
import XCTest
|
||||
|
||||
final class DatePickerWithFieldStyleTests: XCTestCase {
|
||||
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
|
||||
typealias PlatformDatePickerWithFieldStyle = NSDatePicker
|
||||
#endif
|
||||
|
||||
func testDatePickerWithFieldStyle() {
|
||||
let date0 = Date(timeIntervalSince1970: 0)
|
||||
let date1 = Date(timeIntervalSince1970: 5)
|
||||
let date2 = Date(timeIntervalSince1970: 10)
|
||||
|
||||
XCTAssertViewIntrospection(of: PlatformDatePickerWithFieldStyle.self) { spies in
|
||||
let spy0 = spies[0]
|
||||
let spy1 = spies[1]
|
||||
let spy2 = spies[2]
|
||||
|
||||
VStack {
|
||||
DatePicker("", selection: .constant(date0))
|
||||
.datePickerStyle(.field)
|
||||
#if os(macOS)
|
||||
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13), customize: spy0)
|
||||
#endif
|
||||
.cornerRadius(8)
|
||||
|
||||
DatePicker("", selection: .constant(date1))
|
||||
.datePickerStyle(.field)
|
||||
#if os(macOS)
|
||||
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13), customize: spy1)
|
||||
#endif
|
||||
.cornerRadius(8)
|
||||
|
||||
DatePicker("", selection: .constant(date2))
|
||||
.datePickerStyle(.field)
|
||||
#if os(macOS)
|
||||
.introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13), customize: spy2)
|
||||
#endif
|
||||
}
|
||||
} extraAssertions: {
|
||||
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
|
||||
XCTAssertEqual($0[safe: 0]?.dateValue, date0)
|
||||
XCTAssertEqual($0[safe: 1]?.dateValue, date1)
|
||||
XCTAssertEqual($0[safe: 2]?.dateValue, date2)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue