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

Side by Side Diff: chrome/browser/invalidation/ticl_invalidation_service_unittest.cc

Issue 286213003: Make GCMProfileService own GCMDriver, instead of deriving from it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/invalidation/ticl_invalidation_service.h" 5 #include "chrome/browser/invalidation/ticl_invalidation_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h" 10 #include "chrome/browser/invalidation/gcm_invalidation_bridge.h"
(...skipping 19 matching lines...) Expand all
30 30
31 // TiclSettingsProvider: 31 // TiclSettingsProvider:
32 virtual bool UseGCMChannel() const OVERRIDE; 32 virtual bool UseGCMChannel() const OVERRIDE;
33 33
34 private: 34 private:
35 DISALLOW_COPY_AND_ASSIGN(FakeTiclSettingsProvider); 35 DISALLOW_COPY_AND_ASSIGN(FakeTiclSettingsProvider);
36 }; 36 };
37 37
38 class FakeGCMDriver : public gcm::GCMDriver { 38 class FakeGCMDriver : public gcm::GCMDriver {
39 public: 39 public:
40 explicit FakeGCMDriver(OAuth2TokenService* token_service); 40 FakeGCMDriver();
41 virtual ~FakeGCMDriver(); 41 virtual ~FakeGCMDriver();
42 42
43 protected:
44 // gcm::GCMDriver:
45 virtual bool ShouldStartAutomatically() const OVERRIDE;
46 virtual base::FilePath GetStorePath() const OVERRIDE;
47 virtual scoped_refptr<net::URLRequestContextGetter>
48 GetURLRequestContextGetter() const OVERRIDE;
49
50 private: 43 private:
51 DISALLOW_COPY_AND_ASSIGN(FakeGCMDriver); 44 DISALLOW_COPY_AND_ASSIGN(FakeGCMDriver);
52 }; 45 };
53 46
54 FakeTiclSettingsProvider::FakeTiclSettingsProvider() { 47 FakeTiclSettingsProvider::FakeTiclSettingsProvider() {
55 } 48 }
56 49
57 FakeTiclSettingsProvider::~FakeTiclSettingsProvider() { 50 FakeTiclSettingsProvider::~FakeTiclSettingsProvider() {
58 } 51 }
59 52
60 bool FakeTiclSettingsProvider::UseGCMChannel() const { 53 bool FakeTiclSettingsProvider::UseGCMChannel() const {
61 return false; 54 return false;
62 } 55 }
63 56
64 FakeGCMDriver::FakeGCMDriver(OAuth2TokenService* token_service) 57 FakeGCMDriver::FakeGCMDriver() {
65 : GCMDriver(scoped_ptr<IdentityProvider>(
66 new FakeIdentityProvider(token_service))) {
67 } 58 }
68 59
69 FakeGCMDriver::~FakeGCMDriver() { 60 FakeGCMDriver::~FakeGCMDriver() {
70 } 61 }
71 62
72 bool FakeGCMDriver::ShouldStartAutomatically() const {
73 return false;
74 }
75
76 base::FilePath FakeGCMDriver::GetStorePath() const {
77 return base::FilePath();
78 }
79
80 scoped_refptr<net::URLRequestContextGetter>
81 FakeGCMDriver::GetURLRequestContextGetter() const {
82 return NULL;
83 }
84
85 } // namespace 63 } // namespace
86 64
87 class TiclInvalidationServiceTestDelegate { 65 class TiclInvalidationServiceTestDelegate {
88 public: 66 public:
89 TiclInvalidationServiceTestDelegate() {} 67 TiclInvalidationServiceTestDelegate() {}
90 68
91 ~TiclInvalidationServiceTestDelegate() { 69 ~TiclInvalidationServiceTestDelegate() {
92 DestroyInvalidationService(); 70 DestroyInvalidationService();
93 } 71 }
94 72
95 void CreateInvalidationService() { 73 void CreateInvalidationService() {
96 CreateUninitializedInvalidationService(); 74 CreateUninitializedInvalidationService();
97 InitializeInvalidationService(); 75 InitializeInvalidationService();
98 } 76 }
99 77
100 void CreateUninitializedInvalidationService() { 78 void CreateUninitializedInvalidationService() {
101 gcm_service_.reset(new FakeGCMDriver(&token_service_)); 79 gcm_service_.reset(new FakeGCMDriver());
102 invalidation_service_.reset(new TiclInvalidationService( 80 invalidation_service_.reset(new TiclInvalidationService(
103 scoped_ptr<IdentityProvider>(new FakeIdentityProvider(&token_service_)), 81 scoped_ptr<IdentityProvider>(new FakeIdentityProvider(&token_service_)),
104 scoped_ptr<TiclSettingsProvider>(new FakeTiclSettingsProvider), 82 scoped_ptr<TiclSettingsProvider>(new FakeTiclSettingsProvider),
105 gcm_service_.get(), 83 gcm_service_.get(),
106 NULL)); 84 NULL));
107 } 85 }
108 86
109 void InitializeInvalidationService() { 87 void InitializeInvalidationService() {
110 fake_invalidator_ = new syncer::FakeInvalidator(); 88 fake_invalidator_ = new syncer::FakeInvalidator();
111 invalidation_service_->InitForTest( 89 invalidation_service_->InitForTest(
(...skipping 13 matching lines...) Expand all
125 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) { 103 void TriggerOnInvalidatorStateChange(syncer::InvalidatorState state) {
126 fake_invalidator_->EmitOnInvalidatorStateChange(state); 104 fake_invalidator_->EmitOnInvalidatorStateChange(state);
127 } 105 }
128 106
129 void TriggerOnIncomingInvalidation( 107 void TriggerOnIncomingInvalidation(
130 const syncer::ObjectIdInvalidationMap& invalidation_map) { 108 const syncer::ObjectIdInvalidationMap& invalidation_map) {
131 fake_invalidator_->EmitOnIncomingInvalidation(invalidation_map); 109 fake_invalidator_->EmitOnIncomingInvalidation(invalidation_map);
132 } 110 }
133 111
134 FakeOAuth2TokenService token_service_; 112 FakeOAuth2TokenService token_service_;
135 scoped_ptr<gcm::GCMDriver> gcm_service_; 113 scoped_ptr<gcm::GCMDriver> gcm_service_;
fgorski 2014/05/19 17:33:32 gcm_driver_
jianli 2014/05/19 18:37:20 Done.
136 syncer::FakeInvalidator* fake_invalidator_; // Owned by the service. 114 syncer::FakeInvalidator* fake_invalidator_; // Owned by the service.
137 115
138 scoped_ptr<TiclInvalidationService> invalidation_service_; 116 scoped_ptr<TiclInvalidationService> invalidation_service_;
139 }; 117 };
140 118
141 INSTANTIATE_TYPED_TEST_CASE_P( 119 INSTANTIATE_TYPED_TEST_CASE_P(
142 TiclInvalidationServiceTest, InvalidationServiceTest, 120 TiclInvalidationServiceTest, InvalidationServiceTest,
143 TiclInvalidationServiceTestDelegate); 121 TiclInvalidationServiceTestDelegate);
144 122
145 namespace internal { 123 namespace internal {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 155
178 delegate->InitializeInvalidationService(); 156 delegate->InitializeInvalidationService();
179 157
180 invalidator->RequestDetailedStatus( 158 invalidator->RequestDetailedStatus(
181 base::Bind(&internal::FakeCallbackContainer::FakeCallback, 159 base::Bind(&internal::FakeCallbackContainer::FakeCallback,
182 fake_container.weak_ptr_factory_.GetWeakPtr())); 160 fake_container.weak_ptr_factory_.GetWeakPtr()));
183 EXPECT_TRUE(fake_container.called_); 161 EXPECT_TRUE(fake_container.called_);
184 } 162 }
185 163
186 } // namespace invalidation 164 } // namespace invalidation
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698