| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "content/browser/geolocation/fake_access_token_store.h" | 7 #include "content/browser/geolocation/fake_access_token_store.h" |
| 8 #include "content/browser/geolocation/location_arbitrator_impl.h" | 8 #include "content/browser/geolocation/location_arbitrator_impl.h" |
| 9 #include "content/browser/geolocation/location_provider.h" | 9 #include "content/browser/geolocation/location_provider.h" |
| 10 #include "content/browser/geolocation/mock_location_provider.h" | 10 #include "content/browser/geolocation/mock_location_provider.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return arbitrator_->gps_; | 146 return arbitrator_->gps_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 scoped_refptr<FakeAccessTokenStore> access_token_store_; | 149 scoped_refptr<FakeAccessTokenStore> access_token_store_; |
| 150 scoped_ptr<MockLocationObserver> observer_; | 150 scoped_ptr<MockLocationObserver> observer_; |
| 151 scoped_ptr<TestingGeolocationArbitrator> arbitrator_; | 151 scoped_ptr<TestingGeolocationArbitrator> arbitrator_; |
| 152 base::MessageLoop loop_; | 152 base::MessageLoop loop_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 TEST_F(GeolocationLocationArbitratorTest, CreateDestroy) { | 155 TEST_F(GeolocationLocationArbitratorTest, CreateDestroy) { |
| 156 EXPECT_TRUE(access_token_store_); | 156 EXPECT_TRUE(access_token_store_.get()); |
| 157 EXPECT_TRUE(arbitrator_ != NULL); | 157 EXPECT_TRUE(arbitrator_ != NULL); |
| 158 arbitrator_.reset(); | 158 arbitrator_.reset(); |
| 159 SUCCEED(); | 159 SUCCEED(); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST_F(GeolocationLocationArbitratorTest, OnPermissionGranted) { | 162 TEST_F(GeolocationLocationArbitratorTest, OnPermissionGranted) { |
| 163 EXPECT_FALSE(arbitrator_->HasPermissionBeenGranted()); | 163 EXPECT_FALSE(arbitrator_->HasPermissionBeenGranted()); |
| 164 arbitrator_->OnPermissionGranted(); | 164 arbitrator_->OnPermissionGranted(); |
| 165 EXPECT_TRUE(arbitrator_->HasPermissionBeenGranted()); | 165 EXPECT_TRUE(arbitrator_->HasPermissionBeenGranted()); |
| 166 // Can't check the provider has been notified without going through the | 166 // Can't check the provider has been notified without going through the |
| 167 // motions to create the provider (see next test). | 167 // motions to create the provider (see next test). |
| 168 EXPECT_FALSE(cell()); | 168 EXPECT_FALSE(cell()); |
| 169 EXPECT_FALSE(gps()); | 169 EXPECT_FALSE(gps()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 TEST_F(GeolocationLocationArbitratorTest, NormalUsage) { | 172 TEST_F(GeolocationLocationArbitratorTest, NormalUsage) { |
| 173 ASSERT_TRUE(access_token_store_); | 173 ASSERT_TRUE(access_token_store_.get()); |
| 174 ASSERT_TRUE(arbitrator_ != NULL); | 174 ASSERT_TRUE(arbitrator_ != NULL); |
| 175 | 175 |
| 176 EXPECT_FALSE(cell()); | 176 EXPECT_FALSE(cell()); |
| 177 EXPECT_FALSE(gps()); | 177 EXPECT_FALSE(gps()); |
| 178 arbitrator_->StartProviders(false); | 178 arbitrator_->StartProviders(false); |
| 179 | 179 |
| 180 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); | 180 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); |
| 181 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); | 181 EXPECT_TRUE(access_token_store_->access_token_set_.empty()); |
| 182 | 182 |
| 183 access_token_store_->NotifyDelegateTokensLoaded(); | 183 access_token_store_->NotifyDelegateTokensLoaded(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 CheckLastPositionInfo(3.5657104, 139.690341, 300); | 290 CheckLastPositionInfo(3.5657104, 139.690341, 300); |
| 291 | 291 |
| 292 // 2 minutes later | 292 // 2 minutes later |
| 293 AdvanceTimeNow(base::TimeDelta::FromMinutes(2)); | 293 AdvanceTimeNow(base::TimeDelta::FromMinutes(2)); |
| 294 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell. | 294 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell. |
| 295 SetPositionFix(cell(), 3.5658700, 139.069979, 1000); | 295 SetPositionFix(cell(), 3.5658700, 139.069979, 1000); |
| 296 CheckLastPositionInfo(3.5658700, 139.069979, 1000); | 296 CheckLastPositionInfo(3.5658700, 139.069979, 1000); |
| 297 } | 297 } |
| 298 | 298 |
| 299 } // namespace content | 299 } // namespace content |
| OLD | NEW |