| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/geolocation/test_location_manager.h" | 5 #import "ios/chrome/browser/geolocation/test_location_manager.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 8 #error "This file requires ARC support." |
| 9 #endif |
| 8 | 10 |
| 9 @interface TestLocationManager () { | 11 @interface TestLocationManager () |
| 10 CLAuthorizationStatus _authorizationStatus; | |
| 11 base::scoped_nsobject<CLLocation> _currentLocation; | |
| 12 BOOL _locationServicesEnabled; | |
| 13 BOOL _started; | |
| 14 BOOL _stopped; | |
| 15 } | |
| 16 | 12 |
| 17 @end | 13 @end |
| 18 | 14 |
| 19 @implementation TestLocationManager | 15 @implementation TestLocationManager |
| 20 | |
| 21 @synthesize authorizationStatus = _authorizationStatus; | 16 @synthesize authorizationStatus = _authorizationStatus; |
| 22 @synthesize locationServicesEnabled = _locationServicesEnabled; | 17 @synthesize locationServicesEnabled = _locationServicesEnabled; |
| 23 @synthesize started = _started; | 18 @synthesize started = _started; |
| 24 @synthesize stopped = _stopped; | 19 @synthesize stopped = _stopped; |
| 20 @synthesize currentLocation = _currentLocation; |
| 25 | 21 |
| 26 - (id)init { | 22 - (id)init { |
| 27 self = [super init]; | 23 self = [super init]; |
| 28 if (self) { | 24 if (self) { |
| 29 [self reset]; | 25 [self reset]; |
| 30 } | 26 } |
| 31 return self; | 27 return self; |
| 32 } | 28 } |
| 33 | 29 |
| 34 - (void)setAuthorizationStatus:(CLAuthorizationStatus)authorizationStatus { | 30 - (void)setAuthorizationStatus:(CLAuthorizationStatus)authorizationStatus { |
| 35 if (_authorizationStatus != authorizationStatus) { | 31 if (_authorizationStatus != authorizationStatus) { |
| 36 _authorizationStatus = authorizationStatus; | 32 _authorizationStatus = authorizationStatus; |
| 37 [self.delegate locationManagerDidChangeAuthorizationStatus:self]; | 33 [self.delegate locationManagerDidChangeAuthorizationStatus:self]; |
| 38 } | 34 } |
| 39 } | 35 } |
| 40 | 36 |
| 41 - (CLLocation*)currentLocation { | |
| 42 return _currentLocation; | |
| 43 } | |
| 44 | |
| 45 - (void)setCurrentLocation:(CLLocation*)currentLocation { | |
| 46 _currentLocation.reset([currentLocation retain]); | |
| 47 } | |
| 48 | |
| 49 - (void)reset { | 37 - (void)reset { |
| 50 _authorizationStatus = kCLAuthorizationStatusNotDetermined; | 38 _authorizationStatus = kCLAuthorizationStatusNotDetermined; |
| 51 _currentLocation.reset(); | 39 _currentLocation = nil; |
| 52 _locationServicesEnabled = YES; | 40 _locationServicesEnabled = YES; |
| 53 _started = NO; | 41 _started = NO; |
| 54 _stopped = NO; | 42 _stopped = NO; |
| 55 } | 43 } |
| 56 | 44 |
| 57 #pragma mark - LocationManager overrides | 45 #pragma mark - LocationManager overrides |
| 58 | 46 |
| 59 - (void)startUpdatingLocation { | 47 - (void)startUpdatingLocation { |
| 60 _started = YES; | 48 _started = YES; |
| 61 } | 49 } |
| 62 | 50 |
| 63 - (void)stopUpdatingLocation { | 51 - (void)stopUpdatingLocation { |
| 64 _stopped = YES; | 52 _stopped = YES; |
| 65 } | 53 } |
| 66 | 54 |
| 67 @end | 55 @end |
| OLD | NEW |