diff --git a/Sources/SnapshotTesting/Common/View.swift b/Sources/SnapshotTesting/Common/View.swift index fb6261c94..7572ec810 100644 --- a/Sources/SnapshotTesting/Common/View.swift +++ b/Sources/SnapshotTesting/Common/View.swift @@ -241,6 +241,74 @@ public struct ViewImageConfig { return .init(safeArea: safeArea, size: size, traits: .iPhone13ProMax(orientation)) } + public static let iPhone14 = ViewImageConfig.iPhone14(.portrait) + + public static func iPhone14(_ orientation: Orientation) -> ViewImageConfig { + let safeArea: UIEdgeInsets + let size: CGSize + switch orientation { + case .landscape: + safeArea = .init(top: 0, left: 47, bottom: 21, right: 47) + size = .init(width: 844, height: 390) + case .portrait: + safeArea = .init(top: 47, left: 0, bottom: 34, right: 0) + size = .init(width: 390, height: 844) + } + + return .init(safeArea: safeArea, size: size, traits: UITraitCollection.iPhone14(orientation)) + } + + public static let iPhone14Plus = ViewImageConfig.iPhone14Plus(.portrait) + + public static func iPhone14Plus(_ orientation: Orientation) -> ViewImageConfig { + let safeArea: UIEdgeInsets + let size: CGSize + switch orientation { + case .landscape: + safeArea = .init(top: 0, left: 47, bottom: 21, right: 47) + size = .init(width: 926, height: 428) + case .portrait: + safeArea = .init(top: 47, left: 0, bottom: 34, right: 0) + size = .init(width: 428, height: 926) + } + + return .init(safeArea: safeArea, size: size, traits: .iPhone14Plus(orientation)) + } + + public static let iPhone14Pro = ViewImageConfig.iPhone14Pro(.portrait) + + public static func iPhone14Pro(_ orientation: Orientation) -> ViewImageConfig { + let safeArea: UIEdgeInsets + let size: CGSize + switch orientation { + case .landscape: + safeArea = .init(top: 0, left: 59, bottom: 21, right: 59) + size = .init(width: 852, height: 393) + case .portrait: + safeArea = .init(top: 59, left: 0, bottom: 34, right: 0) + size = .init(width: 393, height: 852) + } + + return .init(safeArea: safeArea, size: size, traits: .iPhone14Pro(orientation)) + } + + public static let iPhone14ProMax = ViewImageConfig.iPhone14ProMax(.portrait) + + public static func iPhone14ProMax(_ orientation: Orientation) -> ViewImageConfig { + let safeArea: UIEdgeInsets + let size: CGSize + switch orientation { + case .landscape: + safeArea = .init(top: 0, left: 59, bottom: 21, right: 59) + size = .init(width: 932, height: 430) + case .portrait: + safeArea = .init(top: 59, left: 0, bottom: 34, right: 0) + size = .init(width: 430, height: 932) + } + + return .init(safeArea: safeArea, size: size, traits: .iPhone14ProMax(orientation)) + } + public static let iPadMini = ViewImageConfig.iPadMini(.landscape) public static func iPadMini(_ orientation: Orientation) -> ViewImageConfig { diff --git a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift index 570f24240..2e10ab5a4 100644 --- a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift +++ b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift @@ -472,6 +472,10 @@ final class SnapshotTestingTests: XCTestCase { assertSnapshot(matching: viewController, as: .image(on: .iPhoneX), named: "iphone-x") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr), named: "iphone-xr") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax), named: "iphone-xs-max") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14), named: "iphone-14") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Plus), named: "iphone-14-plus") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Pro), named: "iphone-14-pro") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14ProMax), named: "iphone-14-pro-max") assertSnapshot(matching: viewController, as: .image(on: .iPadMini), named: "ipad-mini") assertSnapshot(matching: viewController, as: .image(on: .iPad9_7), named: "ipad-9-7") assertSnapshot(matching: viewController, as: .image(on: .iPad10_2), named: "ipad-10-2") @@ -485,6 +489,10 @@ final class SnapshotTestingTests: XCTestCase { assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhoneX), named: "iphone-x") assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhoneXr), named: "iphone-xr") assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhoneXsMax), named: "iphone-xs-max") + assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhone14), named: "iphone-14") + assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhone14Plus), named: "iphone-14-plus") + assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhone14Pro), named: "iphone-14-pro") + assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhone14ProMax), named: "iphone-14-pro-max") assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadMini), named: "ipad-mini") assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPad9_7), named: "ipad-9-7") assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPad10_2), named: "ipad-10-2") @@ -498,6 +506,10 @@ final class SnapshotTestingTests: XCTestCase { assertSnapshot(matching: viewController, as: .image(on: .iPhoneX(.portrait)), named: "iphone-x") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr(.portrait)), named: "iphone-xr") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax(.portrait)), named: "iphone-xs-max") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14(.portrait)), named: "iphone-14") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Plus(.portrait)), named: "iphone-14-plus") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Pro(.portrait)), named: "iphone-14-pro") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14ProMax(.portrait)), named: "iphone-14-pro-max") assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape)), named: "ipad-mini") assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape)), named: "ipad-9-7") assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape)), named: "ipad-10-2") @@ -553,6 +565,14 @@ final class SnapshotTestingTests: XCTestCase { matching: viewController, as: .image(on: .iPhoneXr(.landscape)), named: "iphone-xr-alternative") assertSnapshot( matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14(.landscpae)), named: "iphone-14-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14Plus(.landscpae)), named: "iphone-14-plus-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14Pro(.landscpae)), named: "iphone-14-pro-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14ProMax(.landscpae)), named: "iphone-14-pro-max-alternative") assertSnapshot( matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative") assertSnapshot( @@ -664,6 +684,10 @@ final class SnapshotTestingTests: XCTestCase { assertSnapshot(matching: viewController, as: .image(on: .iPhoneX(.portrait)), named: "iphone-x") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr(.portrait)), named: "iphone-xr") assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax(.portrait)), named: "iphone-xs-max") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14(.portrait)), named: "iphone-14") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Plus(.portrait)), named: "iphone-14-plus") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14Pro(.portrait)), named: "iphone-14-pro") + assertSnapshot(matching: viewController, as: .image(on: .iPhone14ProMax(.portrait)), named: "iphone-14-pro-max") assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape)), named: "ipad-mini") assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape)), named: "ipad-9-7") assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape)), named: "ipad-10-2") @@ -683,6 +707,14 @@ final class SnapshotTestingTests: XCTestCase { matching: viewController, as: .image(on: .iPhoneXr(.landscape)), named: "iphone-xr-alternative") assertSnapshot( matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14(.landscape)), named: "iphone-14-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14Plus(.landscape)), named: "iphone-14-plus-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14Pro(.landscape)), named: "iphone-14-pro-alternative") + assertSnapshot( + matching: viewController, as: .image(on: .iPhone14ProMax(.landscape)), named: "iphone-14-pro-max-alternative") assertSnapshot( matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative") assertSnapshot(