Fix UI snapshots. (#3585)

* Remove old snapshots.

* Add a check for the correct simulator name.

* Record mismatched snapshots.

* Regenerate more snapshots using a (temporary) higher precision.

* Fix snapshot.
This commit is contained in:
Doug 2024-12-04 11:59:53 +00:00 committed by GitHub
parent 0085c20c64
commit ab2152096d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
145 changed files with 170 additions and 365 deletions

View File

@ -47,6 +47,9 @@ enum Application {
guard deviceModel == requirediPhoneSimulator || deviceModel == requirediPadSimulator else {
fatalError("Running on \(deviceModel) but we only support \(requirediPhoneSimulator) and \(requirediPadSimulator).")
}
guard UIDevice.current.snapshotName == "iPhone-18.1" || UIDevice.current.snapshotName == "iPad-18.1" else {
fatalError("Running on a simulator that hasn't been renamed to match the expected snapshot filenames.")
}
}
}
@ -91,15 +94,7 @@ extension XCUIApplication {
}
private var deviceName: String {
var name = UIDevice.current.name
// When running with parallel execution simulators are named "Clone 2 of iPhone 14" etc.
// Tidy this prefix out of the name to generate snapshots with the correct name.
if name.starts(with: "Clone "), let range = name.range(of: " of ") {
name = String(name[range.upperBound...])
}
return name
UIDevice.current.snapshotName
}
private var localeCode: String {
@ -118,6 +113,20 @@ extension XCUIApplication {
}
}
private extension UIDevice {
var snapshotName: String {
var name = name
// When running with parallel execution simulators are named "Clone 2 of iPhone 14" etc.
// Tidy this prefix out of the name to generate snapshots with the correct name.
if name.starts(with: "Clone "), let range = name.range(of: " of ") {
name = String(name[range.upperBound...])
}
return name
}
}
private extension UIImage {
/// Adjusts the image by cropping it with the given edge insets.
func inset(by insets: UIEdgeInsets) -> UIImage {

Some files were not shown because too many files have changed in this diff Show More