wip
This commit is contained in:
parent
4b042303aa
commit
ddc22dc33b
|
@ -0,0 +1,39 @@
|
|||
import SwiftUI
|
||||
|
||||
// MARK: SwiftUI.ProgressView().progressViewStyle(.linear)
|
||||
|
||||
public struct ProgressViewWithLinearStyleType: IntrospectableViewType {
|
||||
public enum Style {
|
||||
case linear
|
||||
}
|
||||
}
|
||||
|
||||
extension IntrospectableViewType where Self == ProgressViewWithLinearStyleType {
|
||||
public static func progressView(style: Self.Style) -> Self { .init() }
|
||||
}
|
||||
|
||||
#if canImport(UIKit)
|
||||
extension iOSViewVersion<ProgressViewWithLinearStyleType, UIProgressView> {
|
||||
@available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on iOS 13")
|
||||
public static let v13 = Self(for: .v13)
|
||||
public static let v14 = Self(for: .v14)
|
||||
public static let v15 = Self(for: .v15)
|
||||
public static let v16 = Self(for: .v16)
|
||||
}
|
||||
|
||||
extension tvOSViewVersion<ProgressViewWithLinearStyleType, UIProgressView> {
|
||||
@available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on tvOS 13")
|
||||
public static let v13 = Self(for: .v13)
|
||||
public static let v14 = Self(for: .v14)
|
||||
public static let v15 = Self(for: .v15)
|
||||
public static let v16 = Self(for: .v16)
|
||||
}
|
||||
#elseif canImport(AppKit)
|
||||
extension macOSViewVersion<ProgressViewWithLinearStyleType, NSProgressIndicator> {
|
||||
@available(*, unavailable, message: ".progressViewStyle(.linear) isn't available on macOS 10.15")
|
||||
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
|
|
@ -28,6 +28,7 @@
|
|||
D57506982A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506972A27F32800A628E4 /* DatePickerWithGraphicalStyleTests.swift */; };
|
||||
D575069A2A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D57506992A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift */; };
|
||||
D575069C2A27F68700A628E4 /* ProgressViewWithCircularStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D575069B2A27F68700A628E4 /* ProgressViewWithCircularStyleTests.swift */; };
|
||||
D575069E2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D575069D2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.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 */; };
|
||||
|
@ -85,6 +86,7 @@
|
|||
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>"; };
|
||||
D575069B2A27F68700A628E4 /* ProgressViewWithCircularStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressViewWithCircularStyleTests.swift; sourceTree = "<group>"; };
|
||||
D575069D2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProgressViewWithLinearStyleTests.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>"; };
|
||||
|
@ -159,6 +161,7 @@
|
|||
D57506772A27BBBD00A628E4 /* PickerWithSegmentedStyleTests.swift */,
|
||||
D58119D52A23AED70081F853 /* PickerWithWheelStyleTests.swift */,
|
||||
D575069B2A27F68700A628E4 /* ProgressViewWithCircularStyleTests.swift */,
|
||||
D575069D2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.swift */,
|
||||
D50FFE8D2A17E2A400C32641 /* ScrollViewTests.swift */,
|
||||
D58119CF2A23A62C0081F853 /* SliderTests.swift */,
|
||||
D58119D12A23A77C0081F853 /* StepperTests.swift */,
|
||||
|
@ -345,6 +348,7 @@
|
|||
D575067C2A27C24600A628E4 /* ListWithPlainStyleTests.swift in Sources */,
|
||||
D58119CA2A239BAC0081F853 /* TextEditorTests.swift in Sources */,
|
||||
D57506842A27C8D400A628E4 /* ListWithSidebarStyleTests.swift in Sources */,
|
||||
D575069E2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.swift in Sources */,
|
||||
D57506862A27CA4100A628E4 /* ListWithBorderedStyleTests.swift in Sources */,
|
||||
D5F8D5ED2A1E7B490054E9AB /* NavigationViewWithStackStyleTests.swift in Sources */,
|
||||
D57506942A27EED200A628E4 /* DatePickerWithStepperFieldStyleTests.swift in Sources */,
|
||||
|
|
|
@ -20,7 +20,7 @@ final class ProgressViewWithCircularStyleTests: XCTestCase {
|
|||
let spy2 = spies[2]
|
||||
|
||||
VStack {
|
||||
ProgressView()
|
||||
ProgressView(value: 0.25)
|
||||
.progressViewStyle(.circular)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy0)
|
||||
|
@ -28,7 +28,7 @@ final class ProgressViewWithCircularStyleTests: XCTestCase {
|
|||
.introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13), customize: spy0)
|
||||
#endif
|
||||
|
||||
ProgressView()
|
||||
ProgressView(value: 0.5)
|
||||
.progressViewStyle(.circular)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy1)
|
||||
|
@ -36,7 +36,7 @@ final class ProgressViewWithCircularStyleTests: XCTestCase {
|
|||
.introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13), customize: spy1)
|
||||
#endif
|
||||
|
||||
ProgressView()
|
||||
ProgressView(value: 0.75)
|
||||
.progressViewStyle(.circular)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .circular), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy2)
|
||||
|
@ -44,6 +44,12 @@ final class ProgressViewWithCircularStyleTests: XCTestCase {
|
|||
.introspect(.progressView(style: .circular), on: .macOS(.v11, .v12, .v13), customize: spy2)
|
||||
#endif
|
||||
}
|
||||
} extraAssertions: {
|
||||
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
|
||||
XCTAssertEqual($0[safe: 0]?.doubleValue, 0.25)
|
||||
XCTAssertEqual($0[safe: 1]?.doubleValue, 0.5)
|
||||
XCTAssertEqual($0[safe: 2]?.doubleValue, 0.75)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
import SwiftUI
|
||||
import SwiftUIIntrospect
|
||||
import XCTest
|
||||
|
||||
final class ProgressViewWithLinearStyleTests: XCTestCase {
|
||||
#if canImport(UIKit)
|
||||
typealias PlatformProgressViewWithLinearStyle = UIProgressView
|
||||
#elseif canImport(AppKit)
|
||||
typealias PlatformProgressViewWithLinearStyle = NSProgressIndicator
|
||||
#endif
|
||||
|
||||
func testProgressViewWithLinearStyle() throws {
|
||||
guard #available(iOS 14, tvOS 14, macOS 11, *) else {
|
||||
throw XCTSkip()
|
||||
}
|
||||
|
||||
XCTAssertViewIntrospection(of: PlatformProgressViewWithLinearStyle.self) { spies in
|
||||
let spy0 = spies[0]
|
||||
let spy1 = spies[1]
|
||||
let spy2 = spies[2]
|
||||
|
||||
VStack {
|
||||
ProgressView(value: 0.25)
|
||||
.progressViewStyle(.linear)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy0)
|
||||
#elseif os(macOS)
|
||||
.introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13), customize: spy0)
|
||||
#endif
|
||||
|
||||
ProgressView(value: 0.5)
|
||||
.progressViewStyle(.linear)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy1)
|
||||
#elseif os(macOS)
|
||||
.introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13), customize: spy1)
|
||||
#endif
|
||||
|
||||
ProgressView(value: 0.75)
|
||||
.progressViewStyle(.linear)
|
||||
#if os(iOS) || os(tvOS)
|
||||
.introspect(.progressView(style: .linear), on: .iOS(.v14, .v15, .v16), .tvOS(.v14, .v15, .v16), customize: spy2)
|
||||
#elseif os(macOS)
|
||||
.introspect(.progressView(style: .linear), on: .macOS(.v11, .v12, .v13), customize: spy2)
|
||||
#endif
|
||||
}
|
||||
} extraAssertions: {
|
||||
#if canImport(UIKit)
|
||||
XCTAssertEqual($0[safe: 0]?.progress, 0.25)
|
||||
XCTAssertEqual($0[safe: 1]?.progress, 0.5)
|
||||
XCTAssertEqual($0[safe: 2]?.progress, 0.75)
|
||||
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
|
||||
XCTAssertEqual($0[safe: 0]?.doubleValue, 0.25)
|
||||
XCTAssertEqual($0[safe: 1]?.doubleValue, 0.5)
|
||||
XCTAssertEqual($0[safe: 2]?.doubleValue, 0.75)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue