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

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

Issue 618003002: [GCM] Handling connection events in GCMAccountTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the test failing on a mac 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_account_mapper.cc ('k') | components/gcm_driver/gcm_driver.cc » ('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_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"
11 #include "google_apis/gcm/engine/gcm_store.h" 11 #include "google_apis/gcm/engine/gcm_store.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace gcm { 14 namespace gcm {
15 15
16 namespace { 16 namespace {
17 17
18 const char kGCMAccountMapperSenderId[] = "745476177629"; 18 const char kGCMAccountMapperSenderId[] = "745476177629";
19 const char kGCMAccountMapperAppId[] = "com.google.android.gms";
20 const char kRegistrationId[] = "reg_id"; 19 const char kRegistrationId[] = "reg_id";
21 20
22 AccountMapping MakeAccountMapping(const std::string& account_id, 21 AccountMapping MakeAccountMapping(const std::string& account_id,
23 AccountMapping::MappingStatus status, 22 AccountMapping::MappingStatus status,
24 const base::Time& status_change_timestamp, 23 const base::Time& status_change_timestamp,
25 const std::string& last_message_id) { 24 const std::string& last_message_id) {
26 AccountMapping account_mapping; 25 AccountMapping account_mapping;
27 account_mapping.account_id = account_id; 26 account_mapping.account_id = account_id;
28 account_mapping.email = account_id + "@gmail.com"; 27 account_mapping.email = account_id + "@gmail.com";
29 // account_mapping.access_token intentionally left empty. 28 // account_mapping.access_token intentionally left empty.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 GCMAccountMapperTest::GCMAccountMapperTest() { 264 GCMAccountMapperTest::GCMAccountMapperTest() {
266 Restart(); 265 Restart();
267 } 266 }
268 267
269 GCMAccountMapperTest::~GCMAccountMapperTest() { 268 GCMAccountMapperTest::~GCMAccountMapperTest() {
270 } 269 }
271 270
272 void GCMAccountMapperTest::Restart() { 271 void GCMAccountMapperTest::Restart() {
273 if (account_mapper_) 272 if (account_mapper_)
274 account_mapper_->ShutdownHandler(); 273 account_mapper_->ShutdownHandler();
274 gcm_driver_.RemoveAppHandler(kGCMAccountMapperAppId);
275 account_mapper_.reset(new GCMAccountMapper(&gcm_driver_)); 275 account_mapper_.reset(new GCMAccountMapper(&gcm_driver_));
276 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); 276 scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock);
277 clock_ = clock.get(); 277 clock_ = clock.get();
278 account_mapper_->SetClockForTesting(clock.PassAs<base::Clock>()); 278 account_mapper_->SetClockForTesting(clock.PassAs<base::Clock>());
279 } 279 }
280 280
281 // Tests the initialization of account mappings (from the store) when empty. 281 // Tests the initialization of account mappings (from the store) when empty.
282 // It also checks that initialization triggers registration ID request. 282 // It also checks that initialization triggers registration ID request.
283 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) { 283 TEST_F(GCMAccountMapperTest, InitializeAccountMappingsEmpty) {
284 EXPECT_FALSE(gcm_driver().registration_id_requested()); 284 EXPECT_FALSE(gcm_driver().registration_id_requested());
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 EXPECT_EQ(account_token.account_id, iter->account_id); 427 EXPECT_EQ(account_token.account_id, iter->account_id);
428 EXPECT_EQ(account_token.access_token, iter->access_token); 428 EXPECT_EQ(account_token.access_token, iter->access_token);
429 EXPECT_EQ(AccountMapping::ADDING, iter->status); 429 EXPECT_EQ(AccountMapping::ADDING, iter->status);
430 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp); 430 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp);
431 EXPECT_EQ(gcm_driver().last_message_id(), iter->last_message_id); 431 EXPECT_EQ(gcm_driver().last_message_id(), iter->last_message_id);
432 } 432 }
433 433
434 // Tests status change from ADDING to MAPPED (Message is acknowledged). 434 // Tests status change from ADDING to MAPPED (Message is acknowledged).
435 TEST_F(GCMAccountMapperTest, AddMappingMessageAcknowledged) { 435 TEST_F(GCMAccountMapperTest, AddMappingMessageAcknowledged) {
436 mapper()->Initialize(GCMAccountMapper::AccountMappings()); 436 mapper()->Initialize(GCMAccountMapper::AccountMappings());
437 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
437 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 438 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
438 439
439 std::vector<GCMClient::AccountTokenInfo> account_tokens; 440 std::vector<GCMClient::AccountTokenInfo> account_tokens;
440 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id"); 441 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id");
441 account_tokens.push_back(account_token); 442 account_tokens.push_back(account_token);
442 mapper()->SetAccountTokens(account_tokens); 443 mapper()->SetAccountTokens(account_tokens);
443 444
444 clock()->SetNow(base::Time::Now()); 445 clock()->SetNow(base::Time::Now());
445 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS); 446 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS);
446 clock()->SetNow(base::Time::Now()); 447 clock()->SetNow(base::Time::Now());
(...skipping 16 matching lines...) Expand all
463 EXPECT_EQ(account_token.access_token, iter->access_token); 464 EXPECT_EQ(account_token.access_token, iter->access_token);
464 EXPECT_EQ(AccountMapping::MAPPED, iter->status); 465 EXPECT_EQ(AccountMapping::MAPPED, iter->status);
465 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp); 466 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp);
466 EXPECT_TRUE(iter->last_message_id.empty()); 467 EXPECT_TRUE(iter->last_message_id.empty());
467 } 468 }
468 469
469 // Tests status change form ADDING to MAPPED (When message was acknowledged, 470 // Tests status change form ADDING to MAPPED (When message was acknowledged,
470 // after Chrome was restarted). 471 // after Chrome was restarted).
471 TEST_F(GCMAccountMapperTest, AddMappingMessageAckedAfterRestart) { 472 TEST_F(GCMAccountMapperTest, AddMappingMessageAckedAfterRestart) {
472 mapper()->Initialize(GCMAccountMapper::AccountMappings()); 473 mapper()->Initialize(GCMAccountMapper::AccountMappings());
474 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
473 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 475 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
474 476
475 std::vector<GCMClient::AccountTokenInfo> account_tokens; 477 std::vector<GCMClient::AccountTokenInfo> account_tokens;
476 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id"); 478 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id");
477 account_tokens.push_back(account_token); 479 account_tokens.push_back(account_token);
478 mapper()->SetAccountTokens(account_tokens); 480 mapper()->SetAccountTokens(account_tokens);
479 481
480 clock()->SetNow(base::Time::Now()); 482 clock()->SetNow(base::Time::Now());
481 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS); 483 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS);
482 484
483 Restart(); 485 Restart();
484 GCMAccountMapper::AccountMappings stored_mappings; 486 GCMAccountMapper::AccountMappings stored_mappings;
485 stored_mappings.push_back(gcm_driver().last_account_mapping()); 487 stored_mappings.push_back(gcm_driver().last_account_mapping());
486 mapper()->Initialize(stored_mappings); 488 mapper()->Initialize(stored_mappings);
489 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
487 490
488 clock()->SetNow(base::Time::Now()); 491 clock()->SetNow(base::Time::Now());
489 gcm_driver().AcknowledgeSend(gcm_driver().last_message_id()); 492 gcm_driver().AcknowledgeSend(gcm_driver().last_message_id());
490 493
491 EXPECT_EQ(account_token.email, gcm_driver().last_account_mapping().email); 494 EXPECT_EQ(account_token.email, gcm_driver().last_account_mapping().email);
492 EXPECT_EQ(account_token.account_id, 495 EXPECT_EQ(account_token.account_id,
493 gcm_driver().last_account_mapping().account_id); 496 gcm_driver().last_account_mapping().account_id);
494 EXPECT_EQ(account_token.access_token, 497 EXPECT_EQ(account_token.access_token,
495 gcm_driver().last_account_mapping().access_token); 498 gcm_driver().last_account_mapping().access_token);
496 EXPECT_EQ(AccountMapping::MAPPED, gcm_driver().last_account_mapping().status); 499 EXPECT_EQ(AccountMapping::MAPPED, gcm_driver().last_account_mapping().status);
497 EXPECT_EQ(clock()->Now(), 500 EXPECT_EQ(clock()->Now(),
498 gcm_driver().last_account_mapping().status_change_timestamp); 501 gcm_driver().last_account_mapping().status_change_timestamp);
499 EXPECT_TRUE(gcm_driver().last_account_mapping().last_message_id.empty()); 502 EXPECT_TRUE(gcm_driver().last_account_mapping().last_message_id.empty());
500 503
501 GCMAccountMapper::AccountMappings mappings = GetAccounts(); 504 GCMAccountMapper::AccountMappings mappings = GetAccounts();
502 GCMAccountMapper::AccountMappings::const_iterator iter = mappings.begin(); 505 GCMAccountMapper::AccountMappings::const_iterator iter = mappings.begin();
503 EXPECT_EQ(account_token.email, iter->email); 506 EXPECT_EQ(account_token.email, iter->email);
504 EXPECT_EQ(account_token.account_id, iter->account_id); 507 EXPECT_EQ(account_token.account_id, iter->account_id);
505 EXPECT_EQ(account_token.access_token, iter->access_token); 508 EXPECT_EQ(account_token.access_token, iter->access_token);
506 EXPECT_EQ(AccountMapping::MAPPED, iter->status); 509 EXPECT_EQ(AccountMapping::MAPPED, iter->status);
507 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp); 510 EXPECT_EQ(clock()->Now(), iter->status_change_timestamp);
508 EXPECT_TRUE(iter->last_message_id.empty()); 511 EXPECT_TRUE(iter->last_message_id.empty());
509 } 512 }
510 513
511 // Tests a case when ADD message times out for a new account. 514 // Tests a case when ADD message times out for a new account.
512 TEST_F(GCMAccountMapperTest, AddMappingMessageSendErrorForNewAccount) { 515 TEST_F(GCMAccountMapperTest, AddMappingMessageSendErrorForNewAccount) {
513 mapper()->Initialize(GCMAccountMapper::AccountMappings()); 516 mapper()->Initialize(GCMAccountMapper::AccountMappings());
517 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
514 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 518 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
515 519
516 std::vector<GCMClient::AccountTokenInfo> account_tokens; 520 std::vector<GCMClient::AccountTokenInfo> account_tokens;
517 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id"); 521 GCMClient::AccountTokenInfo account_token = MakeAccountTokenInfo("acc_id");
518 account_tokens.push_back(account_token); 522 account_tokens.push_back(account_token);
519 mapper()->SetAccountTokens(account_tokens); 523 mapper()->SetAccountTokens(account_tokens);
520 524
521 clock()->SetNow(base::Time::Now()); 525 clock()->SetNow(base::Time::Now());
522 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS); 526 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS);
523 527
(...skipping 13 matching lines...) Expand all
537 // Start with one account that is mapped. 541 // Start with one account that is mapped.
538 base::Time status_change_timestamp = base::Time::Now(); 542 base::Time status_change_timestamp = base::Time::Now();
539 AccountMapping mapping = MakeAccountMapping("acc_id", 543 AccountMapping mapping = MakeAccountMapping("acc_id",
540 AccountMapping::MAPPED, 544 AccountMapping::MAPPED,
541 status_change_timestamp, 545 status_change_timestamp,
542 "add_message_id"); 546 "add_message_id");
543 547
544 GCMAccountMapper::AccountMappings stored_mappings; 548 GCMAccountMapper::AccountMappings stored_mappings;
545 stored_mappings.push_back(mapping); 549 stored_mappings.push_back(mapping);
546 mapper()->Initialize(stored_mappings); 550 mapper()->Initialize(stored_mappings);
551 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
547 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 552 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
548 553
549 clock()->SetNow(base::Time::Now()); 554 clock()->SetNow(base::Time::Now());
550 gcm_driver().MessageSendError("add_message_id"); 555 gcm_driver().MessageSendError("add_message_id");
551 556
552 // No new message is sent because of the send error, as the token is stale. 557 // No new message is sent because of the send error, as the token is stale.
553 // Because the account was new, the entry should be deleted. 558 // Because the account was new, the entry should be deleted.
554 EXPECT_TRUE(gcm_driver().last_message_id().empty()); 559 EXPECT_TRUE(gcm_driver().last_message_id().empty());
555 560
556 GCMAccountMapper::AccountMappings mappings = GetAccounts(); 561 GCMAccountMapper::AccountMappings mappings = GetAccounts();
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 TEST_F(GCMAccountMapperTest, RemoveMappingMessageAcknowledged) { 649 TEST_F(GCMAccountMapperTest, RemoveMappingMessageAcknowledged) {
645 // Start with one account that is mapped. 650 // Start with one account that is mapped.
646 AccountMapping mapping = MakeAccountMapping("acc_id", 651 AccountMapping mapping = MakeAccountMapping("acc_id",
647 AccountMapping::MAPPED, 652 AccountMapping::MAPPED,
648 base::Time::Now(), 653 base::Time::Now(),
649 std::string()); 654 std::string());
650 655
651 GCMAccountMapper::AccountMappings stored_mappings; 656 GCMAccountMapper::AccountMappings stored_mappings;
652 stored_mappings.push_back(mapping); 657 stored_mappings.push_back(mapping);
653 mapper()->Initialize(stored_mappings); 658 mapper()->Initialize(stored_mappings);
659 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
654 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 660 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
655 clock()->SetNow(base::Time::Now()); 661 clock()->SetNow(base::Time::Now());
656 662
657 mapper()->SetAccountTokens(std::vector<GCMClient::AccountTokenInfo>()); 663 mapper()->SetAccountTokens(std::vector<GCMClient::AccountTokenInfo>());
658 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS); 664 gcm_driver().CompleteSend(gcm_driver().last_message_id(), GCMClient::SUCCESS);
659 gcm_driver().AcknowledgeSend(gcm_driver().last_message_id()); 665 gcm_driver().AcknowledgeSend(gcm_driver().last_message_id());
660 666
661 EXPECT_EQ(mapping.account_id, gcm_driver().last_removed_account_id()); 667 EXPECT_EQ(mapping.account_id, gcm_driver().last_removed_account_id());
662 668
663 GCMAccountMapper::AccountMappings mappings = GetAccounts(); 669 GCMAccountMapper::AccountMappings mappings = GetAccounts();
664 EXPECT_TRUE(mappings.empty()); 670 EXPECT_TRUE(mappings.empty());
665 } 671 }
666 672
667 // Tests that account removing proceeds, when a removing message is acked after 673 // Tests that account removing proceeds, when a removing message is acked after
668 // Chrome was restarted. 674 // Chrome was restarted.
669 TEST_F(GCMAccountMapperTest, RemoveMappingMessageAckedAfterRestart) { 675 TEST_F(GCMAccountMapperTest, RemoveMappingMessageAckedAfterRestart) {
670 // Start with one account that is mapped. 676 // Start with one account that is mapped.
671 AccountMapping mapping = MakeAccountMapping("acc_id", 677 AccountMapping mapping = MakeAccountMapping("acc_id",
672 AccountMapping::REMOVING, 678 AccountMapping::REMOVING,
673 base::Time::Now(), 679 base::Time::Now(),
674 "remove_message_id"); 680 "remove_message_id");
675 681
676 GCMAccountMapper::AccountMappings stored_mappings; 682 GCMAccountMapper::AccountMappings stored_mappings;
677 stored_mappings.push_back(mapping); 683 stored_mappings.push_back(mapping);
678 mapper()->Initialize(stored_mappings); 684 mapper()->Initialize(stored_mappings);
685 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
679 686
680 gcm_driver().AcknowledgeSend("remove_message_id"); 687 gcm_driver().AcknowledgeSend("remove_message_id");
681 688
682 EXPECT_EQ(mapping.account_id, gcm_driver().last_removed_account_id()); 689 EXPECT_EQ(mapping.account_id, gcm_driver().last_removed_account_id());
683 690
684 GCMAccountMapper::AccountMappings mappings = GetAccounts(); 691 GCMAccountMapper::AccountMappings mappings = GetAccounts();
685 EXPECT_TRUE(mappings.empty()); 692 EXPECT_TRUE(mappings.empty());
686 } 693 }
687 694
688 // Tests that account removing proceeds, when a removing message is acked after 695 // Tests that account removing proceeds, when a removing message is acked after
689 // Chrome was restarted. 696 // Chrome was restarted.
690 TEST_F(GCMAccountMapperTest, RemoveMappingMessageSendError) { 697 TEST_F(GCMAccountMapperTest, RemoveMappingMessageSendError) {
691 // Start with one account that is mapped. 698 // Start with one account that is mapped.
692 base::Time status_change_timestamp = base::Time::Now(); 699 base::Time status_change_timestamp = base::Time::Now();
693 AccountMapping mapping = MakeAccountMapping("acc_id", 700 AccountMapping mapping = MakeAccountMapping("acc_id",
694 AccountMapping::REMOVING, 701 AccountMapping::REMOVING,
695 status_change_timestamp, 702 status_change_timestamp,
696 "remove_message_id"); 703 "remove_message_id");
697 704
698 GCMAccountMapper::AccountMappings stored_mappings; 705 GCMAccountMapper::AccountMappings stored_mappings;
699 stored_mappings.push_back(mapping); 706 stored_mappings.push_back(mapping);
700 mapper()->Initialize(stored_mappings); 707 mapper()->Initialize(stored_mappings);
708 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
701 709
702 clock()->SetNow(base::Time::Now()); 710 clock()->SetNow(base::Time::Now());
703 gcm_driver().MessageSendError("remove_message_id"); 711 gcm_driver().MessageSendError("remove_message_id");
704 712
705 EXPECT_TRUE(gcm_driver().last_removed_account_id().empty()); 713 EXPECT_TRUE(gcm_driver().last_removed_account_id().empty());
706 714
707 EXPECT_EQ(mapping.account_id, gcm_driver().last_account_mapping().account_id); 715 EXPECT_EQ(mapping.account_id, gcm_driver().last_account_mapping().account_id);
708 EXPECT_EQ(mapping.email, gcm_driver().last_account_mapping().email); 716 EXPECT_EQ(mapping.email, gcm_driver().last_account_mapping().email);
709 EXPECT_EQ(AccountMapping::REMOVING, 717 EXPECT_EQ(AccountMapping::REMOVING,
710 gcm_driver().last_account_mapping().status); 718 gcm_driver().last_account_mapping().status);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 base::Time half_hour_ago = clock()->Now() - base::TimeDelta::FromMinutes(30); 813 base::Time half_hour_ago = clock()->Now() - base::TimeDelta::FromMinutes(30);
806 GCMAccountMapper::AccountMappings stored_mappings; 814 GCMAccountMapper::AccountMappings stored_mappings;
807 stored_mappings.push_back(MakeAccountMapping( 815 stored_mappings.push_back(MakeAccountMapping(
808 "acc_id_0", AccountMapping::ADDING, half_hour_ago, "acc_id_0_msg")); 816 "acc_id_0", AccountMapping::ADDING, half_hour_ago, "acc_id_0_msg"));
809 stored_mappings.push_back(MakeAccountMapping( 817 stored_mappings.push_back(MakeAccountMapping(
810 "acc_id_1", AccountMapping::MAPPED, half_hour_ago, "acc_id_1_msg")); 818 "acc_id_1", AccountMapping::MAPPED, half_hour_ago, "acc_id_1_msg"));
811 stored_mappings.push_back(MakeAccountMapping( 819 stored_mappings.push_back(MakeAccountMapping(
812 "acc_id_2", AccountMapping::REMOVING, half_hour_ago, "acc_id_2_msg")); 820 "acc_id_2", AccountMapping::REMOVING, half_hour_ago, "acc_id_2_msg"));
813 821
814 mapper()->Initialize(stored_mappings); 822 mapper()->Initialize(stored_mappings);
823 gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
815 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS); 824 gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
816 825
817 GCMAccountMapper::AccountMappings expected_mappings(stored_mappings); 826 GCMAccountMapper::AccountMappings expected_mappings(stored_mappings);
818 827
819 // Finish messages after a restart. 828 // Finish messages after a restart.
820 clock()->SetNow(base::Time::Now()); 829 clock()->SetNow(base::Time::Now());
821 gcm_driver().AcknowledgeSend(expected_mappings[0].last_message_id); 830 gcm_driver().AcknowledgeSend(expected_mappings[0].last_message_id);
822 expected_mappings[0].status_change_timestamp = clock()->Now(); 831 expected_mappings[0].status_change_timestamp = clock()->Now();
823 expected_mappings[0].status = AccountMapping::MAPPED; 832 expected_mappings[0].status = AccountMapping::MAPPED;
824 expected_mappings[0].last_message_id.clear(); 833 expected_mappings[0].last_message_id.clear();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 expected_mappings[1].status_change_timestamp = clock()->Now(); 906 expected_mappings[1].status_change_timestamp = clock()->Now();
898 expected_mappings[1].status = AccountMapping::MAPPED; 907 expected_mappings[1].status = AccountMapping::MAPPED;
899 expected_mappings[2].status_change_timestamp = clock()->Now(); 908 expected_mappings[2].status_change_timestamp = clock()->Now();
900 expected_mappings[2].status = AccountMapping::MAPPED; 909 expected_mappings[2].status = AccountMapping::MAPPED;
901 910
902 VerifyMappings( 911 VerifyMappings(
903 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts"); 912 expected_mappings, GetAccounts(), "Step 6, Three mapped accounts");
904 } 913 }
905 914
906 } // namespace gcm 915 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_account_mapper.cc ('k') | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698