Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: content/browser/geolocation/mock_location_provider.h

Issue 2188933002: Revert of Reland: Geolocation: move from content/browser to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/geolocation/mock_location_provider.h
diff --git a/content/browser/geolocation/mock_location_provider.h b/content/browser/geolocation/mock_location_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c3372e29190d115fdb3ecdb52765edf2948ce31
--- /dev/null
+++ b/content/browser/geolocation/mock_location_provider.h
@@ -0,0 +1,64 @@
+// 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 CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
+#define CONTENT_BROWSER_GEOLOCATION_MOCK_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 "content/browser/geolocation/location_provider_base.h"
+#include "content/public/common/geoposition.h"
+
+namespace content {
+
+// Mock implementation of a location provider for testing.
+class MockLocationProvider : public LocationProviderBase {
+ public:
+ enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_;
+
+ MockLocationProvider();
+ ~MockLocationProvider() override;
+
+ // Updates listeners with the new position.
+ void HandlePositionChanged(const Geoposition& position);
+
+ // LocationProvider implementation.
+ bool StartProvider(bool high_accuracy) override;
+ void StopProvider() override;
+ void GetPosition(Geoposition* position) override;
+ void OnPermissionGranted() override;
+
+ bool is_permission_granted_;
+ Geoposition position_;
+ scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockLocationProvider);
+};
+
+// Factory functions for the various sorts of mock location providers,
+// for use with LocationArbitrator::SetProviderFactoryForTest (i.e.
+// not intended for test code to use to get access to the mock, you can use
+// MockLocationProvider::instance_ for this, or make a custom factory method).
+
+// Creates a mock location provider with no default behavior.
+LocationProvider* NewMockLocationProvider();
+// Creates a mock location provider that automatically notifies its
+// listeners with a valid location when StartProvider is called.
+LocationProvider* NewAutoSuccessMockLocationProvider();
+// Creates a mock location provider that automatically notifies its
+// listeners with an error when StartProvider is called.
+LocationProvider* NewAutoFailMockLocationProvider();
+// Similar to NewAutoSuccessMockLocationProvider but mimicks the behavior of
+// the Network Location provider, in deferring making location updates until
+// a permission request has been confirmed.
+LocationProvider* NewAutoSuccessMockNetworkLocationProvider();
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
« no previous file with comments | « content/browser/geolocation/mock_location_arbitrator.cc ('k') | content/browser/geolocation/mock_location_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698