Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
csusheep committed Dec 21, 2023
1 parent e2d1aec commit 654db99
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 95 deletions.
8 changes: 4 additions & 4 deletions WebDriverAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4348,7 +4348,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 7J7278KZZ5;
DEVELOPMENT_TEAM = VDZ6WAVGC2;
INFOPLIST_FILE = WebDriverAgentTests/IntegrationApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -4368,7 +4368,7 @@
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 7J7278KZZ5;
DEVELOPMENT_TEAM = VDZ6WAVGC2;
INFOPLIST_FILE = WebDriverAgentTests/IntegrationApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -4429,7 +4429,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 7J7278KZZ5;
DEVELOPMENT_TEAM = VDZ6WAVGC2;
ENABLE_TESTING_SEARCH_PATHS = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
Expand Down Expand Up @@ -4487,7 +4487,7 @@
CLANG_STATIC_ANALYZER_MODE = deep;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 7J7278KZZ5;
DEVELOPMENT_TEAM = VDZ6WAVGC2;
ENABLE_TESTING_SEARCH_PATHS = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
Expand Down
14 changes: 12 additions & 2 deletions WebDriverAgentLib/Commands/FBScreenshotCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#import "FBLogger.h"
#import "FBScreenshot.h"
#import "FBMacros.h"
#import "FBImageIOScaler.h"
#import "FBConfiguration.h"
#import "FBErrorBuilder.h"
#import "FBImageProcessor.h"

static const NSTimeInterval SCREENSHOT_TIMEOUT = 0.5;

Expand Down Expand Up @@ -94,7 +94,7 @@ + (NSArray *)routes
rect = CGRectNull;
}

if ([FBScreenshot isNewScreenshotAPISupported]) {
if ([FBScreenshotCommands isNewScreenshotAPISupported]) {
id<XCTestManager_ManagerInterface> proxy = [FBXCTestDaemonsProxy testRunnerProxy];
__block NSError *innerError = nil;
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
Expand Down Expand Up @@ -306,5 +306,15 @@ + (nullable NSData *)jpegDataWithImage:(CGImageRef)imageRef
return newImageData;
}

+ (BOOL)isNewScreenshotAPISupported
{
static dispatch_once_t newScreenshotAPISupported;
static BOOL result;
dispatch_once(&newScreenshotAPISupported, ^{
result = [(NSObject *)[FBXCTestDaemonsProxy testRunnerProxy] respondsToSelector:@selector(_XCT_requestScreenshotOfScreenWithID:withRect:uti:compressionQuality:withReply:)];
});
return result;
}


@end
44 changes: 0 additions & 44 deletions WebDriverAgentLib/Commands/UUElementCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#import "XCUIElement+FBIsVisible.h"
#import "XCUIElement+FBPickerWheel.h"
#import "XCUIElement+FBScrolling.h"
#import "XCUIElement+FBTap.h"
#import "XCUIElement+FBTyping.h"
#import "XCUIElement+FBUtilities.h"
#import "XCUIElement+FBWebDriverAttributes.h"
Expand Down Expand Up @@ -203,46 +202,6 @@ + (NSArray *)routes {
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)uuDealAlert:(FBRouteRequest *)request {
FBApplication *application = request.session.activeApplication ?: [FBApplication fb_activeApplication];
FBAlert *alert = [FBAlert alertWithApplication:application];
NSError *error;
NSInteger counts = 0;
while (alert.isPresent && counts < 10) {
[alert uuAcceptWithError:&error];
alert = [FBAlert alertWithApplication:application];
counts += 1;
}
if (error) {
return FBResponseWithUnknownError(error);
}
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)uuDealAlertWithParam:(FBRouteRequest *)request {
FBApplication *application = request.session.activeApplication ?: [FBApplication fb_activeApplication];
BOOL accept = [request.arguments[@"accept"] boolValue];
FBAlert *alert = [FBAlert alertWithApplication:application];
if (nil == alert) {
return FBResponseWithOK();
}
NSError *error;
NSInteger counts = 0;
while (alert.isPresent && counts < 10) {
if (accept) {
[alert uuAcceptWithError:&error];
} else {
[alert uuDismissWithError:&error];
}
alert = [FBAlert alertWithApplication:application];
counts += 1;
}
if (error) {
return FBResponseWithUnknownError(error);
}
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)uuGetSysInfo:(FBRouteRequest *)request
{
[[BatteryInfoManager sharedManager] startBatteryMonitoring];
Expand Down Expand Up @@ -581,9 +540,6 @@ screen orientation is different from the default one (which is portrait).
*/
+ (XCUICoordinate *)uuGestureCoordinateWithCoordinate:(CGPoint)coordinate application:(XCUIApplication *)application shouldApplyOrientationWorkaround:(BOOL)shouldApplyOrientationWorkaround {
CGPoint point = coordinate;
if (shouldApplyOrientationWorkaround) {
point = FBInvertPointForApplication(coordinate, application.frame.size, application.interfaceOrientation);
}
XCUICoordinate *appCoordinate = [[XCUICoordinate alloc] initWithElement:application normalizedOffset:CGVectorMake(0, 0)];
return [[XCUICoordinate alloc] initWithCoordinate:appCoordinate pointsOffset:CGVectorMake(point.x, point.y)];
}
Expand Down
4 changes: 0 additions & 4 deletions WebDriverAgentLib/FBAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (BOOL)acceptWithError:(NSError **)error;

- (BOOL)uuAcceptWithError:(NSError **)error;

/**
Dismisses alert, if present
Expand All @@ -66,8 +64,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (BOOL)dismissWithError:(NSError **)error;

- (BOOL)uuDismissWithError:(NSError **)error;

/**
Clicks on an alert button, if present
Expand Down
41 changes: 0 additions & 41 deletions WebDriverAgentLib/FBAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -276,45 +276,4 @@ - (XCUIElement *)alertElement
}


- (BOOL)uuAcceptWithError:(NSError **)error
{
XCUIElement *alertElement = self.alertElement;
NSArray<XCUIElement *> *buttons = [alertElement descendantsMatchingType:XCUIElementTypeButton].allElementsBoundByIndex;

XCUIElement *defaultButton;
if (alertElement.elementType == XCUIElementTypeAlert && [buttons count] < 3) {
defaultButton = buttons.lastObject;
} else {
defaultButton = buttons.firstObject;
}
if (!defaultButton) {
return
[[[FBErrorBuilder builder]
withDescriptionFormat:@"Failed to find accept button for alert: %@", alertElement]
buildError:error];
}
return [defaultButton fb_tapWithError:error];
}

- (BOOL)uuDismissWithError:(NSError **)error
{
XCUIElement *cancelButton;
XCUIElement *alertElement = self.alertElement;
NSArray<XCUIElement *> *buttons = [alertElement descendantsMatchingType:XCUIElementTypeButton].allElementsBoundByIndex;

if (alertElement.elementType == XCUIElementTypeAlert) {
cancelButton = buttons.firstObject;
} else {
cancelButton = buttons.lastObject;
}
if (!cancelButton) {
return
[[[FBErrorBuilder builder]
withDescriptionFormat:@"Failed to find dismiss button for alert: %@", alertElement]
buildError:error];
return NO;
}
return [cancelButton fb_tapWithError:error];
}

@end

0 comments on commit 654db99

Please sign in to comment.