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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 public: | 66 public: |
67 TestingLocationArbitrator( | 67 TestingLocationArbitrator( |
68 const LocationArbitratorImpl::LocationUpdateCallback& callback, | 68 const LocationArbitratorImpl::LocationUpdateCallback& callback, |
69 AccessTokenStore* access_token_store) | 69 AccessTokenStore* access_token_store) |
70 : LocationArbitratorImpl(callback), | 70 : LocationArbitratorImpl(callback), |
71 cell_(NULL), | 71 cell_(NULL), |
72 gps_(NULL), | 72 gps_(NULL), |
73 access_token_store_(access_token_store) { | 73 access_token_store_(access_token_store) { |
74 } | 74 } |
75 | 75 |
76 virtual base::Time GetTimeNow() const override { | 76 base::Time GetTimeNow() const override { return GetTimeNowForTest(); } |
77 return GetTimeNowForTest(); | |
78 } | |
79 | 77 |
80 virtual AccessTokenStore* NewAccessTokenStore() override { | 78 AccessTokenStore* NewAccessTokenStore() override { |
81 return access_token_store_.get(); | 79 return access_token_store_.get(); |
82 } | 80 } |
83 | 81 |
84 virtual LocationProvider* NewNetworkLocationProvider( | 82 LocationProvider* NewNetworkLocationProvider( |
85 AccessTokenStore* access_token_store, | 83 AccessTokenStore* access_token_store, |
86 net::URLRequestContextGetter* context, | 84 net::URLRequestContextGetter* context, |
87 const GURL& url, | 85 const GURL& url, |
88 const base::string16& access_token) override { | 86 const base::string16& access_token) override { |
89 return new MockLocationProvider(&cell_); | 87 return new MockLocationProvider(&cell_); |
90 } | 88 } |
91 | 89 |
92 virtual LocationProvider* NewSystemLocationProvider() override { | 90 LocationProvider* NewSystemLocationProvider() override { |
93 return new MockLocationProvider(&gps_); | 91 return new MockLocationProvider(&gps_); |
94 } | 92 } |
95 | 93 |
96 // Two location providers, with nice short names to make the tests more | 94 // Two location providers, with nice short names to make the tests more |
97 // readable. Note |gps_| will only be set when there is a high accuracy | 95 // readable. Note |gps_| will only be set when there is a high accuracy |
98 // observer registered (and |cell_| when there's at least one observer of any | 96 // observer registered (and |cell_| when there's at least one observer of any |
99 // type). | 97 // type). |
100 MockLocationProvider* cell_; | 98 MockLocationProvider* cell_; |
101 MockLocationProvider* gps_; | 99 MockLocationProvider* gps_; |
102 scoped_refptr<AccessTokenStore> access_token_store_; | 100 scoped_refptr<AccessTokenStore> access_token_store_; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 319 |
322 // Update with a less accurate position to verify 240956. | 320 // Update with a less accurate position to verify 240956. |
323 SetPositionFix(cell(), 3, 139, 150); | 321 SetPositionFix(cell(), 3, 139, 150); |
324 CheckLastPositionInfo(3, 139, 150); | 322 CheckLastPositionInfo(3, 139, 150); |
325 | 323 |
326 // No delete required for fakeMockProvider. It points to fakeProvider. | 324 // No delete required for fakeMockProvider. It points to fakeProvider. |
327 delete fakeProvider; | 325 delete fakeProvider; |
328 } | 326 } |
329 | 327 |
330 } // namespace content | 328 } // namespace content |
OLD | NEW |