From f6b1502ed7882fac49c3ccac576c9b5749d18ba4 Mon Sep 17 00:00:00 2001 From: Rasmus Tauts Date: Fri, 15 Sep 2023 15:57:23 +0300 Subject: [PATCH] Add landscape snapshot testing capability This PR adds a capability to snapshot test screens in landscape, both with regular and large font. MOB-2653 --- SnapshotTests/SnapshotTestCase.swift | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/SnapshotTests/SnapshotTestCase.swift b/SnapshotTests/SnapshotTestCase.swift index d6d46b3e2..6c9ddd635 100644 --- a/SnapshotTests/SnapshotTestCase.swift +++ b/SnapshotTests/SnapshotTestCase.swift @@ -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) + } +}