Skip to content

Commit

Permalink
fix: Return null if no simulated location has been previously set (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Feb 20, 2023
1 parent 309bfc1 commit 6a5c48b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) {
Only works since Xcode 14.3/iOS 16.4
@param error If there is an error, upon return contains an NSError object that describes the problem.
@return The current simulated location or nil in case of failure
@return The current simulated location or nil in case of failure or if no location has previously been seet
(the returned error will be nil in the latter case)
*/
- (nullable CLLocation *)fb_getSimulatedLocation:(NSError **)error;

Expand Down
8 changes: 4 additions & 4 deletions WebDriverAgentLib/Commands/FBCustomCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,14 @@ + (NSString *)timeZone
{
NSError *error;
CLLocation *location = [XCUIDevice.sharedDevice fb_getSimulatedLocation:&error];
if (nil == location) {
if (nil != error) {
return FBResponseWithStatus([FBCommandStatus unknownErrorWithMessage:error.description
traceback:nil]);
}
return FBResponseWithObject(@{
@"latitude": @(location.coordinate.latitude),
@"longiture": @(location.coordinate.longitude),
@"altitude": @(location.altitude),
@"latitude": location ? @(location.coordinate.latitude) : NSNull.null,
@"longitude": location ? @(location.coordinate.longitude) : NSNull.null,
@"altitude": location ? @(location.altitude) : NSNull.null,
});
}

Expand Down

0 comments on commit 6a5c48b

Please sign in to comment.