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

Unified Diff: content/browser/geolocation/geolocation_provider_unittest.cc

Issue 10070012: Geolocation support for chromedriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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
« no previous file with comments | « content/browser/geolocation/geolocation_provider.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/geolocation/geolocation_provider_unittest.cc
diff --git a/content/browser/geolocation/geolocation_provider_unittest.cc b/content/browser/geolocation/geolocation_provider_unittest.cc
index 1b131e93d59a11dfc42754b68cebfca15f412196..b99de63bce1eeb5d0c05f58cfb9bf092168c10b4 100644
--- a/content/browser/geolocation/geolocation_provider_unittest.cc
+++ b/content/browser/geolocation/geolocation_provider_unittest.cc
@@ -71,6 +71,12 @@ class NullGeolocationObserver : public GeolocationObserver {
virtual void OnLocationUpdate(const Geoposition& position) {}
};
+class MockGeolocationObserver : public GeolocationObserver {
+ public:
+ // GeolocationObserver
+ MOCK_METHOD1(OnLocationUpdate, void(const Geoposition& position));
+};
+
class StartStopMockLocationProvider : public MockLocationProvider {
public:
explicit StartStopMockLocationProvider(MessageLoop* test_loop)
@@ -179,4 +185,29 @@ TEST_F(GeolocationProviderTest, StartStop) {
GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
}
+TEST_F(GeolocationProviderTest, OverrideLocationForTesting) {
+ scoped_refptr<FakeAccessTokenStore> fake_access_token_store =
+ new FakeAccessTokenStore;
+ scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory =
+ new MockDependencyFactory(&message_loop_, fake_access_token_store.get());
+ MockGeolocationObserver mock_observer;
+ EXPECT_CALL(*(fake_access_token_store.get()), LoadAccessTokens(_));
+
+ GeolocationArbitrator::SetDependencyFactoryForTest(dependency_factory.get());
+
+ Geoposition override_position;
+ override_position.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ provider_->OverrideLocationForTesting(override_position);
+ // Adding an observer when the location is overriden should synchronously
+ // update the observer with our overriden position.
+ EXPECT_CALL(mock_observer, OnLocationUpdate(
+ testing::Field(
+ &Geoposition::error_code,
+ testing::Eq(Geoposition::ERROR_CODE_POSITION_UNAVAILABLE))));
+ provider_->AddObserver(&mock_observer, GeolocationObserverOptions());
+ provider_->RemoveObserver(&mock_observer);
+
+ GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
+}
+
} // namespace
« no previous file with comments | « content/browser/geolocation/geolocation_provider.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698