Skip to content

Commit

Permalink
add ScreenSize
Browse files Browse the repository at this point in the history
  • Loading branch information
林名君 committed Nov 5, 2018
1 parent 17b3ca3 commit 85f450e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#import "XCUIDevice.h"
#import "XCUIDevice+FBHealthCheck.h"
#import "XCUIDevice+FBHelpers.h"
#import "FBMathUtils.h"
#import "FBMacros.h"
#import "XCUIElement+FBWebDriverAttributes.h"

@implementation FBSessionCommands

Expand Down Expand Up @@ -145,6 +148,7 @@ + (NSArray *)routes

+ (id<FBResponsePayload>)handleGetStatus:(FBRouteRequest *)request
{
FBApplication *application = FBApplication.fb_activeApplication;
// For updatedWDABundleId capability by Appium
NSString *productBundleIdentifier = @"com.facebook.WebDriverAgentRunner";
NSString *envproductBundleIdentifier = NSProcessInfo.processInfo.environment[@"WDA_PRODUCT_BUNDLE_IDENTIFIER"];
Expand All @@ -160,6 +164,10 @@ + (NSArray *)routes
if (nil != upgradeTimestamp && upgradeTimestamp.length > 0) {
[buildInfo setObject:upgradeTimestamp forKey:@"upgradedAt"];
}

CGRect frame = application.wdFrame;
CGSize screenSize = FBAdjustDimensionsForApplication(frame.size, application.interfaceOrientation);
[FBConfiguration setScreenSize:screenSize];

return
FBResponseWithStatus(
Expand All @@ -172,6 +180,10 @@ + (NSArray *)routes
@"version" : [[UIDevice currentDevice] systemVersion],
@"sdkVersion": FBSDKVersion() ?: @"unknown",
},
@"size" : @{
@"width": @(screenSize.width),
@"height": @(screenSize.height),
},
@"ios" :
@{
@"simulatorVersion" : [[UIDevice currentDevice] systemVersion],
Expand Down
4 changes: 4 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -63,6 +64,9 @@ NS_ASSUME_NONNULL_BEGIN

+ (BOOL)shouldLoadSnapshotWithAttributes;

+ (void)setScreenSize:(CGSize)screenSize;
+ (CGSize)screenSize;

@end

NS_ASSUME_NONNULL_END
20 changes: 20 additions & 0 deletions WebDriverAgentLib/Utilities/FBConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#import "FBXCodeCompatibility.h"
#import "XCTestPrivateSymbols.h"
#import "XCElementSnapshot.h"
#import "FBMathUtils.h"
#import "FBMacros.h"
#import "XCUIElement+FBWebDriverAttributes.h"

static NSUInteger const DefaultStartingPort = 8100;
static NSUInteger const DefaultMjpegServerPort = 9100;
Expand All @@ -27,6 +30,8 @@
static NSString *FBElementResponseAttributes = @"type,label";
static NSUInteger FBMaxTypingFrequency = 60;

static CGSize ScreenSize;

@implementation FBConfiguration

#pragma mark Public
Expand Down Expand Up @@ -137,6 +142,21 @@ + (void)setShouldWaitForQuiescence:(BOOL)value
FBShouldWaitForQuiescence = value;
}

+ (void)setScreenSize:(CGSize)screenSize {
ScreenSize = screenSize;
}

+ (CGSize)screenSize {
if (CGSizeEqualToSize(CGSizeZero, ScreenSize)) {
FBApplication *application = FBApplication.fb_activeApplication;
CGRect frame = application.wdFrame;
ScreenSize = FBAdjustDimensionsForApplication(frame.size, application.interfaceOrientation);
return ScreenSize;
}
return ScreenSize;

}

#pragma mark Private

+ (NSRange)bindingPortRangeFromArguments
Expand Down

0 comments on commit 85f450e

Please sign in to comment.