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

chore: tweak device in currentCapabilities #773

Merged
merged 4 commits into from
Sep 22, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ + (NSArray *)routes
#endif
@"ip" : [XCUIDevice sharedDevice].fb_wifiIPAddress ?: [NSNull null]
},
@"build" : buildInfo.copy
@"build" : buildInfo.copy,
@"device": [self.class deviceName:[UIDevice currentDevice].userInterfaceIdiom]
}
);
}
Expand Down Expand Up @@ -418,12 +419,29 @@ + (NSDictionary *)sessionInformation
};
}

/*
Return the device kind as lower case
*/
+ (NSString *)deviceName:(UIUserInterfaceIdiom) userInterfaceIdiom

Choose a reason for hiding this comment

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

deviceNameByUserInterfaceIdiom:(UIUserInterfaceIdiom) userInterfaceIdiom

{
if (userInterfaceIdiom == UIUserInterfaceIdiomPad) {
return @"ipad";
} else if (userInterfaceIdiom == UIUserInterfaceIdiomTV) {
return @"apple tv";
} else if (userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
return @"iphone";
}
// CarPlay, Mac, Vision UI or unknown are possible
return @"Unknown";

}

+ (NSDictionary *)currentCapabilities
{
FBApplication *application = [FBSession activeSession].activeApplication;
return
@{
@"device": ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? @"ipad" : @"iphone",
@"device": [self.class deviceName:[UIDevice currentDevice].userInterfaceIdiom],
@"sdkVersion": [[UIDevice currentDevice] systemVersion],
@"browserName": application.label ?: [NSNull null],
@"CFBundleIdentifier": application.bundleID ?: [NSNull null],
Expand Down
Loading