Skip to content

Commit 6a5c48b

Browse files
fix: Return null if no simulated location has been previously set (#663)
1 parent 309bfc1 commit 6a5c48b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) {
174174
Only works since Xcode 14.3/iOS 16.4
175175
176176
@param error If there is an error, upon return contains an NSError object that describes the problem.
177-
@return The current simulated location or nil in case of failure
177+
@return The current simulated location or nil in case of failure or if no location has previously been seet
178+
(the returned error will be nil in the latter case)
178179
*/
179180
- (nullable CLLocation *)fb_getSimulatedLocation:(NSError **)error;
180181

WebDriverAgentLib/Commands/FBCustomCommands.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,14 @@ + (NSString *)timeZone
503503
{
504504
NSError *error;
505505
CLLocation *location = [XCUIDevice.sharedDevice fb_getSimulatedLocation:&error];
506-
if (nil == location) {
506+
if (nil != error) {
507507
return FBResponseWithStatus([FBCommandStatus unknownErrorWithMessage:error.description
508508
traceback:nil]);
509509
}
510510
return FBResponseWithObject(@{
511-
@"latitude": @(location.coordinate.latitude),
512-
@"longiture": @(location.coordinate.longitude),
513-
@"altitude": @(location.altitude),
511+
@"latitude": location ? @(location.coordinate.latitude) : NSNull.null,
512+
@"longitude": location ? @(location.coordinate.longitude) : NSNull.null,
513+
@"altitude": location ? @(location.altitude) : NSNull.null,
514514
});
515515
}
516516

0 commit comments

Comments
 (0)