| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "content/browser/geolocation/fake_access_token_store.h" | 6 #include "content/browser/geolocation/fake_access_token_store.h" |
| 7 #include "content/browser/geolocation/geolocation_observer.h" | 7 #include "content/browser/geolocation/geolocation_observer.h" |
| 8 #include "content/browser/geolocation/location_arbitrator.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" |
| 11 #include "content/public/common/geoposition.h" | 11 #include "content/public/common/geoposition.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using ::testing::NiceMock; | 15 using ::testing::NiceMock; |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 ASSERT_TRUE(position.Validate()); | 54 ASSERT_TRUE(position.Validate()); |
| 55 provider->HandlePositionChanged(position); | 55 provider->HandlePositionChanged(position); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SetReferencePosition(MockLocationProvider* provider) { | 58 void SetReferencePosition(MockLocationProvider* provider) { |
| 59 SetPositionFix(provider, 51.0, -0.1, 400); | 59 SetPositionFix(provider, 51.0, -0.1, 400); |
| 60 } | 60 } |
| 61 | 61 |
| 62 namespace { | 62 namespace { |
| 63 | 63 |
| 64 class TestingGeolocationArbitrator : public GeolocationArbitrator { | 64 class TestingGeolocationArbitrator : public GeolocationArbitratorImpl { |
| 65 public: | 65 public: |
| 66 TestingGeolocationArbitrator( | 66 TestingGeolocationArbitrator( |
| 67 GeolocationObserver* observer, | 67 GeolocationObserver* observer, |
| 68 AccessTokenStore* access_token_store) | 68 AccessTokenStore* access_token_store) |
| 69 : GeolocationArbitrator(observer), | 69 : GeolocationArbitratorImpl(observer), |
| 70 cell_(NULL), | 70 cell_(NULL), |
| 71 gps_(NULL), | 71 gps_(NULL), |
| 72 access_token_store_(access_token_store) { | 72 access_token_store_(access_token_store) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual base::Time GetTimeNow() const OVERRIDE { | 75 virtual base::Time GetTimeNow() const OVERRIDE { |
| 76 return GetTimeNowForTest(); | 76 return GetTimeNowForTest(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual AccessTokenStore* NewAccessTokenStore() OVERRIDE { | 79 virtual AccessTokenStore* NewAccessTokenStore() OVERRIDE { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 Geoposition geoposition = observer_->last_position_; | 123 Geoposition geoposition = observer_->last_position_; |
| 124 EXPECT_TRUE(geoposition.Validate()); | 124 EXPECT_TRUE(geoposition.Validate()); |
| 125 EXPECT_DOUBLE_EQ(latitude, geoposition.latitude); | 125 EXPECT_DOUBLE_EQ(latitude, geoposition.latitude); |
| 126 EXPECT_DOUBLE_EQ(longitude, geoposition.longitude); | 126 EXPECT_DOUBLE_EQ(longitude, geoposition.longitude); |
| 127 EXPECT_DOUBLE_EQ(accuracy, geoposition.accuracy); | 127 EXPECT_DOUBLE_EQ(accuracy, geoposition.accuracy); |
| 128 } | 128 } |
| 129 | 129 |
| 130 base::TimeDelta SwitchOnFreshnessCliff() { | 130 base::TimeDelta SwitchOnFreshnessCliff() { |
| 131 // Add 1, to ensure it meets any greater-than test. | 131 // Add 1, to ensure it meets any greater-than test. |
| 132 return base::TimeDelta::FromMilliseconds( | 132 return base::TimeDelta::FromMilliseconds( |
| 133 GeolocationArbitrator::kFixStaleTimeoutMilliseconds + 1); | 133 GeolocationArbitratorImpl::kFixStaleTimeoutMilliseconds + 1); |
| 134 } | 134 } |
| 135 | 135 |
| 136 MockLocationProvider* cell() { | 136 MockLocationProvider* cell() { |
| 137 return arbitrator_->cell_; | 137 return arbitrator_->cell_; |
| 138 } | 138 } |
| 139 | 139 |
| 140 MockLocationProvider* gps() { | 140 MockLocationProvider* gps() { |
| 141 return arbitrator_->gps_; | 141 return arbitrator_->gps_; |
| 142 } | 142 } |
| 143 | 143 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 CheckLastPositionInfo(3.5657104, 139.690341, 300); | 285 CheckLastPositionInfo(3.5657104, 139.690341, 300); |
| 286 | 286 |
| 287 // 2 minutes later | 287 // 2 minutes later |
| 288 AdvanceTimeNow(base::TimeDelta::FromMinutes(2)); | 288 AdvanceTimeNow(base::TimeDelta::FromMinutes(2)); |
| 289 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell. | 289 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell. |
| 290 SetPositionFix(cell(), 3.5658700, 139.069979, 1000); | 290 SetPositionFix(cell(), 3.5658700, 139.069979, 1000); |
| 291 CheckLastPositionInfo(3.5658700, 139.069979, 1000); | 291 CheckLastPositionInfo(3.5658700, 139.069979, 1000); |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace content | 294 } // namespace content |
| OLD | NEW |