Skip to content

Commit 8e3a292

Browse files
committed
Run and updated test in all platforms:
- macOS 15.5 - iPhone 16 - OS 18.5 - Apple Watch Series 10 (46mm) - watchOS 11.5 - visionOS 2.5 - Apple TV 4K (3rd generation) - tvOS 18.5 - iPad Pro 13-inc (M4) - iPadOS 18.5
1 parent b557bf5 commit 8e3a292

File tree

693 files changed

+496
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

693 files changed

+496
-55
lines changed

‎Sources/XCTSnapshot/Methods/UI/Core/SnapshotUIController.swift‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,11 @@ class SnapshotUIController: SDKViewController {
397397
for: traits()
398398
)
399399

400+
#if os(visionOS)
401+
format.scale = traits.displayScale
402+
#else
400403
format.scale = view.window?.screen.scale ?? traits.displayScale
404+
#endif
401405

402406
let renderer = UIGraphicsImageRenderer(
403407
bounds: bounds,

‎Sources/XCTSnapshot/Serialization/Defaults/ImageBytes.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ extension SyncSnapshot where Input: UIImage, Output == ImageBytes {
185185
.image()
186186
}
187187

188-
#if os(iOS) || os(tvOS)
188+
#if os(iOS) || os(tvOS) || os(visionOS)
189189
/// Creates a custom image snapshot configuration with precision and scale settings.
190190
///
191191
/// - Parameters:
@@ -207,7 +207,7 @@ extension SyncSnapshot where Input: UIImage, Output == ImageBytes {
207207
perceptualPrecision: perceptualPrecision
208208
).pullback { ImageBytes(rawValue: $0) }
209209
}
210-
#else
210+
#elseif os(watchOS)
211211
public static func image(
212212
precision: Float = 1
213213
) -> SyncSnapshot<Input, Output> {

‎Tests/Deprecated/SnapshotTestingTests/SnapshotTestingTests.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import SwiftUI
1717
#if canImport(WebKit)
1818
@preconcurrency import WebKit
1919
#endif
20-
#if canImport(UIKit)
20+
#if canImport(UIKit) && !os(watchOS)
2121
import UIKit.UIView
2222
#endif
2323

-578 Bytes
-1.07 KB

‎Tests/SnapshotTestingTests/UITests.swift‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,22 @@ struct UITests {
130130
$0.disableInconsistentTraitsChecker = true
131131
} operation: {
132132
let view = SDKView()
133-
#if !os(tvOS)
133+
#if os(visionOS)
134+
view.backgroundColor = .init(dynamicProvider: {
135+
if $0.userInterfaceStyle == .light {
136+
return .red
137+
} else {
138+
return .blue
139+
}
140+
})
141+
#elseif !os(tvOS)
134142
view.backgroundColor = .systemBackground
135143
#else
136144
view.backgroundColor = .systemGray
137145
#endif
138146

139147
let testCases = [
140-
(.light, "lightMode"),
148+
(UIUserInterfaceStyle.light, "lightMode"),
141149
(.dark, "darkMode"),
142150
]
143151

@@ -158,18 +166,22 @@ struct UITests {
158166
label.font = UIFont.preferredFont(forTextStyle: .body)
159167
label.adjustsFontForContentSizeCategory = true
160168

161-
let categories: [UITraitCollection.ContentSizeCategory] = [
169+
let categories: [UIContentSizeCategory] = [
162170
.extraSmall,
163171
.large,
164172
.accessibilityExtraExtraExtraLarge,
165173
]
166174

167-
for category in categories {
168-
try await assert(
169-
of: label,
170-
as: .image(traits: .init(preferredContentSizeCategory: category)),
171-
named: category.rawValue
172-
)
175+
try await withTestingEnvironment {
176+
$0.disableInconsistentTraitsChecker = true
177+
} operation: {
178+
for category in categories {
179+
try await assert(
180+
of: label,
181+
as: .image(traits: .init(preferredContentSizeCategory: category)),
182+
named: category.rawValue
183+
)
184+
}
173185
}
174186
}
175187

5.67 KB
4.55 KB
7.82 KB

0 commit comments

Comments
 (0)