-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add landscape snapshot testing capability #774
Add landscape snapshot testing capability #774
Conversation
fe018b2
to
f6b1502
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then we should do
assertSnapshot(
matching: viewController,
as: .extra3LargeFontStrategyLandscape,
named: ...
)
correct? Or as: .imageLandscape
also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool. Added some comments regarding reusing trait collections. It is such great idea to have landscape mode tested 👍
SnapshotTests/SnapshotTestCase.swift
Outdated
let traits = UITraitCollection(traitsFrom: [ | ||
.init(forceTouchCapability: .available), | ||
.init(layoutDirection: .leftToRight), | ||
.init(preferredContentSizeCategory: .medium), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says preferredContentSizeCategory
is .medium
here, but below it overrides it with .accessibilityExtraExtraExtraLarge)
. Seem like medium
is unnecessary?
.init(preferredContentSizeCategory: .medium), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 3a0d35b
SnapshotTests/SnapshotTestCase.swift
Outdated
extension Snapshotting where Value == UIViewController, Format == UIImage { | ||
static var extra3LargeFontStrategyLandscape: Self { | ||
let traits = UITraitCollection(traitsFrom: [ | ||
.init(forceTouchCapability: .available), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we use forceTouchCapability
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't as far as I know. Those traits were taken from the other available iPhone models, because unfortunately iPhone 13 is not available. Perhaps this allows some other kind of testing and those traits are just bundled together for easier use.
return Self.image(on: viewImageConfig) | ||
} | ||
|
||
static var imageLandscape: Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like most of the trait collection items are the same, so we can put them in one reusable list:
private static var commonTraitCollection: [UITraitCollection] = [
.init(forceTouchCapability: .available),
.init(layoutDirection: .leftToRight),
.init(preferredContentSizeCategory: .medium),
.init(userInterfaceIdiom: .phone),
.init(horizontalSizeClass: .regular),
.init(verticalSizeClass: .compact),
]
static var extra3LargeFontStrategyLandscape: Self {
let traits = UITraitCollection(traitsFrom: [
.init(preferredContentSizeCategory: .accessibilityExtraExtraExtraLarge)
] + commonTraitCollection)
/// .....
static var imageLandscape: Self {
let traits = UITraitCollection(traitsFrom: commonTraitCollection)
/// .....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed 3a0d35b
!squash |
This PR adds a capability to snapshot test screens in landscape, both with regular and large font. MOB-2653
b7bea6b
to
3d55c01
Compare
This PR adds a capability to snapshot test screens in landscape, both with regular and large font.
MOB-2653