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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 SetPositionFix(gps(), 3.5657104, 139.690341, 300); | 289 SetPositionFix(gps(), 3.5657104, 139.690341, 300); |
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 TEST_F(GeolocationLocationArbitratorTest, TwoOneShotsIsNewPositionBetter) { |
| 300 arbitrator_->StartProviders(false); |
| 301 access_token_store_->NotifyDelegateTokensLoaded(); |
| 302 ASSERT_TRUE(cell()); |
| 303 ASSERT_TRUE(gps()); |
| 304 |
| 305 // Set the initial position. |
| 306 SetPositionFix(cell(), 3, 139, 100); |
| 307 CheckLastPositionInfo(3, 139, 100); |
| 308 |
| 309 // Restart providers to simulate a one-shot request. |
| 310 arbitrator_->StopProviders(); |
| 311 |
| 312 // To test 240956, perform a throwaway alloc. |
| 313 // This convinces the allocator to put the providers in a new memory location. |
| 314 MockLocationProvider* fakeMockProvider = NULL; |
| 315 LocationProviderBase* fakeProvider = |
| 316 new MockLocationProvider(&fakeMockProvider); |
| 317 |
| 318 arbitrator_->StartProviders(false); |
| 319 access_token_store_->NotifyDelegateTokensLoaded(); |
| 320 |
| 321 // Advance the time a short while to simulate successive calls. |
| 322 AdvanceTimeNow(base::TimeDelta::FromMilliseconds(5)); |
| 323 |
| 324 // Update with a less accurate position to verify 240956. |
| 325 SetPositionFix(cell(), 3, 139, 150); |
| 326 CheckLastPositionInfo(3, 139, 150); |
| 327 |
| 328 // No delete required for fakeMockProvider. It points to fakeProvider. |
| 329 delete fakeProvider; |
| 330 } |
| 331 |
299 } // namespace content | 332 } // namespace content |
OLD | NEW |