Skip to content
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: make adjusting screenshot coordinate configurable - screenshotOrientation settings api #277

Merged
20 changes: 11 additions & 9 deletions WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,18 @@ + (NSInteger)screenshotOrientation

+ (NSString *)humanReadableScreenshotOrientation
{
if (FBScreenshotOrientation == UIInterfaceOrientationPortrait) {
return @"portrait";
} else if (FBScreenshotOrientation == UIInterfaceOrientationPortraitUpsideDown) {
return @"portraitUpsideDown";
} else if (FBScreenshotOrientation == UIInterfaceOrientationLandscapeRight) {
return @"landscapeRight";
} else if (FBScreenshotOrientation == UIInterfaceOrientationLandscapeLeft) {
return @"landscapeLeft";
switch (FBScreenshotOrientation) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

case UIInterfaceOrientationPortrait:
return @"portrait";
case UIInterfaceOrientationPortraitUpsideDown:
return @"portraitUpsideDown";
case UIInterfaceOrientationLandscapeRight:
return @"landscapeRight";
case UIInterfaceOrientationLandscapeLeft:
return @"landscapeLeft";
case UIInterfaceOrientationUnknown:
return @"auto";
}
return @"auto";
}
#endif

Expand Down
21 changes: 13 additions & 8 deletions WebDriverAgentLib/Utilities/FBImageUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ BOOL FBIsPngImage(NSData *imageData)
return (NSData *)UIImagePNGRepresentation(image);
}
} else {
if (FBConfiguration.screenshotOrientation == UIInterfaceOrientationPortraitUpsideDown) {
imageOrientation = UIImageOrientationDown;
} else if (FBConfiguration.screenshotOrientation == UIInterfaceOrientationLandscapeRight) {
imageOrientation = UIImageOrientationLeft;
} else if (FBConfiguration.screenshotOrientation == UIInterfaceOrientationLandscapeLeft) {
imageOrientation = UIImageOrientationRight;
} else {
imageOrientation = UIImageOrientationUp;
switch (FBConfiguration.screenshotOrientation) {
case UIInterfaceOrientationPortraitUpsideDown:
imageOrientation = UIImageOrientationDown;
break;
case UIInterfaceOrientationLandscapeRight:
imageOrientation = UIImageOrientationLeft;
break;
case UIInterfaceOrientationLandscapeLeft:
imageOrientation = UIImageOrientationRight;
break;
default:
imageOrientation = UIImageOrientationUp;
break;
}
}

Expand Down