Skip to content

Add support for iPad 9_7 and iPad 10_2 #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Sources/SnapshotTesting/Common/View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,63 @@ public struct ViewImageConfig {
return .init(safeArea: .init(top: 20, left: 0, bottom: 0, right: 0), size: size, traits: traits)
}

public static let iPad9_7 = iPadMini

public static func iPad9_7(_ orientation: Orientation) -> ViewImageConfig {
return iPadMini(orientation)
}

public static func iPad9_7(_ orientation: TabletOrientation) -> ViewImageConfig {
return iPadMini(orientation)
}

public static let iPad10_2 = ViewImageConfig.iPad10_2(.landscape)

public static func iPad10_2(_ orientation: Orientation) -> ViewImageConfig {
switch orientation {
case .landscape:
return ViewImageConfig.iPad10_2(.landscape(splitView: .full))
case .portrait:
return ViewImageConfig.iPad10_2(.portrait(splitView: .full))
}
}

public static func iPad10_2(_ orientation: TabletOrientation) -> ViewImageConfig {
let size: CGSize
let traits: UITraitCollection
switch orientation {
case .landscape(let splitView):
switch splitView {
case .oneThird:
size = .init(width: 320, height: 810)
traits = .iPad10_2_Compact_SplitView
case .oneHalf:
size = .init(width: 535, height: 810)
traits = .iPad10_2_Compact_SplitView
case .twoThirds:
size = .init(width: 750, height: 810)
traits = .iPad10_2
case .full:
size = .init(width: 1080, height: 810)
traits = .iPad10_2
}
case .portrait(let splitView):
switch splitView {
case .oneThird:
size = .init(width: 320, height: 1080)
traits = .iPad10_2_Compact_SplitView
case .twoThirds:
size = .init(width: 480, height: 1080)
traits = .iPad10_2_Compact_SplitView
case .full:
size = .init(width: 810, height: 1080)
traits = .iPad10_2
}
}
return .init(safeArea: .init(top: 20, left: 0, bottom: 0, right: 0), size: size, traits: traits)
}


public static let iPadPro10_5 = ViewImageConfig.iPadPro10_5(.landscape)

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

public static let iPadMini = iPad
public static let iPadMini_Compact_SplitView = iPadCompactSplitView
public static let iPad9_7 = iPad
public static let iPad9_7_Compact_SplitView = iPadCompactSplitView
public static let iPad10_2 = iPad
public static let iPad10_2_Compact_SplitView = iPadCompactSplitView
public static let iPadPro10_5 = iPad
public static let iPadPro10_5_Compact_SplitView = iPadCompactSplitView
public static let iPadPro11 = iPad
Expand Down
30 changes: 30 additions & 0 deletions Tests/SnapshotTestingTests/SnapshotTestingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ final class SnapshotTestingTests: XCTestCase {
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: .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")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5), named: "ipad-pro-10-5")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11), named: "ipad-pro-11")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9), named: "ipad-pro-12-9")
Expand All @@ -455,6 +457,8 @@ final class SnapshotTestingTests: XCTestCase {
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: .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")
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro10_5), named: "ipad-pro-10-5")
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro11), named: "ipad-pro-11")
assertSnapshot(matching: viewController, as: .recursiveDescription(on: .iPadPro12_9), named: "ipad-pro-12-9")
Expand All @@ -466,6 +470,8 @@ final class SnapshotTestingTests: XCTestCase {
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: .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")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape)), named: "ipad-pro-10-5")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11(.landscape)), named: "ipad-pro-11")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9(.landscape)), named: "ipad-pro-12-9")
Expand All @@ -475,6 +481,18 @@ final class SnapshotTestingTests: XCTestCase {
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.landscape(splitView: .twoThirds))), named: "ipad-mini-66-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.portrait(splitView: .oneThird))), named: "ipad-mini-33-split-portrait")
assertSnapshot(matching: viewController, as: .image(on: .iPadMini(.portrait(splitView: .twoThirds))), named: "ipad-mini-66-split-portrait")

assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .oneThird))), named: "ipad-9-7-33-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .oneHalf))), named: "ipad-9-7-50-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.landscape(splitView: .twoThirds))), named: "ipad-9-7-66-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.portrait(splitView: .oneThird))), named: "ipad-9-7-33-split-portrait")
assertSnapshot(matching: viewController, as: .image(on: .iPad9_7(.portrait(splitView: .twoThirds))), named: "ipad-9-7-66-split-portrait")

assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .oneThird))), named: "ipad-10-2-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .oneHalf))), named: "ipad-10-2-50-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.landscape(splitView: .twoThirds))), named: "ipad-10-2-66-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.portrait(splitView: .oneThird))), named: "ipad-10-2-33-split-portrait")
assertSnapshot(matching: viewController, as: .image(on: .iPad10_2(.portrait(splitView: .twoThirds))), named: "ipad-10-2-66-split-portrait")

assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape(splitView: .oneThird))), named: "ipad-pro-10inch-33-split-landscape")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape(splitView: .oneHalf))), named: "ipad-pro-10inch-50-split-landscape")
Expand Down Expand Up @@ -508,6 +526,10 @@ final class SnapshotTestingTests: XCTestCase {
matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPad9_7(.portrait)), named: "ipad-9-7-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPad10_2(.portrait)), named: "ipad-10-2-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPadPro10_5(.portrait)), named: "ipad-pro-10-5-alternative")
assertSnapshot(
Expand Down Expand Up @@ -601,6 +623,8 @@ final class SnapshotTestingTests: XCTestCase {
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: .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")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5), named: "ipad-pro-10-5")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11), named: "ipad-pro-11")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9), named: "ipad-pro-12-9")
Expand All @@ -612,6 +636,8 @@ final class SnapshotTestingTests: XCTestCase {
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: .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")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro10_5(.landscape)), named: "ipad-pro-10-5")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro11(.landscape)), named: "ipad-pro-11")
assertSnapshot(matching: viewController, as: .image(on: .iPadPro12_9(.landscape)), named: "ipad-pro-12-9")
Expand All @@ -630,6 +656,10 @@ final class SnapshotTestingTests: XCTestCase {
matching: viewController, as: .image(on: .iPhoneXsMax(.landscape)), named: "iphone-xs-max-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPadMini(.portrait)), named: "ipad-mini-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPad9_7(.portrait)), named: "ipad-9-7-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPad10_2(.portrait)), named: "ipad-10-2-alternative")
assertSnapshot(
matching: viewController, as: .image(on: .iPadPro10_5(.portrait)), named: "ipad-pro-10-5-alternative")
assertSnapshot(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<UIView; frame = (0 0; 1080 810); autoresize = W+H; layer = <CALayer>>
| <UILabel; frame = (512.333 20; 55.6667 20.3333); text = 'What's'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (0 405; 25 20.3333); text = 'the'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (1041 405; 39 20.3333); text = 'point'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (536.333 792; 7.66667 18); text = '?'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<UIView; frame = (0 0; 1024 768); autoresize = W+H; layer = <CALayer>>
| <UILabel; frame = (484.333 20; 55.6667 20.3333); text = 'What's'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (0 384; 25 20.3333); text = 'the'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (985 384; 39 20.3333); text = 'point'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
| <UILabel; frame = (508.333 750; 7.66667 18); text = '?'; userInteractionEnabled = NO; layer = <_UILabelLayer>>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.