| OLD | NEW |
| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 const std::string& message_id, | 271 const std::string& message_id, |
| 272 GCMClient::Result result) override {} | 272 GCMClient::Result result) override {} |
| 273 void OnMessageReceived(const std::string& registration_id, | 273 void OnMessageReceived(const std::string& registration_id, |
| 274 const GCMClient::IncomingMessage& message) override; | 274 const GCMClient::IncomingMessage& message) override; |
| 275 void OnMessagesDeleted(const std::string& app_id) override; | 275 void OnMessagesDeleted(const std::string& app_id) override; |
| 276 void OnMessageSendError( | 276 void OnMessageSendError( |
| 277 const std::string& app_id, | 277 const std::string& app_id, |
| 278 const gcm::GCMClient::SendErrorDetails& send_error_details) override; | 278 const gcm::GCMClient::SendErrorDetails& send_error_details) override; |
| 279 void OnSendAcknowledged(const std::string& app_id, | 279 void OnSendAcknowledged(const std::string& app_id, |
| 280 const std::string& message_id) override; | 280 const std::string& message_id) override; |
| 281 void OnGCMReady(const std::vector<AccountMapping>& account_mappings) override; | 281 void OnGCMReady(const std::vector<AccountMapping>& account_mappings, |
| 282 const base::Time& last_token_fetching_time) override; |
| 282 void OnActivityRecorded() override {} | 283 void OnActivityRecorded() override {} |
| 283 void OnConnected(const net::IPEndPoint& ip_endpoint) override {} | 284 void OnConnected(const net::IPEndPoint& ip_endpoint) override {} |
| 284 void OnDisconnected() override {} | 285 void OnDisconnected() override {} |
| 285 | 286 |
| 286 GCMClientImpl* gcm_client() const { return gcm_client_.get(); } | 287 GCMClientImpl* gcm_client() const { return gcm_client_.get(); } |
| 287 FakeMCSClient* mcs_client() const { | 288 FakeMCSClient* mcs_client() const { |
| 288 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get()); | 289 return reinterpret_cast<FakeMCSClient*>(gcm_client_->mcs_client_.get()); |
| 289 } | 290 } |
| 290 ConnectionFactory* connection_factory() const { | 291 ConnectionFactory* connection_factory() const { |
| 291 return gcm_client_->connection_factory_.get(); | 292 return gcm_client_->connection_factory_.get(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 } | 508 } |
| 508 | 509 |
| 509 void GCMClientImplTest::ReceiveOnMessageSentToMCS( | 510 void GCMClientImplTest::ReceiveOnMessageSentToMCS( |
| 510 const std::string& app_id, | 511 const std::string& app_id, |
| 511 const std::string& message_id, | 512 const std::string& message_id, |
| 512 const MCSClient::MessageSendStatus status) { | 513 const MCSClient::MessageSendStatus status) { |
| 513 gcm_client_->OnMessageSentToMCS(0LL, app_id, message_id, status); | 514 gcm_client_->OnMessageSentToMCS(0LL, app_id, message_id, status); |
| 514 } | 515 } |
| 515 | 516 |
| 516 void GCMClientImplTest::OnGCMReady( | 517 void GCMClientImplTest::OnGCMReady( |
| 517 const std::vector<AccountMapping>& account_mappings) { | 518 const std::vector<AccountMapping>& account_mappings, |
| 519 const base::Time& last_token_fetching_time) { |
| 518 last_event_ = LOADING_COMPLETED; | 520 last_event_ = LOADING_COMPLETED; |
| 519 QuitLoop(); | 521 QuitLoop(); |
| 522 // TODO(fgorski): Add tests for last_token_fetching_time. |
| 520 // TODO(fgorski): Add scenario verifying contents of account_mappings, when | 523 // TODO(fgorski): Add scenario verifying contents of account_mappings, when |
| 521 // the list is not empty. | 524 // the list is not empty. |
| 522 } | 525 } |
| 523 | 526 |
| 524 void GCMClientImplTest::OnMessageReceived( | 527 void GCMClientImplTest::OnMessageReceived( |
| 525 const std::string& registration_id, | 528 const std::string& registration_id, |
| 526 const GCMClient::IncomingMessage& message) { | 529 const GCMClient::IncomingMessage& message) { |
| 527 last_event_ = MESSAGE_RECEIVED; | 530 last_event_ = MESSAGE_RECEIVED; |
| 528 last_app_id_ = registration_id; | 531 last_app_id_ = registration_id; |
| 529 last_message_ = message; | 532 last_message_ = message; |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { | 1044 TEST_F(GCMClientImplStartAndStopTest, StartStopAndRestartImmediately) { |
| 1042 // Start the GCM and then stop and restart it immediately. | 1045 // Start the GCM and then stop and restart it immediately. |
| 1043 gcm_client()->Start(); | 1046 gcm_client()->Start(); |
| 1044 gcm_client()->Stop(); | 1047 gcm_client()->Stop(); |
| 1045 gcm_client()->Start(); | 1048 gcm_client()->Start(); |
| 1046 | 1049 |
| 1047 PumpLoopUntilIdle(); | 1050 PumpLoopUntilIdle(); |
| 1048 } | 1051 } |
| 1049 | 1052 |
| 1050 } // namespace gcm | 1053 } // namespace gcm |
| OLD | NEW |