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

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

Issue 2028823002: Refactor to make BlimpLocationProvider accessible to content layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Makes testing override location provider accessible Created 4 years, 6 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/location_arbitrator_impl_unittest.cc
diff --git a/content/browser/geolocation/location_arbitrator_impl_unittest.cc b/content/browser/geolocation/location_arbitrator_impl_unittest.cc
index 93b1645b65aed37fc912f56497b2177aa805be65..c22b4496ca705b0a952a9654be5ff5b090930b2a 100644
--- a/content/browser/geolocation/location_arbitrator_impl_unittest.cc
+++ b/content/browser/geolocation/location_arbitrator_impl_unittest.cc
@@ -72,6 +72,7 @@ class TestingLocationArbitrator : public LocationArbitratorImpl {
: LocationArbitratorImpl(callback),
cell_(NULL),
gps_(NULL),
+ override_(NULL),
Kevin M 2016/06/08 20:47:25 nit: use nullptr instead of NULL now, and you can
CJ 2016/06/09 01:02:18 Done.
access_token_store_(access_token_store) {
}
@@ -93,12 +94,21 @@ class TestingLocationArbitrator : public LocationArbitratorImpl {
return new MockLocationProvider(&gps_);
}
- // Two location providers, with nice short names to make the tests more
+ LocationProvider* GetOverrideSystemLocationProvider() override {
+ if (use_override_) {
+ return new MockLocationProvider(&override_);
+ }
+ return nullptr;
+ }
+
+ // Three location providers, with nice short names to make the tests more
// readable. Note |gps_| will only be set when there is a high accuracy
// observer registered (and |cell_| when there's at least one observer of any
- // type).
+ // type). |override_| will be included only if use_network is false.
MockLocationProvider* cell_;
MockLocationProvider* gps_;
+ MockLocationProvider* override_;
+ bool use_override_ = false;
scoped_refptr<AccessTokenStore> access_token_store_;
};
@@ -144,6 +154,10 @@ class GeolocationLocationArbitratorTest : public testing::Test {
return arbitrator_->gps_;
}
+ MockLocationProvider* overrider() {
Kevin M 2016/06/08 20:47:25 "override"?
CJ 2016/06/09 01:02:18 Not sure if I was allowed to use it since override
+ return arbitrator_->override_;
+ }
+
scoped_refptr<FakeAccessTokenStore> access_token_store_;
std::unique_ptr<MockLocationObserver> observer_;
std::unique_ptr<TestingLocationArbitrator> arbitrator_;
@@ -173,7 +187,7 @@ TEST_F(GeolocationLocationArbitratorTest, NormalUsage) {
EXPECT_FALSE(cell());
EXPECT_FALSE(gps());
- arbitrator_->StartProviders(false);
+ arbitrator_->StartProviders(false, true);
EXPECT_TRUE(access_token_store_->access_token_map_.empty());
EXPECT_TRUE(access_token_store_->access_token_map_.empty());
@@ -203,7 +217,7 @@ TEST_F(GeolocationLocationArbitratorTest, NormalUsage) {
}
TEST_F(GeolocationLocationArbitratorTest, SetObserverOptions) {
- arbitrator_->StartProviders(false);
+ arbitrator_->StartProviders(false, true);
access_token_store_->NotifyDelegateTokensLoaded();
ASSERT_TRUE(cell());
ASSERT_TRUE(gps());
@@ -212,13 +226,13 @@ TEST_F(GeolocationLocationArbitratorTest, SetObserverOptions) {
SetReferencePosition(cell());
EXPECT_EQ(MockLocationProvider::LOW_ACCURACY, cell()->state_);
EXPECT_EQ(MockLocationProvider::LOW_ACCURACY, gps()->state_);
- arbitrator_->StartProviders(true);
+ arbitrator_->StartProviders(true, true);
EXPECT_EQ(MockLocationProvider::HIGH_ACCURACY, cell()->state_);
EXPECT_EQ(MockLocationProvider::HIGH_ACCURACY, gps()->state_);
}
TEST_F(GeolocationLocationArbitratorTest, Arbitration) {
- arbitrator_->StartProviders(false);
+ arbitrator_->StartProviders(false, true);
access_token_store_->NotifyDelegateTokensLoaded();
ASSERT_TRUE(cell());
ASSERT_TRUE(gps());
@@ -294,7 +308,7 @@ TEST_F(GeolocationLocationArbitratorTest, Arbitration) {
}
TEST_F(GeolocationLocationArbitratorTest, TwoOneShotsIsNewPositionBetter) {
- arbitrator_->StartProviders(false);
+ arbitrator_->StartProviders(false, true);
access_token_store_->NotifyDelegateTokensLoaded();
ASSERT_TRUE(cell());
ASSERT_TRUE(gps());
@@ -312,7 +326,7 @@ TEST_F(GeolocationLocationArbitratorTest, TwoOneShotsIsNewPositionBetter) {
LocationProvider* fakeProvider =
new MockLocationProvider(&fakeMockProvider);
- arbitrator_->StartProviders(false);
+ arbitrator_->StartProviders(false, true);
access_token_store_->NotifyDelegateTokensLoaded();
// Advance the time a short while to simulate successive calls.

Powered by Google App Engine
This is Rietveld 408576698