Skip to content

Commit

Permalink
Merge from FB
Browse files Browse the repository at this point in the history
  • Loading branch information
imurchie committed Dec 12, 2017
2 parents 0b59e3e + 6a9b497 commit 8496615
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function fetch_and_build_dependencies() {

function build_inspector() {
echo -e "${BOLD}Building Inspector"
assert_has_npm
CURRENT_DIR=$(pwd)
RESOURCE_BUNDLE_DIR="$CURRENT_DIR/Resources/WebDriverAgent.bundle"
INSPECTOR_DIR="$CURRENT_DIR/Inspector"
Expand Down
1 change: 1 addition & 0 deletions WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <arpa/inet.h>
#import <ifaddrs.h>
#include <notify.h>
#import <objc/runtime.h>

#import "FBSpringboardApplication.h"
#import "FBErrorBuilder.h"
Expand Down
6 changes: 3 additions & 3 deletions WebDriverAgentLib/Categories/XCUIElement+FBUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)fb_obstructsElement:(XCUIElement *)element;

/**
Gets the most recent snapshot of the current element. The element will be
Gets the most recent snapshot of the current element. The element will be
automatically resolved if the snapshot is not available yet
@return The recent snapshot of the element
*/
- (XCElementSnapshot *)fb_lastSnapshot;

/**
Filters elements by matching them to snapshots from the corresponding array
@param snapshots Array of snapshots to be matched with
@return Array of filtered elements, which have matches in snapshots array
Expand Down
15 changes: 9 additions & 6 deletions WebDriverAgentLib/Categories/XCUIElement+FBUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import "XCUIElement+FBUtilities.h"

#import <objc/runtime.h>

#import "FBAlert.h"
#import "FBLogger.h"
#import "FBMacros.h"
Expand All @@ -19,6 +21,7 @@
#import "XCAXClient_iOS.h"
#import "XCUIElement+FBWebDriverAttributes.h"


@implementation XCUIElement (FBUtilities)

static const NSTimeInterval FBANIMATION_TIMEOUT = 5.0;
Expand Down Expand Up @@ -124,23 +127,23 @@ - (BOOL)fb_waitUntilSnapshotIsStable
return result;
}

- (NSData *)fb_screenshotWithError:(NSError**)error
- (NSData *)fb_screenshotWithError:(NSError **)error
{
if (CGRectIsEmpty(self.frame)) {
if (error) {
*error = [[FBErrorBuilder.builder withDescription:@"Cannot get a screenshot of zero-sized element"] build];
}
return nil;
}

Class xcScreenClass = NSClassFromString(@"XCUIScreen");
if (nil == xcScreenClass) {
if (error) {
*error = [[FBErrorBuilder.builder withDescription:@"Element screenshots are only available since Xcode9 SDK"] build];
}
return nil;
}

id mainScreen = [xcScreenClass valueForKey:@"mainScreen"];
SEL mSelector = NSSelectorFromString(@"screenshotDataForQuality:rect:error:");
NSMethodSignature *mSignature = [mainScreen methodSignatureForSelector:mSelector];
Expand All @@ -158,7 +161,7 @@ - (NSData *)fb_screenshotWithError:(NSError**)error
if (nil == imageData) {
return nil;
}

UIImage *image = [UIImage imageWithData:imageData];
UIInterfaceOrientation orientation = self.application.interfaceOrientation;
UIImageOrientation imageOrientation = UIImageOrientationUp;
Expand All @@ -173,9 +176,9 @@ - (NSData *)fb_screenshotWithError:(NSError**)error
CGSize size = image.size;
UIGraphicsBeginImageContext(CGSizeMake(size.width, size.height));
[[UIImage imageWithCGImage:(CGImageRef)[image CGImage] scale:1.0 orientation:imageOrientation] drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage* fixedImage = UIGraphicsGetImageFromCurrentImageContext();
UIImage *fixedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

// The resulting data is a JPEG image, so we need to convert it to PNG representation
return (NSData *)UIImagePNGRepresentation(fixedImage);
}
Expand Down
1 change: 1 addition & 0 deletions WebDriverAgentLib/Utilities/FBXCodeCompatibility.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ - (BOOL)fb_isActivateSupported

@end


static BOOL FBShouldUseFirstMatchSelector = NO;
static dispatch_once_t onceFirstMatchToken;
@implementation XCUIElementQuery (FBCompatibility)
Expand Down
4 changes: 3 additions & 1 deletion WebDriverAgentLib/Utilities/XCTestPrivateSymbols.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#import "XCTestPrivateSymbols.h"

#import <objc/runtime.h>

#import "FBRuntimeUtils.h"

NSNumber *FB_XCAXAIsVisibleAttribute;
Expand Down Expand Up @@ -38,7 +40,7 @@

void *FBRetrieveXCTestSymbol(const char *name)
{
Class XCTestClass = NSClassFromString(@"XCTestCase");
Class XCTestClass = objc_lookUpClass("XCTestCase");
NSCAssert(XCTestClass != nil, @"XCTest should be already linked", XCTestClass);
NSString *XCTestBinary = [NSBundle bundleForClass:XCTestClass].executablePath;
const char *binaryPath = XCTestBinary.UTF8String;
Expand Down

0 comments on commit 8496615

Please sign in to comment.