| 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 "google_apis/gcm/engine/gcm_store_impl.h" | 5 #include "google_apis/gcm/engine/gcm_store_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 account_mapping2, | 551 account_mapping2, |
| 552 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); | 552 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); |
| 553 PumpLoop(); | 553 PumpLoop(); |
| 554 | 554 |
| 555 gcm_store = BuildGCMStore().Pass(); | 555 gcm_store = BuildGCMStore().Pass(); |
| 556 gcm_store->Load(base::Bind( | 556 gcm_store->Load(base::Bind( |
| 557 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 557 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 558 PumpLoop(); | 558 PumpLoop(); |
| 559 | 559 |
| 560 EXPECT_EQ(2UL, load_result->account_mappings.size()); | 560 EXPECT_EQ(2UL, load_result->account_mappings.size()); |
| 561 GCMStore::AccountMappingMap::iterator iter = | 561 GCMStore::AccountMappings::iterator iter = |
| 562 load_result->account_mappings.begin(); | 562 load_result->account_mappings.begin(); |
| 563 EXPECT_EQ("account_id_1", iter->first); | 563 EXPECT_EQ(account_mapping1.account_id, iter->account_id); |
| 564 EXPECT_EQ(account_mapping1.account_id, iter->second.account_id); | 564 EXPECT_EQ(account_mapping1.email, iter->email); |
| 565 EXPECT_EQ(account_mapping1.email, iter->second.email); | 565 EXPECT_TRUE(iter->access_token.empty()); |
| 566 EXPECT_TRUE(iter->second.access_token.empty()); | 566 EXPECT_EQ(AccountMapping::ADDING, iter->status); |
| 567 EXPECT_EQ(AccountMapping::ADDING, iter->second.status); | |
| 568 EXPECT_EQ(account_mapping1.status_change_timestamp, | 567 EXPECT_EQ(account_mapping1.status_change_timestamp, |
| 569 iter->second.status_change_timestamp); | 568 iter->status_change_timestamp); |
| 570 EXPECT_EQ(account_mapping1.last_message_id, iter->second.last_message_id); | 569 EXPECT_EQ(account_mapping1.last_message_id, iter->last_message_id); |
| 571 ++iter; | 570 ++iter; |
| 572 EXPECT_EQ("account_id_2", iter->first); | 571 EXPECT_EQ(account_mapping2.account_id, iter->account_id); |
| 573 EXPECT_EQ(account_mapping2.account_id, iter->second.account_id); | 572 EXPECT_EQ(account_mapping2.email, iter->email); |
| 574 EXPECT_EQ(account_mapping2.email, iter->second.email); | 573 EXPECT_TRUE(iter->access_token.empty()); |
| 575 EXPECT_TRUE(iter->second.access_token.empty()); | 574 EXPECT_EQ(AccountMapping::REMOVING, iter->status); |
| 576 EXPECT_EQ(AccountMapping::REMOVING, iter->second.status); | |
| 577 EXPECT_EQ(account_mapping2.status_change_timestamp, | 575 EXPECT_EQ(account_mapping2.status_change_timestamp, |
| 578 iter->second.status_change_timestamp); | 576 iter->status_change_timestamp); |
| 579 EXPECT_EQ(account_mapping2.last_message_id, iter->second.last_message_id); | 577 EXPECT_EQ(account_mapping2.last_message_id, iter->last_message_id); |
| 580 | 578 |
| 581 gcm_store->RemoveAccountMapping( | 579 gcm_store->RemoveAccountMapping( |
| 582 account_mapping1.account_id, | 580 account_mapping1.account_id, |
| 583 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); | 581 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); |
| 584 PumpLoop(); | 582 PumpLoop(); |
| 585 | 583 |
| 586 gcm_store = BuildGCMStore().Pass(); | 584 gcm_store = BuildGCMStore().Pass(); |
| 587 gcm_store->Load(base::Bind( | 585 gcm_store->Load(base::Bind( |
| 588 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 586 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 589 PumpLoop(); | 587 PumpLoop(); |
| 590 | 588 |
| 591 EXPECT_EQ(1UL, load_result->account_mappings.size()); | 589 EXPECT_EQ(1UL, load_result->account_mappings.size()); |
| 592 iter = load_result->account_mappings.begin(); | 590 iter = load_result->account_mappings.begin(); |
| 593 EXPECT_EQ("account_id_2", iter->first); | 591 EXPECT_EQ(account_mapping2.account_id, iter->account_id); |
| 594 EXPECT_EQ(account_mapping2.account_id, iter->second.account_id); | 592 EXPECT_EQ(account_mapping2.email, iter->email); |
| 595 EXPECT_EQ(account_mapping2.email, iter->second.email); | 593 EXPECT_TRUE(iter->access_token.empty()); |
| 596 EXPECT_TRUE(iter->second.access_token.empty()); | 594 EXPECT_EQ(AccountMapping::REMOVING, iter->status); |
| 597 EXPECT_EQ(AccountMapping::REMOVING, iter->second.status); | |
| 598 EXPECT_EQ(account_mapping2.status_change_timestamp, | 595 EXPECT_EQ(account_mapping2.status_change_timestamp, |
| 599 iter->second.status_change_timestamp); | 596 iter->status_change_timestamp); |
| 600 EXPECT_EQ(account_mapping2.last_message_id, iter->second.last_message_id); | 597 EXPECT_EQ(account_mapping2.last_message_id, iter->last_message_id); |
| 601 } | 598 } |
| 602 | 599 |
| 603 // When the database is destroyed, all database updates should fail. At the | 600 // When the database is destroyed, all database updates should fail. At the |
| 604 // same time, they per-app message counts should not go up, as failures should | 601 // same time, they per-app message counts should not go up, as failures should |
| 605 // result in decrementing the counts. | 602 // result in decrementing the counts. |
| 606 TEST_F(GCMStoreImplTest, AddMessageAfterDestroy) { | 603 TEST_F(GCMStoreImplTest, AddMessageAfterDestroy) { |
| 607 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); | 604 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); |
| 608 scoped_ptr<GCMStore::LoadResult> load_result; | 605 scoped_ptr<GCMStore::LoadResult> load_result; |
| 609 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 606 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
| 610 base::Unretained(this), | 607 base::Unretained(this), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 639 |
| 643 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, | 640 gcm_store->Load(base::Bind(&GCMStoreImplTest::LoadCallback, |
| 644 base::Unretained(this), | 641 base::Unretained(this), |
| 645 &load_result)); | 642 &load_result)); |
| 646 PumpLoop(); | 643 PumpLoop(); |
| 647 } | 644 } |
| 648 | 645 |
| 649 } // namespace | 646 } // namespace |
| 650 | 647 |
| 651 } // namespace gcm | 648 } // namespace gcm |
| OLD | NEW |