Index: device/geolocation/fake_location_provider.h |
diff --git a/device/geolocation/fake_location_provider.h b/device/geolocation/fake_location_provider.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..27a4fef78add6e92f7f1ee77c860c54167181eec |
--- /dev/null |
+++ b/device/geolocation/fake_location_provider.h |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2012 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. |
+ |
+#ifndef DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |
+#define DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |
+ |
+#include "base/compiler_specific.h" |
+#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/single_thread_task_runner.h" |
+#include "base/threading/thread.h" |
+#include "device/geolocation/geoposition.h" |
+#include "device/geolocation/location_provider_base.h" |
+ |
+namespace device { |
+ |
+// Fake implementation of a location provider for testing. |
+class FakeLocationProvider : public LocationProviderBase { |
+ public: |
+ enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_ = STOPPED; |
+ |
+ FakeLocationProvider(); |
+ ~FakeLocationProvider() override; |
+ |
+ // Updates listeners with the new position. |
+ void HandlePositionChanged(const Geoposition& position); |
+ |
+ bool get_state() const { return state_; } |
Wez
2016/08/20 01:42:11
|state_| isn't a bool; do you mean:
State get_sta
CJ
2016/08/22 17:56:39
State state(). Done.
|
+ bool get_is_permission_granted() const { return is_permission_granted_; } |
Wez
2016/08/20 01:42:11
Simple getters and setters are named along the lin
CJ
2016/08/22 17:56:39
Done.
|
+ const Geoposition& get_position() const { return position_; } |
Wez
2016/08/20 01:42:11
Isn't this exactly what GetPosition does?
CJ
2016/08/22 17:56:39
Good point.
|
+ |
+ // LocationProvider implementation. |
+ bool StartProvider(bool high_accuracy) override; |
+ void StopProvider() override; |
+ const Geoposition& GetPosition() override; |
+ void OnPermissionGranted() override; |
+ |
+ scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; |
+ |
+ private: |
+ bool is_permission_granted_ = false; |
+ Geoposition position_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FakeLocationProvider); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_GEOLOCATION_FAKE_LOCATION_PROVIDER_H_ |