-
-
Notifications
You must be signed in to change notification settings - Fork 336
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
fix(screenshots): Don't capture zero size screenshots #2459
Changes from all commits
ed15636
7d9c595
d8f9d5f
49f2f84
645d469
9a77f8a
6022f6a
c8a2689
8b99397
15331d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,12 @@ - (void)saveScreenShots:(NSString *)path | |
|
||
if ([window drawViewHierarchyInRect:window.bounds afterScreenUpdates:false]) { | ||
UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); | ||
[result addObject:UIImagePNGRepresentation(img)]; | ||
if (img.size.width > 0 || img.size.height > 0) { | ||
NSData *bytes = UIImagePNGRepresentation(img); | ||
if (bytes && bytes.length > 0) { | ||
Comment on lines
+51
to
+52
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.
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. Its not the size of the view that makes the image 0 length, its not being able to render the image. |
||
[result addObject:bytes]; | ||
} | ||
} | ||
} | ||
|
||
UIGraphicsEndImageContext(); | ||
|
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.
m
: Can we please add tests for this new functionality? As this code is not really testable you could extract this code into a method, expose it via a private category that you would have to add similar as we have it, for example, for SentryClient+Private.h, and then call it from tests. I can also push the basic solution to your branch if you want @krystofwoldrich.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.
You can push the solution to this branch and I will work with that. It will definitely help me.
Besides exposing it with the private header. Are there any examples in the test on how to mock functions, likely I will have to mock
UIGraphicsGetImageFromCurrentImageContext
.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.
The code was already testable. I added a test.