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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/test/simple_test_clock.h" | 10 #include "base/test/simple_test_clock.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 GCMAccountMapperTest(); | 240 GCMAccountMapperTest(); |
241 ~GCMAccountMapperTest() override; | 241 ~GCMAccountMapperTest() override; |
242 | 242 |
243 void Restart(); | 243 void Restart(); |
244 | 244 |
245 void Initialize(const GCMAccountMapper::AccountMappings mappings); | 245 void Initialize(const GCMAccountMapper::AccountMappings mappings); |
246 const GCMAccountMapper::AccountMappings& GetAccounts() const { | 246 const GCMAccountMapper::AccountMappings& GetAccounts() const { |
247 return account_mapper_->accounts_; | 247 return account_mapper_->accounts_; |
248 } | 248 } |
249 void MessageReceived(const std::string& app_id, | 249 void MessageReceived(const std::string& app_id, |
250 const IncomingMessage& message); | 250 const IncomingMessage& message, |
| 251 const MessageReceiptCallback& optional_receipt_callback); |
251 | 252 |
252 GCMAccountMapper* mapper() { return account_mapper_.get(); } | 253 GCMAccountMapper* mapper() { return account_mapper_.get(); } |
253 | 254 |
254 CustomFakeGCMDriver& gcm_driver() { return gcm_driver_; } | 255 CustomFakeGCMDriver& gcm_driver() { return gcm_driver_; } |
255 | 256 |
256 base::SimpleTestClock* clock() { return clock_; } | 257 base::SimpleTestClock* clock() { return clock_; } |
257 const std::string& last_received_app_id() const { | 258 const std::string& last_received_app_id() const { |
258 return last_received_app_id_; | 259 return last_received_app_id_; |
259 } | 260 } |
260 const IncomingMessage& last_received_message() const { | 261 const IncomingMessage& last_received_message() const { |
(...skipping 25 matching lines...) Expand all Loading... |
286 account_mapper_->SetClockForTesting(std::move(clock)); | 287 account_mapper_->SetClockForTesting(std::move(clock)); |
287 } | 288 } |
288 | 289 |
289 void GCMAccountMapperTest::Initialize( | 290 void GCMAccountMapperTest::Initialize( |
290 const GCMAccountMapper::AccountMappings mappings) { | 291 const GCMAccountMapper::AccountMappings mappings) { |
291 mapper()->Initialize(mappings, | 292 mapper()->Initialize(mappings, |
292 base::Bind(&GCMAccountMapperTest::MessageReceived, | 293 base::Bind(&GCMAccountMapperTest::MessageReceived, |
293 base::Unretained(this))); | 294 base::Unretained(this))); |
294 } | 295 } |
295 | 296 |
296 void GCMAccountMapperTest::MessageReceived(const std::string& app_id, | 297 void GCMAccountMapperTest::MessageReceived( |
297 const IncomingMessage& message) { | 298 const std::string& app_id, |
| 299 const IncomingMessage& message, |
| 300 const MessageReceiptCallback& optional_receipt_callback) { |
298 last_received_app_id_ = app_id; | 301 last_received_app_id_ = app_id; |
299 last_received_message_ = message; | 302 last_received_message_ = message; |
300 } | 303 } |
301 | 304 |
302 // Tests the initialization of account mappings (from the store) when empty. | 305 // Tests the initialization of account mappings (from the store) when empty. |
303 // It also checks that initialization triggers registration ID request. | 306 // It also checks that initialization triggers registration ID request. |
304 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { | 307 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { |
305 EXPECT_FALSE(gcm_driver().registration_id_requested()); | 308 EXPECT_FALSE(gcm_driver().registration_id_requested()); |
306 Initialize(GCMAccountMapper::AccountMappings()); | 309 Initialize(GCMAccountMapper::AccountMappings()); |
307 EXPECT_TRUE(GetAccounts().empty()); | 310 EXPECT_TRUE(GetAccounts().empty()); |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 EXPECT_EQ(1UL, last_received_message().data.size()); | 950 EXPECT_EQ(1UL, last_received_message().data.size()); |
948 MessageData::const_iterator it = | 951 MessageData::const_iterator it = |
949 last_received_message().data.find(kTestDataKey); | 952 last_received_message().data.find(kTestDataKey); |
950 EXPECT_TRUE(it != last_received_message().data.end()); | 953 EXPECT_TRUE(it != last_received_message().data.end()); |
951 EXPECT_EQ(kTestDataValue, it->second); | 954 EXPECT_EQ(kTestDataValue, it->second); |
952 EXPECT_EQ(kTestCollapseKey, last_received_message().collapse_key); | 955 EXPECT_EQ(kTestCollapseKey, last_received_message().collapse_key); |
953 EXPECT_EQ(kTestSenderId, last_received_message().sender_id); | 956 EXPECT_EQ(kTestSenderId, last_received_message().sender_id); |
954 } | 957 } |
955 | 958 |
956 } // namespace gcm | 959 } // namespace gcm |
OLD | NEW |