Chromium Code Reviews| 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. |