| 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_account_mapper.h" | 5 #include "components/gcm_driver/gcm_account_mapper.h" |
| 6 | 6 |
| 7 #include "base/test/simple_test_clock.h" | 7 #include "base/test/simple_test_clock.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/gcm_driver/fake_gcm_driver.h" | 9 #include "components/gcm_driver/fake_gcm_driver.h" |
| 10 #include "google_apis/gcm/engine/account_mapping.h" | 10 #include "google_apis/gcm/engine/account_mapping.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 NONE, | 75 NONE, |
| 76 SEND_STARTED, | 76 SEND_STARTED, |
| 77 SEND_FINISHED, | 77 SEND_FINISHED, |
| 78 SEND_ACKNOWLEDGED | 78 SEND_ACKNOWLEDGED |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 CustomFakeGCMDriver(); | 81 CustomFakeGCMDriver(); |
| 82 virtual ~CustomFakeGCMDriver(); | 82 virtual ~CustomFakeGCMDriver(); |
| 83 | 83 |
| 84 virtual void UpdateAccountMapping( | 84 virtual void UpdateAccountMapping( |
| 85 const AccountMapping& account_mapping) OVERRIDE; | 85 const AccountMapping& account_mapping) override; |
| 86 virtual void RemoveAccountMapping(const std::string& account_id) OVERRIDE; | 86 virtual void RemoveAccountMapping(const std::string& account_id) override; |
| 87 virtual void AddAppHandler(const std::string& app_id, | 87 virtual void AddAppHandler(const std::string& app_id, |
| 88 GCMAppHandler* handler) OVERRIDE; | 88 GCMAppHandler* handler) override; |
| 89 virtual void RemoveAppHandler(const std::string& app_id) OVERRIDE; | 89 virtual void RemoveAppHandler(const std::string& app_id) override; |
| 90 virtual void RegisterImpl( | 90 virtual void RegisterImpl( |
| 91 const std::string& app_id, | 91 const std::string& app_id, |
| 92 const std::vector<std::string>& sender_ids) OVERRIDE; | 92 const std::vector<std::string>& sender_ids) override; |
| 93 | 93 |
| 94 void CompleteRegister(const std::string& registration_id, | 94 void CompleteRegister(const std::string& registration_id, |
| 95 GCMClient::Result result); | 95 GCMClient::Result result); |
| 96 void CompleteSend(const std::string& message_id, GCMClient::Result result); | 96 void CompleteSend(const std::string& message_id, GCMClient::Result result); |
| 97 void AcknowledgeSend(const std::string& message_id); | 97 void AcknowledgeSend(const std::string& message_id); |
| 98 void MessageSendError(const std::string& message_id); | 98 void MessageSendError(const std::string& message_id); |
| 99 | 99 |
| 100 void CompleteSendAllMessages(); | 100 void CompleteSendAllMessages(); |
| 101 void AcknowledgeSendAllMessages(); | 101 void AcknowledgeSendAllMessages(); |
| 102 | 102 |
| 103 void SetLastMessageAction(const std::string& message_id, | 103 void SetLastMessageAction(const std::string& message_id, |
| 104 LastMessageAction action); | 104 LastMessageAction action); |
| 105 void Clear(); | 105 void Clear(); |
| 106 | 106 |
| 107 const AccountMapping& last_account_mapping() const { | 107 const AccountMapping& last_account_mapping() const { |
| 108 return account_mapping_; | 108 return account_mapping_; |
| 109 } | 109 } |
| 110 const std::string& last_message_id() const { return last_message_id_; } | 110 const std::string& last_message_id() const { return last_message_id_; } |
| 111 const std::string& last_removed_account_id() const { | 111 const std::string& last_removed_account_id() const { |
| 112 return last_removed_account_id_; | 112 return last_removed_account_id_; |
| 113 } | 113 } |
| 114 LastMessageAction last_action() const { return last_action_; } | 114 LastMessageAction last_action() const { return last_action_; } |
| 115 bool registration_id_requested() const { return registration_id_requested_; } | 115 bool registration_id_requested() const { return registration_id_requested_; } |
| 116 | 116 |
| 117 protected: | 117 protected: |
| 118 virtual void SendImpl(const std::string& app_id, | 118 virtual void SendImpl(const std::string& app_id, |
| 119 const std::string& receiver_id, | 119 const std::string& receiver_id, |
| 120 const GCMClient::OutgoingMessage& message) OVERRIDE; | 120 const GCMClient::OutgoingMessage& message) override; |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 AccountMapping account_mapping_; | 123 AccountMapping account_mapping_; |
| 124 std::string last_message_id_; | 124 std::string last_message_id_; |
| 125 std::string last_removed_account_id_; | 125 std::string last_removed_account_id_; |
| 126 LastMessageAction last_action_; | 126 LastMessageAction last_action_; |
| 127 std::map<std::string, LastMessageAction> all_messages_; | 127 std::map<std::string, LastMessageAction> all_messages_; |
| 128 bool registration_id_requested_; | 128 bool registration_id_requested_; |
| 129 }; | 129 }; |
| 130 | 130 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 expected_mappings[1].status_change_timestamp = clock()->Now(); | 897 expected_mappings[1].status_change_timestamp = clock()->Now(); |
| 898 expected_mappings[1].status = AccountMapping::MAPPED; | 898 expected_mappings[1].status = AccountMapping::MAPPED; |
| 899 expected_mappings[2].status_change_timestamp = clock()->Now(); | 899 expected_mappings[2].status_change_timestamp = clock()->Now(); |
| 900 expected_mappings[2].status = AccountMapping::MAPPED; | 900 expected_mappings[2].status = AccountMapping::MAPPED; |
| 901 | 901 |
| 902 VerifyMappings( | 902 VerifyMappings( |
| 903 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts"); | 903 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts"); |
| 904 } | 904 } |
| 905 | 905 |
| 906 } // namespace gcm | 906 } // namespace gcm |
| OLD | NEW |