-
Notifications
You must be signed in to change notification settings - Fork 220
Port Xcode 9 XCTAttachment API integration from FB repo #19
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4ea21c4
Implement Xcode 9 integration using XCTAttachement API
SiarheiFedartsou 25feb78
Add tvOS support for Xcode 9 integration & some cleanup
SiarheiFedartsou 951bb0d
s/attachement/attachment
delebedev d45a6ff
Conform to coding style
delebedev b85e09e
Pass recordMode as parameter
delebedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,58 +11,15 @@ | |
| #if swift(>=3) | ||
| public extension FBSnapshotTestCase { | ||
| public func FBSnapshotVerifyView(_ view: UIView, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { | ||
| FBSnapshotVerifyViewOrLayer(view, identifier: identifier, suffixes: suffixes, tolerance: tolerance, file: file, line: line) | ||
| if let errorDescription = snapshotVerifyViewOrLayer(view, identifier: identifier, suffixes: suffixes, tolerance: tolerance, defaultReferenceDirectory: FB_REFERENCE_IMAGE_DIR) { | ||
| XCTFail(errorDescription, file: file, line: line) | ||
| } | ||
| } | ||
|
|
||
| public func FBSnapshotVerifyLayer(_ layer: CALayer, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { | ||
| FBSnapshotVerifyViewOrLayer(layer, identifier: identifier, suffixes: suffixes, tolerance: tolerance, file: file, line: line) | ||
| } | ||
|
|
||
| private func FBSnapshotVerifyViewOrLayer(_ viewOrLayer: AnyObject, identifier: String = "", suffixes: NSOrderedSet = FBSnapshotTestCaseDefaultSuffixes(), tolerance: CGFloat = 0, file: StaticString = #file, line: UInt = #line) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe there's a good reason why |
||
| let envReferenceImageDirectory = self.getReferenceImageDirectory(withDefault: FB_REFERENCE_IMAGE_DIR) | ||
| var error: NSError? | ||
| var comparisonSuccess = false | ||
|
|
||
| if let envReferenceImageDirectory = envReferenceImageDirectory { | ||
| for suffix in suffixes { | ||
| let referenceImagesDirectory = "\(envReferenceImageDirectory)\(suffix)" | ||
| if viewOrLayer.isKind(of: UIView.self) { | ||
| do { | ||
| try compareSnapshot(of: viewOrLayer as! UIView, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: tolerance) | ||
| comparisonSuccess = true | ||
| } catch let error1 as NSError { | ||
| error = error1 | ||
| comparisonSuccess = false | ||
| } | ||
| } else if viewOrLayer.isKind(of: CALayer.self) { | ||
| do { | ||
| try compareSnapshot(of: viewOrLayer as! CALayer, referenceImagesDirectory: referenceImagesDirectory, identifier: identifier, tolerance: tolerance) | ||
| comparisonSuccess = true | ||
| } catch let error1 as NSError { | ||
| error = error1 | ||
| comparisonSuccess = false | ||
| } | ||
| } else { | ||
| assertionFailure("Only UIView and CALayer classes can be snapshotted") | ||
| } | ||
|
|
||
| assert(recordMode == false, message: "Test ran in record mode. Reference image is now saved. Disable record mode to perform an actual snapshot comparison!", file: file, line: line) | ||
|
|
||
| if comparisonSuccess || recordMode { | ||
| break | ||
| } | ||
|
|
||
| assert(comparisonSuccess, message: "Snapshot comparison failed: \(String(describing: error))", file: file, line: line) | ||
| if let errorDescription = snapshotVerifyViewOrLayer(layer, identifier: identifier, suffixes: suffixes, tolerance: tolerance, defaultReferenceDirectory: FB_REFERENCE_IMAGE_DIR) { | ||
| XCTFail(errorDescription, file: file, line: line) | ||
| } | ||
| } else { | ||
| XCTFail("Missing value for referenceImagesDirectory - Set FB_REFERENCE_IMAGE_DIR as Environment variable in your scheme.") | ||
| } | ||
| } | ||
|
|
||
| func assert(_ assertion: Bool, message: String, file: StaticString, line: UInt) { | ||
| if !assertion { | ||
| XCTFail(message, file: file, line: line) | ||
| } | ||
| } | ||
| } | ||
| #else | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this possible? Looking at L102-L105, it is doing this:
When
self.recordModeis on,compareSnapshotOfViewOrLayer:...the BOOL from the function relates to whether or not the reference image was saved.