summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/geolocation/test_location_manager.mm
blob: eb6633eaf84d124313a21a4fa8bbb16f557887da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/geolocation/test_location_manager.h"

#include "base/mac/scoped_nsobject.h"

@interface TestLocationManager () {
  CLAuthorizationStatus _authorizationStatus;
  base::scoped_nsobject<CLLocation> _currentLocation;
  BOOL _locationServicesEnabled;
  BOOL _started;
  BOOL _stopped;
}

@end

@implementation TestLocationManager

@synthesize authorizationStatus = _authorizationStatus;
@synthesize locationServicesEnabled = _locationServicesEnabled;
@synthesize started = _started;
@synthesize stopped = _stopped;

- (id)init {
  self = [super init];
  if (self) {
    [self reset];
  }
  return self;
}

- (void)setAuthorizationStatus:(CLAuthorizationStatus)authorizationStatus {
  if (_authorizationStatus != authorizationStatus) {
    _authorizationStatus = authorizationStatus;
    [self.delegate locationManagerDidChangeAuthorizationStatus:self];
  }
}

- (CLLocation*)currentLocation {
  return _currentLocation;
}

- (void)setCurrentLocation:(CLLocation*)currentLocation {
  _currentLocation.reset([currentLocation retain]);
}

- (void)reset {
  _authorizationStatus = kCLAuthorizationStatusNotDetermined;
  _currentLocation.reset();
  _locationServicesEnabled = YES;
  _started = NO;
  _stopped = NO;
}

#pragma mark - LocationManager overrides

- (void)startUpdatingLocation {
  _started = YES;
}

- (void)stopUpdatingLocation {
  _stopped = YES;
}

@end