Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/browser/geolocation/location_arbitrator_unittest.cc

Issue 10068037: RefCounted types should not have public destructors, content/browser part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MSVC fixes Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/arbitrator_dependency_factory.h" 6 #include "content/browser/geolocation/arbitrator_dependency_factory.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/geolocation_observer.h" 8 #include "content/browser/geolocation/geolocation_observer.h"
9 #include "content/browser/geolocation/location_arbitrator.h" 9 #include "content/browser/geolocation/location_arbitrator.h"
10 #include "content/browser/geolocation/location_provider.h" 10 #include "content/browser/geolocation/location_provider.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 SetPositionFix(provider, 51.0, -0.1, 400); 63 SetPositionFix(provider, 51.0, -0.1, 400);
64 } 64 }
65 65
66 class MockDependencyFactory : public GeolocationArbitratorDependencyFactory { 66 class MockDependencyFactory : public GeolocationArbitratorDependencyFactory {
67 public: 67 public:
68 explicit MockDependencyFactory(AccessTokenStore* access_token_store) 68 explicit MockDependencyFactory(AccessTokenStore* access_token_store)
69 : cell_(NULL), 69 : cell_(NULL),
70 gps_(NULL), 70 gps_(NULL),
71 access_token_store_(access_token_store) { 71 access_token_store_(access_token_store) {
72 } 72 }
73
73 virtual GeolocationArbitrator::GetTimeNow GetTimeFunction() { 74 virtual GeolocationArbitrator::GetTimeNow GetTimeFunction() {
74 return GetTimeNowForTest; 75 return GetTimeNowForTest;
75 } 76 }
77
76 virtual AccessTokenStore* NewAccessTokenStore() { 78 virtual AccessTokenStore* NewAccessTokenStore() {
77 return access_token_store_.get(); 79 return access_token_store_.get();
78 } 80 }
81
79 virtual LocationProviderBase* NewNetworkLocationProvider( 82 virtual LocationProviderBase* NewNetworkLocationProvider(
80 AccessTokenStore* access_token_store, 83 AccessTokenStore* access_token_store,
81 net::URLRequestContextGetter* context, 84 net::URLRequestContextGetter* context,
82 const GURL& url, 85 const GURL& url,
83 const string16& access_token) { 86 const string16& access_token) {
84 return new MockLocationProvider(&cell_); 87 return new MockLocationProvider(&cell_);
85 } 88 }
89
86 virtual LocationProviderBase* NewSystemLocationProvider() { 90 virtual LocationProviderBase* NewSystemLocationProvider() {
87 return new MockLocationProvider(&gps_); 91 return new MockLocationProvider(&gps_);
88 } 92 }
89 93
90 // 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
91 // 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
92 // 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
93 // type). 97 // type).
94 MockLocationProvider* cell_; 98 MockLocationProvider* cell_;
95 MockLocationProvider* gps_; 99 MockLocationProvider* gps_;
96 100
97 scoped_refptr<AccessTokenStore> access_token_store_; 101 scoped_refptr<AccessTokenStore> access_token_store_;
102
103 private:
104 virtual ~MockDependencyFactory() {}
98 }; 105 };
99 106
100 class GeolocationLocationArbitratorTest : public testing::Test { 107 class GeolocationLocationArbitratorTest : public testing::Test {
101 protected: 108 protected:
102 // testing::Test 109 // testing::Test
103 virtual void SetUp() { 110 virtual void SetUp() {
104 access_token_store_ = new NiceMock<FakeAccessTokenStore>; 111 access_token_store_ = new NiceMock<FakeAccessTokenStore>;
105 observer_.reset(new MockLocationObserver); 112 observer_.reset(new MockLocationObserver);
106 dependency_factory_ = new MockDependencyFactory(access_token_store_); 113 dependency_factory_ = new MockDependencyFactory(access_token_store_);
107 GeolocationArbitrator::SetDependencyFactoryForTest( 114 GeolocationArbitrator::SetDependencyFactoryForTest(
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 CheckLastPositionInfo(3.5657104, 139.690341, 300); 287 CheckLastPositionInfo(3.5657104, 139.690341, 300);
281 288
282 // 2 minutes later 289 // 2 minutes later
283 AdvanceTimeNow(base::TimeDelta::FromMinutes(2)); 290 AdvanceTimeNow(base::TimeDelta::FromMinutes(2));
284 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell. 291 // Arrive in station. Cell moves but GPS is stale. Switch to fresher cell.
285 SetPositionFix(cell(), 3.5658700, 139.069979, 1000); 292 SetPositionFix(cell(), 3.5658700, 139.069979, 1000);
286 CheckLastPositionInfo(3.5658700, 139.069979, 1000); 293 CheckLastPositionInfo(3.5658700, 139.069979, 1000);
287 } 294 }
288 295
289 } // namespace 296 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698