Skip to content

Instantly share code, notes, and snippets.

@TheAdamBorek
Last active April 3, 2017 06:33
Show Gist options
  • Select an option

  • Save TheAdamBorek/404ec87069a0feb58651b3ef64ecc89e to your computer and use it in GitHub Desktop.

Select an option

Save TheAdamBorek/404ec87069a0feb58651b3ef64ecc89e to your computer and use it in GitHub Desktop.
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