Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyunpeng2 committed Jul 5, 2024
1 parent d8fcd1a commit 55b1d66
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
26 changes: 12 additions & 14 deletions WebDriverAgentLib/Commands/FBSTFCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import "FBSTFCommands.h"

#import "FBApplication.h"
#import "XCUIApplication.h"
#import "FBConfiguration.h"
#import "FBKeyboard.h"
#import "FBRoute.h"
Expand All @@ -18,7 +18,6 @@
#import "FBElementCache.h"
#import "FBErrorBuilder.h"
#import "FBSession.h"
#import "FBApplication.h"
#import "FBMacros.h"
#import "FBMathUtils.h"
#import "FBRuntimeUtils.h"
Expand Down Expand Up @@ -70,7 +69,7 @@ + (NSArray *)routes

+ (id<FBResponsePayload>)handleGetSourceCommand:(FBRouteRequest *)request
{
FBApplication *application = request.session.activeApplication ?: FBApplication.fb_activeApplication;
XCUIApplication *application = request.session.activeApplication ?: XCUIApplication.fb_activeApplication;
NSString *sourceType = request.parameters[@"format"] ?: SOURCE_FORMAT_XML;
NSString *sourceScope = request.parameters[@"scope"];
id result;
Expand Down Expand Up @@ -101,7 +100,7 @@ + (NSArray *)routes

+ (id<FBResponsePayload>)handleTap_stf:(FBRouteRequest *)request
{
XCUIApplication* application = FBApplication.fb_activeApplication;
XCUIApplication* application = XCUIApplication.fb_activeApplication;
CGPoint tapPoint = CGPointMake((CGFloat)[request.arguments[@"x"] doubleValue], (CGFloat)[request.arguments[@"y"] doubleValue]);
NSArray<NSDictionary<NSString *, id> *> *tapGesture =
@[@{
Expand All @@ -112,25 +111,24 @@ + (NSArray *)routes
}
}
];
[application fb_performAppiumTouchActions:tapGesture elementCache:nil error:nil];
//}
[application fb_performW3CActions:tapGesture elementCache:nil error:nil];
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)handlePerformAppiumTouchActions_stf:(FBRouteRequest *)request
{
XCUIApplication *application = [FBApplication fb_activeApplication];
XCUIApplication *application = [XCUIApplication fb_activeApplication];
NSArray *actions = (NSArray *)request.arguments[@"actions"];
NSError *error;
if (![application fb_performAppiumTouchActions:actions elementCache:nil error:&error]) {
if (![application fb_performW3CActions:actions elementCache:nil error:&error]) {
return FBResponseWithUnknownError(error);
}
return FBResponseWithOK();
}

+ (id<FBResponsePayload>)handleDragCoordinate_stf:(FBRouteRequest *)request
{
XCUIApplication* application = FBApplication.fb_activeApplication;
XCUIApplication* application = XCUIApplication.fb_activeApplication;
CGVector startOffset = CGVectorMake([request.arguments[@"fromX"] doubleValue],
[request.arguments[@"fromY"] doubleValue]);
XCUICoordinate *startCoordinate = [self.class gestureCoordinateWithOffset:startOffset
Expand Down Expand Up @@ -172,14 +170,14 @@ + (NSArray *)routes
}

// [FBConfiguration setShouldWaitForQuiescence:[requirements[@"shouldWaitForQuiescence"] boolValue]];
FBApplication *app = [[FBApplication alloc] initPrivateWithPath:appPath bundleID:bundleID];
if (app.fb_state < 2) {
XCUIApplication *app = [[XCUIApplication alloc] initPrivateWithPath:appPath bundleID:bundleID];
if (app.state < 2) {
// app.fb_shouldWaitForQuiescence = FBConfiguration.shouldWaitForQuiescence;
app.launchArguments = (NSArray<NSString *> *)requirements[@"arguments"] ?: @[];
app.launchEnvironment = @{};//(NSDictionary <NSString *, NSString *> *)requirements[@"environment"] ?: @{};
[app launch];
} else {
[app fb_activate];
[app activate];
}
if (app.processID == 0) {
return FBResponseWithUnknownErrorFormat(@"Failed to launch %@ application", bundleID);
Expand All @@ -191,9 +189,9 @@ + (NSArray *)routes
+ (id<FBResponsePayload>)handleAppTerminateWithoutSession:(FBRouteRequest *)request
{
NSString *bundleIdentifier = request.arguments[@"bundleId"];
FBApplication* app = [[FBApplication alloc] initPrivateWithPath:nil bundleID:bundleIdentifier];
XCUIApplication* app = [[XCUIApplication alloc] initPrivateWithPath:nil bundleID:bundleIdentifier];
BOOL result = NO;
if (app.fb_state >= 2) {
if (app.running) {
[app terminate];
result = YES;
}
Expand Down
2 changes: 1 addition & 1 deletion WebDriverAgentLib/Utilities/FBKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "FBKeyboard.h"


#import "FBApplication.h"
#import "XCUIApplication.h"
#import "FBConfiguration.h"
#import "FBXCTestDaemonsProxy.h"
#import "FBErrorBuilder.h"
Expand Down
4 changes: 3 additions & 1 deletion WebDriverAgentLib/Utilities/FBMjpegServer.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
@import UniformTypeIdentifiers;

#import "GCDAsyncSocket.h"
#import "XCUIApplication.h"
#import "FBConfiguration.h"
#import "FBLogger.h"
#import "FBScreenshot.h"
#import "FBImageProcessor.h"
#import "FBImageUtils.h"
#import "XCUIScreen.h"
#import "XCUIApplication+FBHelpers.h"

static const NSTimeInterval SCREENSHOT_TIMEOUT = 0.1;

Expand Down Expand Up @@ -116,7 +118,7 @@ - (void)sendScreenshot:(NSData *)screenshotData {
NSString *chunkHeader = [NSString stringWithFormat:@"--BoundaryString\r\nContent-type: image/jpg\r\nContent-Length: %@\r\n\r\n", @(screenshotData.length)];
if(!self.sendHeader){
@try {
FBApplication *systemApp = FBApplication.fb_activeApplication;
XCUIApplication* systemApp = XCUIApplication.fb_activeApplication;
orientation = systemApp.interfaceOrientation;
}@catch(NSException *e) {
NSLog(@"%@",e);
Expand Down

0 comments on commit 55b1d66

Please sign in to comment.