Skip to content

Commit b4b93b5

Browse files
Add iPhone 15 devices (#376)
* Add iPhone 15 Devices * Fix lint violations * Improve implementation Co-authored-by: Christopher Fuller <[email protected]> --------- Co-authored-by: Christopher Fuller <[email protected]>
1 parent b0ad58e commit b4b93b5

File tree

492 files changed

+1057
-20
lines changed

Some content is hidden

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

492 files changed

+1057
-20
lines changed

Sources/SnapshotTestingExtensions/UITraitCollection.swift

+84
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,88 @@ extension UITraitCollection {
9595
])
9696
}
9797
}
98+
99+
internal static func iPhone15(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
100+
let base: [UITraitCollection] = [
101+
UITraitCollection(forceTouchCapability: .unavailable),
102+
UITraitCollection(layoutDirection: .leftToRight),
103+
UITraitCollection(preferredContentSizeCategory: .medium),
104+
UITraitCollection(userInterfaceIdiom: .phone)
105+
]
106+
return switch orientation {
107+
case .landscape:
108+
UITraitCollection(traitsFrom: base + [
109+
UITraitCollection(horizontalSizeClass: .regular),
110+
UITraitCollection(verticalSizeClass: .compact)
111+
])
112+
case .portrait:
113+
UITraitCollection(traitsFrom: base + [
114+
UITraitCollection(horizontalSizeClass: .compact),
115+
UITraitCollection(verticalSizeClass: .regular)
116+
])
117+
}
118+
}
119+
120+
internal static func iPhone15Plus(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
121+
let base: [UITraitCollection] = [
122+
UITraitCollection(forceTouchCapability: .unavailable),
123+
UITraitCollection(layoutDirection: .leftToRight),
124+
UITraitCollection(preferredContentSizeCategory: .medium),
125+
UITraitCollection(userInterfaceIdiom: .phone)
126+
]
127+
return switch orientation {
128+
case .landscape:
129+
UITraitCollection(traitsFrom: base + [
130+
UITraitCollection(horizontalSizeClass: .regular),
131+
UITraitCollection(verticalSizeClass: .compact)
132+
])
133+
case .portrait:
134+
UITraitCollection(traitsFrom: base + [
135+
UITraitCollection(horizontalSizeClass: .compact),
136+
UITraitCollection(verticalSizeClass: .regular)
137+
])
138+
}
139+
}
140+
141+
internal static func iPhone15Pro(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
142+
let base: [UITraitCollection] = [
143+
UITraitCollection(forceTouchCapability: .unavailable),
144+
UITraitCollection(layoutDirection: .leftToRight),
145+
UITraitCollection(preferredContentSizeCategory: .medium),
146+
UITraitCollection(userInterfaceIdiom: .phone)
147+
]
148+
return switch orientation {
149+
case .landscape:
150+
UITraitCollection(traitsFrom: base + [
151+
UITraitCollection(horizontalSizeClass: .regular),
152+
UITraitCollection(verticalSizeClass: .compact)
153+
])
154+
case .portrait:
155+
UITraitCollection(traitsFrom: base + [
156+
UITraitCollection(horizontalSizeClass: .compact),
157+
UITraitCollection(verticalSizeClass: .regular)
158+
])
159+
}
160+
}
161+
162+
internal static func iPhone15ProMax(_ orientation: ViewImageConfig.Orientation) -> UITraitCollection {
163+
let base: [UITraitCollection] = [
164+
UITraitCollection(forceTouchCapability: .unavailable),
165+
UITraitCollection(layoutDirection: .leftToRight),
166+
UITraitCollection(preferredContentSizeCategory: .medium),
167+
UITraitCollection(userInterfaceIdiom: .phone)
168+
]
169+
return switch orientation {
170+
case .landscape:
171+
UITraitCollection(traitsFrom: base + [
172+
UITraitCollection(horizontalSizeClass: .regular),
173+
UITraitCollection(verticalSizeClass: .compact)
174+
])
175+
case .portrait:
176+
UITraitCollection(traitsFrom: base + [
177+
UITraitCollection(horizontalSizeClass: .compact),
178+
UITraitCollection(verticalSizeClass: .regular)
179+
])
180+
}
181+
}
98182
}

Sources/SnapshotTestingExtensions/ViewImageConfig.swift

+56
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,60 @@ extension ViewImageConfig {
6767
}
6868
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone14ProMax(orientation))
6969
}
70+
71+
public static func iPhone15(_ orientation: Orientation) -> ViewImageConfig {
72+
let safeArea: UIEdgeInsets
73+
let size: CGSize
74+
switch orientation {
75+
case .landscape:
76+
safeArea = UIEdgeInsets(top: 0, left: 59, bottom: 21, right: 59)
77+
size = CGSize(width: 852, height: 393)
78+
case .portrait:
79+
safeArea = UIEdgeInsets(top: 59, left: 0, bottom: 34, right: 0)
80+
size = CGSize(width: 393, height: 852)
81+
}
82+
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone15(orientation))
83+
}
84+
85+
public static func iPhone15Plus(_ orientation: Orientation) -> ViewImageConfig {
86+
let safeArea: UIEdgeInsets
87+
let size: CGSize
88+
switch orientation {
89+
case .landscape:
90+
safeArea = UIEdgeInsets(top: 0, left: 59, bottom: 21, right: 59)
91+
size = CGSize(width: 932, height: 430)
92+
case .portrait:
93+
safeArea = UIEdgeInsets(top: 59, left: 0, bottom: 34, right: 0)
94+
size = CGSize(width: 430, height: 932)
95+
}
96+
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone15Plus(orientation))
97+
}
98+
99+
public static func iPhone15Pro(_ orientation: Orientation) -> ViewImageConfig {
100+
let safeArea: UIEdgeInsets
101+
let size: CGSize
102+
switch orientation {
103+
case .landscape:
104+
safeArea = UIEdgeInsets(top: 0, left: 59, bottom: 21, right: 59)
105+
size = CGSize(width: 852, height: 393)
106+
case .portrait:
107+
safeArea = UIEdgeInsets(top: 59, left: 0, bottom: 34, right: 0)
108+
size = CGSize(width: 393, height: 852)
109+
}
110+
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone15Pro(orientation))
111+
}
112+
113+
public static func iPhone15ProMax(_ orientation: Orientation) -> ViewImageConfig {
114+
let safeArea: UIEdgeInsets
115+
let size: CGSize
116+
switch orientation {
117+
case .landscape:
118+
safeArea = UIEdgeInsets(top: 0, left: 59, bottom: 21, right: 59)
119+
size = CGSize(width: 932, height: 430)
120+
case .portrait:
121+
safeArea = UIEdgeInsets(top: 59, left: 0, bottom: 34, right: 0)
122+
size = CGSize(width: 430, height: 932)
123+
}
124+
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone15ProMax(orientation))
125+
}
70126
}

Tests/LayoutTests/Support/Device.swift

+44-11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ internal enum Device: CustomStringConvertible {
1818
case iPhone14Plus(Orientation)
1919
case iPhone14Pro(Orientation)
2020
case iPhone14ProMax(Orientation)
21+
case iPhone15(Orientation)
22+
case iPhone15Plus(Orientation)
23+
case iPhone15Pro(Orientation)
24+
case iPhone15ProMax(Orientation)
2125

2226
internal enum Orientation {
2327

@@ -61,6 +65,19 @@ internal enum Device: CustomStringConvertible {
6165
[.iPhone14ProMax(.portrait), .iPhone14ProMax(.landscape)]
6266
}
6367

68+
internal static var iPhone15: [Self] {
69+
[.iPhone15(.portrait), .iPhone15(.landscape)]
70+
}
71+
internal static var iPhone15Plus: [Self] {
72+
[.iPhone15Plus(.portrait), .iPhone15Plus(.landscape)]
73+
}
74+
internal static var iPhone15Pro: [Self] {
75+
[.iPhone15Pro(.portrait), .iPhone15Pro(.landscape)]
76+
}
77+
internal static var iPhone15ProMax: [Self] {
78+
[.iPhone15ProMax(.portrait), .iPhone15ProMax(.landscape)]
79+
}
80+
6481
internal static var allTestDevices: [Self] {
6582
portraitTestDevices + landscapeTestDevices
6683
}
@@ -75,7 +92,11 @@ internal enum Device: CustomStringConvertible {
7592
.iPhone14(.portrait),
7693
.iPhone14Plus(.portrait),
7794
.iPhone14Pro(.portrait),
78-
.iPhone14ProMax(.portrait)
95+
.iPhone14ProMax(.portrait),
96+
.iPhone15(.portrait),
97+
.iPhone15Plus(.portrait),
98+
.iPhone15Pro(.portrait),
99+
.iPhone15ProMax(.portrait)
79100
]
80101
}
81102

@@ -89,7 +110,11 @@ internal enum Device: CustomStringConvertible {
89110
.iPhone14(.landscape),
90111
.iPhone14Plus(.landscape),
91112
.iPhone14Pro(.landscape),
92-
.iPhone14ProMax(.landscape)
113+
.iPhone14ProMax(.landscape),
114+
.iPhone15(.landscape),
115+
.iPhone15Plus(.landscape),
116+
.iPhone15Pro(.landscape),
117+
.iPhone15ProMax(.landscape)
93118
]
94119
}
95120

@@ -114,23 +139,31 @@ internal enum Device: CustomStringConvertible {
114139
internal var name: String {
115140
switch self {
116141
case let .iPhone8(orientation):
117-
return "iPhone 8 - \(orientation)"
142+
"iPhone 8 - \(orientation)"
118143
case let .iPhoneSE(orientation):
119-
return "iPhone SE - \(orientation)"
144+
"iPhone SE - \(orientation)"
120145
case let .iPhoneX(orientation):
121-
return "iPhone X - \(orientation)"
146+
"iPhone X - \(orientation)"
122147
case let .iPhone13(orientation):
123-
return "iPhone 13 - \(orientation)"
148+
"iPhone 13 - \(orientation)"
124149
case let .iPhone13mini(orientation):
125-
return "iPhone 13 mini - \(orientation)"
150+
"iPhone 13 mini - \(orientation)"
126151
case let .iPhone14(orientation):
127-
return "iPhone 14 - \(orientation)"
152+
"iPhone 14 - \(orientation)"
128153
case let .iPhone14Plus(orientation):
129-
return "iPhone 14 Plus - \(orientation)"
154+
"iPhone 14 Plus - \(orientation)"
130155
case let .iPhone14Pro(orientation):
131-
return "iPhone 14 Pro - \(orientation)"
156+
"iPhone 14 Pro - \(orientation)"
132157
case let .iPhone14ProMax(orientation):
133-
return "iPhone 14 Pro Max - \(orientation)"
158+
"iPhone 14 Pro Max - \(orientation)"
159+
case let .iPhone15(orientation):
160+
"iPhone 15 - \(orientation)"
161+
case let .iPhone15Plus(orientation):
162+
"iPhone 15 Plus - \(orientation)"
163+
case let .iPhone15Pro(orientation):
164+
"iPhone 15 Pro - \(orientation)"
165+
case let .iPhone15ProMax(orientation):
166+
"iPhone 15 Pro Max - \(orientation)"
134167
}
135168
}
136169
}

Tests/LayoutTests/Support/SnapshotTesting.swift

+17-9
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,31 @@ extension Device {
6464
internal var config: ViewImageConfig {
6565
switch self {
6666
case let .iPhone8(orientation):
67-
return .iPhone8(orientation.configOrientation)
67+
.iPhone8(orientation.configOrientation)
6868
case let .iPhoneSE(orientation):
69-
return .iPhoneSe(orientation.configOrientation)
69+
.iPhoneSe(orientation.configOrientation)
7070
case let .iPhoneX(orientation):
71-
return .iPhoneX(orientation.configOrientation)
71+
.iPhoneX(orientation.configOrientation)
7272
case let .iPhone13(orientation):
73-
return .iPhone13(orientation.configOrientation)
73+
.iPhone13(orientation.configOrientation)
7474
case let .iPhone13mini(orientation):
75-
return .iPhone13Mini(orientation.configOrientation)
75+
.iPhone13Mini(orientation.configOrientation)
7676
case let .iPhone14(orientation):
77-
return .iPhone14(orientation.configOrientation)
77+
.iPhone14(orientation.configOrientation)
7878
case let .iPhone14Plus(orientation):
79-
return .iPhone14Plus(orientation.configOrientation)
79+
.iPhone14Plus(orientation.configOrientation)
8080
case let .iPhone14Pro(orientation):
81-
return .iPhone14Pro(orientation.configOrientation)
81+
.iPhone14Pro(orientation.configOrientation)
8282
case let .iPhone14ProMax(orientation):
83-
return .iPhone14ProMax(orientation.configOrientation)
83+
.iPhone14ProMax(orientation.configOrientation)
84+
case let .iPhone15(orientation):
85+
.iPhone15(orientation.configOrientation)
86+
case let .iPhone15Plus(orientation):
87+
.iPhone15Plus(orientation.configOrientation)
88+
case let .iPhone15Pro(orientation):
89+
.iPhone15Pro(orientation.configOrientation)
90+
case let .iPhone15ProMax(orientation):
91+
.iPhone15ProMax(orientation.configOrientation)
8492
}
8593
}
8694
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 10, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 10, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 10, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 10, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 370, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 370, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 333, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 333, y: 20, width: 50, height: 100)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 165, y: 416, width: 100, height: 100)>
3+
| <UILabel; frame = (322 456; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 165, y: 416, width: 100, height: 100)>
3+
| <UILabel; frame = (322 456; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 146.666667, y: 376, width: 100, height: 100)>
3+
| <UILabel; frame = (294 416; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 146.666667, y: 376, width: 100, height: 100)>
3+
| <UILabel; frame = (294 416; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 165, y: 416, width: 100, height: 100)>
3+
| <UILabel; frame = (322 456; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 165, y: 416, width: 100, height: 100)>
3+
| <UILabel; frame = (322 456; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 146.666667, y: 376, width: 100, height: 100)>
3+
| <UILabel; frame = (294 416; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 146.666667, y: 376, width: 100, height: 100)>
3+
| <UILabel; frame = (294 416; 51.3333 20.3333); text = 'Layout'; userInteractionEnabled = NO; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <_UILabelLayer>>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 0, y: 59, width: 430, height: 839)>
3+
| <View; name = Blue; frame = (x: 199, y: 450, width: 32, height: 32)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 0, y: 59, width: 430, height: 839)>
3+
| <View; name = Blue; frame = (x: 199, y: 450, width: 32, height: 32)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 0, y: 59, width: 393, height: 759)>
3+
| <View; name = Blue; frame = (x: 180.666667, y: 410, width: 32, height: 32)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 0, y: 59, width: 393, height: 759)>
3+
| <View; name = Blue; frame = (x: 180.666667, y: 410, width: 32, height: 32)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 0, y: 0, width: 430, height: 932)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 430, height: 932)>
2+
| <View; name = Pink; frame = (x: 0, y: 0, width: 430, height: 932)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 0, y: 0, width: 393, height: 852)>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<View; frame = (x: 0, y: 0, width: 393, height: 852)>
2+
| <View; name = Pink; frame = (x: 0, y: 0, width: 393, height: 852)>

0 commit comments

Comments
 (0)