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

Side by Side Diff: components/gcm_driver/gcm_client_impl_unittest.cc

Issue 666133002: Standardize usage of virtual/override/final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « components/gcm_driver/gcm_client_impl.h ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/gcm_driver/gcm_client_impl.h" 5 #include "components/gcm_driver/gcm_client_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 return email_token_map; 86 return email_token_map;
87 } 87 }
88 88
89 class FakeMCSClient : public MCSClient { 89 class FakeMCSClient : public MCSClient {
90 public: 90 public:
91 FakeMCSClient(base::Clock* clock, 91 FakeMCSClient(base::Clock* clock,
92 ConnectionFactory* connection_factory, 92 ConnectionFactory* connection_factory,
93 GCMStore* gcm_store, 93 GCMStore* gcm_store,
94 GCMStatsRecorder* recorder); 94 GCMStatsRecorder* recorder);
95 virtual ~FakeMCSClient(); 95 ~FakeMCSClient() override;
96 virtual void Login(uint64 android_id, uint64 security_token) override; 96 void Login(uint64 android_id, uint64 security_token) override;
97 virtual void SendMessage(const MCSMessage& message) override; 97 void SendMessage(const MCSMessage& message) override;
98 98
99 uint64 last_android_id() const { return last_android_id_; } 99 uint64 last_android_id() const { return last_android_id_; }
100 uint64 last_security_token() const { return last_security_token_; } 100 uint64 last_security_token() const { return last_security_token_; }
101 uint8 last_message_tag() const { return last_message_tag_; } 101 uint8 last_message_tag() const { return last_message_tag_; }
102 const mcs_proto::DataMessageStanza& last_data_message_stanza() const { 102 const mcs_proto::DataMessageStanza& last_data_message_stanza() const {
103 return last_data_message_stanza_; 103 return last_data_message_stanza_;
104 } 104 }
105 105
106 private: 106 private:
107 uint64 last_android_id_; 107 uint64 last_android_id_;
(...skipping 25 matching lines...) Expand all
133 if (last_message_tag_ == kDataMessageStanzaTag) { 133 if (last_message_tag_ == kDataMessageStanzaTag) {
134 last_data_message_stanza_.CopyFrom( 134 last_data_message_stanza_.CopyFrom(
135 reinterpret_cast<const mcs_proto::DataMessageStanza&>( 135 reinterpret_cast<const mcs_proto::DataMessageStanza&>(
136 message.GetProtobuf())); 136 message.GetProtobuf()));
137 } 137 }
138 } 138 }
139 139
140 class AutoAdvancingTestClock : public base::Clock { 140 class AutoAdvancingTestClock : public base::Clock {
141 public: 141 public:
142 explicit AutoAdvancingTestClock(base::TimeDelta auto_increment_time_delta); 142 explicit AutoAdvancingTestClock(base::TimeDelta auto_increment_time_delta);
143 virtual ~AutoAdvancingTestClock(); 143 ~AutoAdvancingTestClock() override;
144 144
145 virtual base::Time Now() override; 145 base::Time Now() override;
146 void Advance(TimeDelta delta); 146 void Advance(TimeDelta delta);
147 int call_count() const { return call_count_; } 147 int call_count() const { return call_count_; }
148 148
149 private: 149 private:
150 int call_count_; 150 int call_count_;
151 base::TimeDelta auto_increment_time_delta_; 151 base::TimeDelta auto_increment_time_delta_;
152 base::Time now_; 152 base::Time now_;
153 153
154 DISALLOW_COPY_AND_ASSIGN(AutoAdvancingTestClock); 154 DISALLOW_COPY_AND_ASSIGN(AutoAdvancingTestClock);
155 }; 155 };
(...skipping 12 matching lines...) Expand all
168 return now_; 168 return now_;
169 } 169 }
170 170
171 void AutoAdvancingTestClock::Advance(base::TimeDelta delta) { 171 void AutoAdvancingTestClock::Advance(base::TimeDelta delta) {
172 now_ += delta; 172 now_ += delta;
173 } 173 }
174 174
175 class FakeGCMInternalsBuilder : public GCMInternalsBuilder { 175 class FakeGCMInternalsBuilder : public GCMInternalsBuilder {
176 public: 176 public:
177 FakeGCMInternalsBuilder(base::TimeDelta clock_step); 177 FakeGCMInternalsBuilder(base::TimeDelta clock_step);
178 virtual ~FakeGCMInternalsBuilder(); 178 ~FakeGCMInternalsBuilder() override;
179 179
180 virtual scoped_ptr<base::Clock> BuildClock() override; 180 scoped_ptr<base::Clock> BuildClock() override;
181 virtual scoped_ptr<MCSClient> BuildMCSClient( 181 scoped_ptr<MCSClient> BuildMCSClient(const std::string& version,
182 const std::string& version, 182 base::Clock* clock,
183 base::Clock* clock, 183 ConnectionFactory* connection_factory,
184 ConnectionFactory* connection_factory, 184 GCMStore* gcm_store,
185 GCMStore* gcm_store, 185 GCMStatsRecorder* recorder) override;
186 GCMStatsRecorder* recorder) override; 186 scoped_ptr<ConnectionFactory> BuildConnectionFactory(
187 virtual scoped_ptr<ConnectionFactory> BuildConnectionFactory(
188 const std::vector<GURL>& endpoints, 187 const std::vector<GURL>& endpoints,
189 const net::BackoffEntry::Policy& backoff_policy, 188 const net::BackoffEntry::Policy& backoff_policy,
190 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session, 189 const scoped_refptr<net::HttpNetworkSession>& gcm_network_session,
191 const scoped_refptr<net::HttpNetworkSession>& http_network_session, 190 const scoped_refptr<net::HttpNetworkSession>& http_network_session,
192 net::NetLog* net_log, 191 net::NetLog* net_log,
193 GCMStatsRecorder* recorder) override; 192 GCMStatsRecorder* recorder) override;
194 193
195 private: 194 private:
196 base::TimeDelta clock_step_; 195 base::TimeDelta clock_step_;
197 }; 196 };
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void CompleteRegistration(const std::string& registration_id); 252 void CompleteRegistration(const std::string& registration_id);
254 void CompleteUnregistration(const std::string& app_id); 253 void CompleteUnregistration(const std::string& app_id);
255 void VerifyPendingRequestFetcherDeleted(); 254 void VerifyPendingRequestFetcherDeleted();
256 255
257 bool ExistsRegistration(const std::string& app_id) const; 256 bool ExistsRegistration(const std::string& app_id) const;
258 void AddRegistration(const std::string& app_id, 257 void AddRegistration(const std::string& app_id,
259 const std::vector<std::string>& sender_ids, 258 const std::vector<std::string>& sender_ids,
260 const std::string& registration_id); 259 const std::string& registration_id);
261 260
262 // GCMClient::Delegate overrides (for verification). 261 // GCMClient::Delegate overrides (for verification).
263 virtual void OnRegisterFinished(const std::string& app_id, 262 void OnRegisterFinished(const std::string& app_id,
264 const std::string& registration_id, 263 const std::string& registration_id,
265 GCMClient::Result result) override; 264 GCMClient::Result result) override;
266 virtual void OnUnregisterFinished(const std::string& app_id, 265 void OnUnregisterFinished(const std::string& app_id,
267 GCMClient::Result result) override; 266 GCMClient::Result result) override;
268 virtual void OnSendFinished(const std::string& app_id, 267 void OnSendFinished(const std::string& app_id,
269 const std::string& message_id, 268 const std::string& message_id,
270 GCMClient::Result result) override {} 269 GCMClient::Result result) override {}
271 virtual void OnMessageReceived(const std::string& registration_id, 270 void OnMessageReceived(const std::string& registration_id,
272 const GCMClient::IncomingMessage& message) 271 const GCMClient::IncomingMessage& message) override;
273 override; 272 void OnMessagesDeleted(const std::string& app_id) override;
274 virtual void OnMessagesDeleted(const std::string& app_id) override; 273 void OnMessageSendError(
275 virtual void OnMessageSendError(
276 const std::string& app_id, 274 const std::string& app_id,
277 const gcm::GCMClient::SendErrorDetails& send_error_details) override; 275 const gcm::GCMClient::SendErrorDetails& send_error_details) override;
278 virtual void OnSendAcknowledged(const std::string& app_id, 276 void OnSendAcknowledged(const std::string& app_id,
279 const std::string& message_id) override; 277 const std::string& message_id) override;
280 virtual void OnGCMReady( 278 void OnGCMReady(const std::vector<AccountMapping>& account_mappings) override;
281 const std::vector<AccountMapping>& account_mappings) override; 279 void OnActivityRecorded() override {}
282 virtual void OnActivityRecorded() override {} 280 void OnConnected(const net::IPEndPoint& ip_endpoint) override {}
283 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) override {} 281 void OnDisconnected() override {}
284 virtual void OnDisconnected() override {}
285 282
286 GCMClientImpl* gcm_client() const { return gcm_client_.get(); } 283 GCMClientImpl* gcm_client() const { return gcm_client_.get(); }
287 FakeMCSClient* mcs_client() const { 284 FakeMCSClient* mcs_client() const {
288 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get()); 285 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get());
289 } 286 }
290 ConnectionFactory* connection_factory() const { 287 ConnectionFactory* connection_factory() const {
291 return gcm_client_->connection_factory_.get(); 288 return gcm_client_->connection_factory_.get();
292 } 289 }
293 290
294 const GCMClientImpl::CheckinInfo& device_checkin_info() const { 291 const GCMClientImpl::CheckinInfo& device_checkin_info() const {
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { 1038 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) {
1042 // Start the GCM and then stop and restart it immediately. 1039 // Start the GCM and then stop and restart it immediately.
1043 gcm_client()->Start(); 1040 gcm_client()->Start();
1044 gcm_client()->Stop(); 1041 gcm_client()->Stop();
1045 gcm_client()->Start(); 1042 gcm_client()->Start();
1046 1043
1047 PumpLoopUntilIdle(); 1044 PumpLoopUntilIdle();
1048 } 1045 }
1049 1046
1050 } // namespace gcm 1047 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_client_impl.h ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698