-
Notifications
You must be signed in to change notification settings - Fork 54
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
Adds quick screenshot method to all SLElement objects #129
Changes from 1 commit
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 |
---|---|---|
|
@@ -170,6 +170,29 @@ | |
*/ | ||
- (void)logElement; | ||
|
||
#pragma mark - Screenshots | ||
/// ---------------------------------------- | ||
/// @name Screenshot an element | ||
/// ---------------------------------------- | ||
|
||
/** | ||
Takes a screenshot of the specified element. | ||
|
||
The rect for the screenshot of the element is automatically provided. | ||
|
||
The image is viewable from the UIAutomation debug log in Instruments. | ||
|
||
When running `subliminal-test` from the command line, the images are also saved | ||
as PNGs within the specified output directory. | ||
|
||
@param filename A string to use as the name for the resultant image file. | ||
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. Please note that this is optional. |
||
|
||
@exception `NSInternalInconsistencyException` if `rect` is `CGRectNull` for specified element. | ||
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. This method abstracts away the use of Since |
||
|
||
*/ | ||
|
||
- (void) screenshotWithFilename:(NSString *)filename; | ||
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. Can you name the method Also, minor point of style: please remove the space between |
||
|
||
@end | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
#import "NSObject+SLVisibility.h" | ||
#import "NSObject+SLAccessibilityDescription.h" | ||
#import "UIScrollView+SLProgrammaticScrolling.h" | ||
#import "SLDevice.h" | ||
|
||
|
||
// The real value (set in `+load`) is not a compile-time constant, | ||
|
@@ -398,4 +399,16 @@ - (void)logElementTree { | |
[super logElementTree]; | ||
} | ||
|
||
#pragma mark - | ||
|
||
- (void) screenshotWithFilename:(NSString *)filename | ||
{ | ||
// maybe consider using a timestamp? not sure if it's worth introducing the complexity of NSDateFormatter | ||
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. Yeah I don't think it's worth appending a timestamp. If the user really cares about distinguishing these screenshots, they can pass a filename. |
||
// The UIAutomation framework automatically appends an integer to screenshots with the same name to prevent overwriting | ||
if (!filename) { | ||
filename = @"element_screenshot"; | ||
} | ||
[[SLDevice currentDevice] captureScreenshotWithFilename:filename inRect:self.rect]; | ||
} | ||
|
||
@end |
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.
I don't think we need to mention this--it's kinda an implementation detail.