OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 5 #ifndef DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |
6 #define DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 6 #define DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
13 #include "device/geolocation/geoposition.h" | 13 #include "device/geolocation/geoposition.h" |
14 #include "device/geolocation/location_provider_base.h" | 14 #include "device/geolocation/location_provider_base.h" |
15 | 15 |
16 namespace device { | 16 namespace device { |
17 | 17 |
18 // Mock implementation of a location provider for testing. | 18 // Fake implementation of a location provider for testing. |
19 class MockLocationProvider : public LocationProviderBase { | 19 class FakeLocationProvider : public LocationProviderBase { |
20 public: | 20 public: |
21 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; | 21 enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; |
22 | 22 |
23 MockLocationProvider(); | 23 FakeLocationProvider(); |
24 ~MockLocationProvider() override; | 24 ~FakeLocationProvider() override; |
25 | 25 |
26 // Updates listeners with the new position. | 26 // Updates listeners with the new position. |
27 void HandlePositionChanged(const Geoposition& position); | 27 void HandlePositionChanged(const Geoposition& position); |
28 | 28 |
29 // LocationProvider implementation. | 29 // LocationProvider implementation. |
30 bool StartProvider(bool high_accuracy) override; | 30 bool StartProvider(bool high_accuracy) override; |
31 void StopProvider() override; | 31 void StopProvider() override; |
32 void GetPosition(Geoposition* position) override; | 32 void GetPosition(Geoposition* position) override; |
33 void OnPermissionGranted() override; | 33 void OnPermissionGranted() override; |
34 | 34 |
35 bool is_permission_granted_; | 35 bool is_permission_granted_; |
36 Geoposition position_; | 36 Geoposition position_; |
37 scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; | 37 scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; |
38 | 38 |
39 private: | 39 private: |
40 DISALLOW_COPY_AND_ASSIGN(MockLocationProvider); | 40 DISALLOW_COPY_AND_ASSIGN(FakeLocationProvider); |
41 }; | 41 }; |
42 | 42 |
43 // Factory functions for the various sorts of mock location providers, | 43 // Factory functions for the various sorts of mock location providers, |
44 // for use with LocationArbitrator::SetProviderFactoryForTest (i.e. | 44 // for use with LocationArbitrator::SetProviderFactoryForTest (i.e. |
45 // not intended for test code to use to get access to the mock, you can use | 45 // not intended for test code to use to get access to the mock, you can use |
46 // MockLocationProvider::instance_ for this, or make a custom factory method). | 46 // FakeLocationProvider::instance_ for this, or make a custom factory method). |
47 | 47 |
48 // Creates a mock location provider with no default behavior. | 48 // Creates a mock location provider with no default behavior. |
49 LocationProvider* NewMockLocationProvider(); | 49 LocationProvider* NewFakeLocationProvider(); |
50 // Creates a mock location provider that automatically notifies its | 50 // Creates a mock location provider that automatically notifies its |
51 // listeners with a valid location when StartProvider is called. | 51 // listeners with a valid location when StartProvider is called. |
52 LocationProvider* NewAutoSuccessMockLocationProvider(); | 52 LocationProvider* NewAutoSuccessFakeLocationProvider(); |
53 // Creates a mock location provider that automatically notifies its | 53 // Creates a mock location provider that automatically notifies its |
54 // listeners with an error when StartProvider is called. | 54 // listeners with an error when StartProvider is called. |
55 LocationProvider* NewAutoFailMockLocationProvider(); | 55 LocationProvider* NewAutoFailFakeLocationProvider(); |
56 // Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of | 56 // Similar to NewAutoSuccessFakeLocationProvider but mimicks the behavior of |
57 // the Network Location provider, in deferring making location updates until | 57 // the Network Location provider, in deferring making location updates until |
58 // a permission request has been confirmed. | 58 // a permission request has been confirmed. |
59 LocationProvider* NewAutoSuccessMockNetworkLocationProvider(); | 59 LocationProvider* NewAutoSuccessFakeNetworkLocationProvider(); |
60 | 60 |
61 } // namespace device | 61 } // namespace device |
62 | 62 |
63 #endif // DEVICE_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_ | 63 #endif // DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |
OLD | NEW |