Skip to content

Commit cb7cfc5

Browse files
skols85stephencelis
authored andcommitted
Add support for iPad 9_7 and iPad 10_2 (pointfreeco#405)
* Add support for iPad 9_7 and iPad 10_2 * Add tests for iPad 9'7 and iPad 10'2 Co-authored-by: Stephen Celis <[email protected]>
1 parent 3a4476f commit cb7cfc5

22 files changed

+101
-0
lines changed

Sources/SnapshotTesting/Common/View.swift

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,63 @@ public struct ViewImageConfig {
192192
return .init(safeArea: .init(top: 20, left: 0, bottom: 0, right: 0), size: size, traits: traits)
193193
}
194194

195+
public static let iPad9_7 = iPadMini
196+
197+
public static func iPad9_7(_ orientation: Orientation) -> ViewImageConfig {
198+
return iPadMini(orientation)
199+
}
200+
201+
public static func iPad9_7(_ orientation: TabletOrientation) -> ViewImageConfig {
202+
return iPadMini(orientation)
203+
}
204+
205+
public static let iPad10_2 = ViewImageConfig.iPad10_2(.landscape)
206+
207+
public static func iPad10_2(_ orientation: Orientation) -> ViewImageConfig {
208+
switch orientation {
209+
case .landscape:
210+
return ViewImageConfig.iPad10_2(.landscape(splitView: .full))
211+
case .portrait:
212+
return ViewImageConfig.iPad10_2(.portrait(splitView: .full))
213+
}
214+
}
215+
216+
public static func iPad10_2(_ orientation: TabletOrientation) -> ViewImageConfig {
217+
let size: CGSize
218+
let traits: UITraitCollection
219+
switch orientation {
220+
case .landscape(let splitView):
221+
switch splitView {
222+
case .oneThird:
223+
size = .init(width: 320, height: 810)
224+
traits = .iPad10_2_Compact_SplitView
225+
case .oneHalf:
226+
size = .init(width: 535, height: 810)
227+
traits = .iPad10_2_Compact_SplitView
228+
case .twoThirds:
229+
size = .init(width: 750, height: 810)
230+
traits = .iPad10_2
231+
case .full:
232+
size = .init(width: 1080, height: 810)
233+
traits = .iPad10_2
234+
}
235+
case .portrait(let splitView):
236+
switch splitView {
237+
case .oneThird:
238+
size = .init(width: 320, height: 1080)
239+
traits = .iPad10_2_Compact_SplitView
240+
case .twoThirds:
241+
size = .init(width: 480, height: 1080)
242+
traits = .iPad10_2_Compact_SplitView
243+
case .full:
244+
size = .init(width: 810, height: 1080)
245+
traits = .iPad10_2
246+
}
247+
}
248+
return .init(safeArea: .init(top: 20, left: 0, bottom: 0, right: 0), size: size, traits: traits)
249+
}
250+
251+
195252
public static let iPadPro10_5 = ViewImageConfig.iPadPro10_5(.landscape)
196253

197254
public static func iPadPro10_5(_ orientation: Orientation) -> ViewImageConfig {
@@ -517,6 +574,10 @@ extension UITraitCollection {
517574

518575
public static let iPadMini = iPad
519576
public static let iPadMini_Compact_SplitView = iPadCompactSplitView
577+
public static let iPad9_7 = iPad
578+
public static let iPad9_7_Compact_SplitView = iPadCompactSplitView
579+
public static let iPad10_2 = iPad
580+
public static let iPad10_2_Compact_SplitView = iPadCompactSplitView
520581
public static let iPadPro10_5 = iPad
521582
public static let iPadPro10_5_Compact_SplitView = iPadCompactSplitView
522583
public static let iPadPro11 = iPad

Tests/SnapshotTestingTests/SnapshotTestingTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ final class SnapshotTestingTests: XCTestCase {
444444
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr), named: "iphone-xr")
445445
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax), named: "iphone-xs-max")
446446
assertSnapshot(matching: viewController, as: .image(on: .iPadMini), named: "ipad-mini")
447+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7), named: "ipad-9-7")
448+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2), named: "ipad-10-2")
447449
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5), named: "ipad-pro-10-5")
448450
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11), named: "ipad-pro-11")
449451
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9), named: "ipad-pro-12-9")
@@ -455,6 +457,8 @@ final class SnapshotTestingTests: XCTestCase {
455457
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhoneXr), named: "iphone-xr")
456458
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPhoneXsMax), named: "iphone-xs-max")
457459
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadMini), named: "ipad-mini")
460+
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPad9_7), named: "ipad-9-7")
461+
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPad10_2), named: "ipad-10-2")
458462
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro10_5), named: "ipad-pro-10-5")
459463
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro11), named: "ipad-pro-11")
460464
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro12_9), named: "ipad-pro-12-9")
@@ -466,6 +470,8 @@ final class SnapshotTestingTests: XCTestCase {
466470
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr(.portrait)), named: "iphone-xr")
467471
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax(.portrait)), named: "iphone-xs-max")
468472
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape)), named: "ipad-mini")
473+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape)), named: "ipad-9-7")
474+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape)), named: "ipad-10-2")
469475
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape)), named: "ipad-pro-10-5")
470476
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11(.landscape)), named: "ipad-pro-11")
471477
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9(.landscape)), named: "ipad-pro-12-9")
@@ -475,6 +481,18 @@ final class SnapshotTestingTests: XCTestCase {
475481
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape(splitView: .twoThirds))), named: "ipad-mini-66-split-landscape")
476482
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.portrait(splitView: .oneThird))), named: "ipad-mini-33-split-portrait")
477483
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.portrait(splitView: .twoThirds))), named: "ipad-mini-66-split-portrait")
484+
485+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .oneThird))), named: "ipad-9-7-33-split-landscape")
486+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .oneHalf))), named: "ipad-9-7-50-split-landscape")
487+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .twoThirds))), named: "ipad-9-7-66-split-landscape")
488+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.portrait(splitView: .oneThird))), named: "ipad-9-7-33-split-portrait")
489+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.portrait(splitView: .twoThirds))), named: "ipad-9-7-66-split-portrait")
490+
491+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .oneThird))), named: "ipad-10-2-split-landscape")
492+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .oneHalf))), named: "ipad-10-2-50-split-landscape")
493+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .twoThirds))), named: "ipad-10-2-66-split-landscape")
494+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.portrait(splitView: .oneThird))), named: "ipad-10-2-33-split-portrait")
495+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.portrait(splitView: .twoThirds))), named: "ipad-10-2-66-split-portrait")
478496

479497
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape(splitView: .oneThird))), named: "ipad-pro-10inch-33-split-landscape")
480498
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape(splitView: .oneHalf))), named: "ipad-pro-10inch-50-split-landscape")
@@ -508,6 +526,10 @@ final class SnapshotTestingTests: XCTestCase {
508526
matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative")
509527
assertSnapshot(
510528
matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative")
529+
assertSnapshot(
530+
matching: viewController, as: .image(on: .iPad9_7(.portrait)), named: "ipad-9-7-alternative")
531+
assertSnapshot(
532+
matching: viewController, as: .image(on: .iPad10_2(.portrait)), named: "ipad-10-2-alternative")
511533
assertSnapshot(
512534
matching: viewController, as: .image(on: .iPadPro10_5(.portrait)), named: "ipad-pro-10-5-alternative")
513535
assertSnapshot(
@@ -601,6 +623,8 @@ final class SnapshotTestingTests: XCTestCase {
601623
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr), named: "iphone-xr")
602624
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax), named: "iphone-xs-max")
603625
assertSnapshot(matching: viewController, as: .image(on: .iPadMini), named: "ipad-mini")
626+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7), named: "ipad-9-7")
627+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2), named: "ipad-10-2")
604628
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5), named: "ipad-pro-10-5")
605629
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11), named: "ipad-pro-11")
606630
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9), named: "ipad-pro-12-9")
@@ -612,6 +636,8 @@ final class SnapshotTestingTests: XCTestCase {
612636
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXr(.portrait)), named: "iphone-xr")
613637
assertSnapshot(matching: viewController, as: .image(on: .iPhoneXsMax(.portrait)), named: "iphone-xs-max")
614638
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape)), named: "ipad-mini")
639+
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape)), named: "ipad-9-7")
640+
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape)), named: "ipad-10-2")
615641
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape)), named: "ipad-pro-10-5")
616642
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11(.landscape)), named: "ipad-pro-11")
617643
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9(.landscape)), named: "ipad-pro-12-9")
@@ -630,6 +656,10 @@ final class SnapshotTestingTests: XCTestCase {
630656
matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative")
631657
assertSnapshot(
632658
matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative")
659+
assertSnapshot(
660+
matching: viewController, as: .image(on: .iPad9_7(.portrait)), named: "ipad-9-7-alternative")
661+
assertSnapshot(
662+
matching: viewController, as: .image(on: .iPad10_2(.portrait)), named: "ipad-10-2-alternative")
633663
assertSnapshot(
634664
matching: viewController, as: .image(on: .iPadPro10_5(.portrait)), named: "ipad-pro-10-5-alternative")
635665
assertSnapshot(
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<UIView; frame = (0 0; 1080 810); autoresize = W+H; layer = <CALayer>>
2+
| <UILabel; frame = (512.333 20; 55.6667 20.3333); text = 'What's'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
3+
| <UILabel; frame = (0 405; 25 20.3333); text = 'the'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
4+
| <UILabel; frame = (1041 405; 39 20.3333); text = 'point'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
5+
| <UILabel; frame = (536.333 792; 7.66667 18); text = '?'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<UIView; frame = (0 0; 1024 768); autoresize = W+H; layer = <CALayer>>
2+
| <UILabel; frame = (484.333 20; 55.6667 20.3333); text = 'What's'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
3+
| <UILabel; frame = (0 384; 25 20.3333); text = 'the'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
4+
| <UILabel; frame = (985 384; 39 20.3333); text = 'point'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
5+
| <UILabel; frame = (508.333 750; 7.66667 18); text = '?'; userInteractionEnabled = NO; layer = <_UILabelLayer>>

0 commit comments

Comments
 (0)