Skip to content

Commit

Permalink
Add landscape snapshot testing capability
Browse files Browse the repository at this point in the history
This PR adds a capability to snapshot test screens in landscape, both
with regular and large font.

MOB-2653
  • Loading branch information
rasmustautsglia committed Sep 15, 2023
1 parent 27d7827 commit f6b1502
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions SnapshotTests/SnapshotTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,38 @@ extension Snapshotting where Value == UIView, Format == UIImage {
)
}
}

extension Snapshotting where Value == UIViewController, Format == UIImage {
static var extra3LargeFontStrategyLandscape: Self {
let traits = UITraitCollection(traitsFrom: [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone),
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact),
.init(preferredContentSizeCategory: .accessibilityExtraExtraExtraLarge)
])
let safeArea: UIEdgeInsets = .init(top: 0, left: 47, bottom: 21, right: 47)
let size: CGSize = .init(width: 844, height: 390)
let viewImageConfig: ViewImageConfig = .init(safeArea: safeArea, size: size, traits: traits)

return Self.image(on: viewImageConfig)
}

static var imageLandscape: Self {
let traits = UITraitCollection(traitsFrom: [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone),
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact)
])
let safeArea: UIEdgeInsets = .init(top: 0, left: 47, bottom: 21, right: 47)
let size: CGSize = .init(width: 844, height: 390)
let viewImageConfig: ViewImageConfig = .init(safeArea: safeArea, size: size, traits: traits)

return Self.image(on: viewImageConfig)
}
}

0 comments on commit f6b1502

Please sign in to comment.