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/mock_location_provider.h" | 9 #include "content/browser/geolocation/mock_location_provider.h" |
10 #include "content/public/common/geoposition.h" | 10 #include "content/public/common/geoposition.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 MockLocationProvider* cell_; | 98 MockLocationProvider* cell_; |
99 MockLocationProvider* gps_; | 99 MockLocationProvider* gps_; |
100 scoped_refptr<AccessTokenStore> access_token_store_; | 100 scoped_refptr<AccessTokenStore> access_token_store_; |
101 }; | 101 }; |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 class GeolocationLocationArbitratorTest : public testing::Test { | 105 class GeolocationLocationArbitratorTest : public testing::Test { |
106 protected: | 106 protected: |
107 // testing::Test | 107 // testing::Test |
108 virtual void SetUp() { | 108 void SetUp() override { |
109 access_token_store_ = new NiceMock<FakeAccessTokenStore>; | 109 access_token_store_ = new NiceMock<FakeAccessTokenStore>; |
110 observer_.reset(new MockLocationObserver); | 110 observer_.reset(new MockLocationObserver); |
111 LocationArbitratorImpl::LocationUpdateCallback callback = | 111 LocationArbitratorImpl::LocationUpdateCallback callback = |
112 base::Bind(&MockLocationObserver::OnLocationUpdate, | 112 base::Bind(&MockLocationObserver::OnLocationUpdate, |
113 base::Unretained(observer_.get())); | 113 base::Unretained(observer_.get())); |
114 arbitrator_.reset(new TestingLocationArbitrator( | 114 arbitrator_.reset(new TestingLocationArbitrator( |
115 callback, access_token_store_.get())); | 115 callback, access_token_store_.get())); |
116 } | 116 } |
117 | 117 |
118 // testing::Test | 118 // testing::Test |
119 virtual void TearDown() { | 119 void TearDown() override {} |
120 } | |
121 | 120 |
122 void CheckLastPositionInfo(double latitude, | 121 void CheckLastPositionInfo(double latitude, |
123 double longitude, | 122 double longitude, |
124 double accuracy) { | 123 double accuracy) { |
125 Geoposition geoposition = observer_->last_position_; | 124 Geoposition geoposition = observer_->last_position_; |
126 EXPECT_TRUE(geoposition.Validate()); | 125 EXPECT_TRUE(geoposition.Validate()); |
127 EXPECT_DOUBLE_EQ(latitude, geoposition.latitude); | 126 EXPECT_DOUBLE_EQ(latitude, geoposition.latitude); |
128 EXPECT_DOUBLE_EQ(longitude, geoposition.longitude); | 127 EXPECT_DOUBLE_EQ(longitude, geoposition.longitude); |
129 EXPECT_DOUBLE_EQ(accuracy, geoposition.accuracy); | 128 EXPECT_DOUBLE_EQ(accuracy, geoposition.accuracy); |
130 } | 129 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 318 |
320 // Update with a less accurate position to verify 240956. | 319 // Update with a less accurate position to verify 240956. |
321 SetPositionFix(cell(), 3, 139, 150); | 320 SetPositionFix(cell(), 3, 139, 150); |
322 CheckLastPositionInfo(3, 139, 150); | 321 CheckLastPositionInfo(3, 139, 150); |
323 | 322 |
324 // No delete required for fakeMockProvider. It points to fakeProvider. | 323 // No delete required for fakeMockProvider. It points to fakeProvider. |
325 delete fakeProvider; | 324 delete fakeProvider; |
326 } | 325 } |
327 | 326 |
328 } // namespace content | 327 } // namespace content |
OLD | NEW |