Last active
April 3, 2017 06:33
-
-
Save TheAdamBorek/404ec87069a0feb58651b3ef64ecc89e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum ScreenSizes { | |
static let threePointFiveInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 480) | |
static let fourInchesPhoneFrame = CGRect(x: 0, y: 0, width: 320, height: 568) | |
static let fourPointSevenInchesPhoneFrame = CGRect(x: 0, y: 0, width: 375, height: 667) | |
static let iPadPortrait = CGRect(x: 0, y: 0, width: 768, height: 1024) | |
static let iPadLandscape = CGRect(x: 0, y: 0, width: 1024, height: 768) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SnapshotTestCase: FBSnapshotTestCase { | |
private let frames: [String : CGRect] = [ | |
"iPadPortraitFrame": ScreenSizes.iPadPortrait, | |
"iPadLandscapeFrame": ScreenSizes.iPadLandscape, | |
"threePointFivePhoneFrame": ScreenSizes.threePointFiveInchesPhoneFrame, | |
"fourInchesPhoneFrame": ScreenSizes.fourInchesPhoneFrame, | |
"fourPointSevenInchesPhoneFrame": ScreenSizes.fourPointSevenInchesPhoneFrame | |
] | |
override func getReferenceImageDirectory(withDefault dir: String!) -> String! { | |
return snapshotReferenceImageDirectory | |
} | |
func verifyForScreens(view: UIView, file: StaticString = #file, line: UInt = #line) { | |
for (identifier, frame) in frames { | |
verify(view: view, frame: frame, identifier: identifier, file: file, line: line) | |
} | |
} | |
func verify(view: UIView, frame: CGRect? = nil, identifier: String = "", file: StaticString = #file, line: UInt = #line) { | |
if let frame = frame { | |
view.frame = frame | |
} | |
view.layoutIfNeeded() | |
FBSnapshotVerifyView(view, identifier: identifier, file: file, line: line) | |
FBSnapshotVerifyLayer(view.layer, identifier: identifier, file: file, line: line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment