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 7ed5771
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: 44, bottom: 24, right: 44)
let size: CGSize = .init(width: 896, height: 414)
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: 44, bottom: 24, right: 44)
let size: CGSize = .init(width: 896, height: 414)
let viewImageConfig: ViewImageConfig = .init(safeArea: safeArea, size: size, traits: traits)

return Self.image(on: viewImageConfig)
}
}

0 comments on commit 7ed5771

Please sign in to comment.