Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Number of persistent ids to use in tests. | 28 // Number of persistent ids to use in tests. |
| 29 const int kNumPersistentIds = 10; | 29 const int kNumPersistentIds = 10; |
| 30 | 30 |
| 31 // Number of per-app messages in tests. | 31 // Number of per-app messages in tests. |
| 32 const int kNumMessagesPerApp = 20; | 32 const int kNumMessagesPerApp = 20; |
| 33 | 33 |
| 34 // App name for testing. | 34 // App name for testing. |
| 35 const char kAppName[] = "my_app"; | 35 const char kAppName[] = "my_app"; |
| 36 const char kAppName2[] = "my_app_2"; | |
| 36 | 37 |
| 37 // Category name for testing. | 38 // Category name for testing. |
| 38 const char kCategoryName[] = "my_category"; | 39 const char kCategoryName[] = "my_category"; |
| 39 | 40 |
| 40 const uint64 kDeviceId = 22; | 41 const uint64 kDeviceId = 22; |
| 41 const uint64 kDeviceToken = 55; | 42 const uint64 kDeviceToken = 55; |
| 42 | 43 |
| 43 class GCMStoreImplTest : public testing::Test { | 44 class GCMStoreImplTest : public testing::Test { |
| 44 public: | 45 public: |
| 45 GCMStoreImplTest(); | 46 GCMStoreImplTest(); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); | 735 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); |
| 735 PumpLoop(); | 736 PumpLoop(); |
| 736 | 737 |
| 737 gcm_store = BuildGCMStore().Pass(); | 738 gcm_store = BuildGCMStore().Pass(); |
| 738 gcm_store->Load(base::Bind( | 739 gcm_store->Load(base::Bind( |
| 739 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | 740 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); |
| 740 PumpLoop(); | 741 PumpLoop(); |
| 741 EXPECT_EQ(base::Time(), load_result->last_token_fetch_time); | 742 EXPECT_EQ(base::Time(), load_result->last_token_fetch_time); |
| 742 } | 743 } |
| 743 | 744 |
| 745 TEST_F(GCMStoreImplTest, InstanceIDData) { | |
| 746 scoped_ptr<GCMStore> gcm_store(BuildGCMStore()); | |
| 747 scoped_ptr<GCMStore::LoadResult> load_result; | |
| 748 gcm_store->Load(base::Bind( | |
| 749 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | |
| 750 PumpLoop(); | |
| 751 | |
| 752 std::string instance_id_data("Foo"); | |
| 753 gcm_store->AddInstanceIDData( | |
| 754 kAppName, | |
| 755 instance_id_data, | |
| 756 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); | |
| 757 PumpLoop(); | |
| 758 | |
| 759 std::string instance_id_data2("Hello Instance ID"); | |
| 760 gcm_store->AddInstanceIDData( | |
| 761 kAppName2, | |
| 762 instance_id_data2, | |
| 763 base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this))); | |
| 764 PumpLoop(); | |
| 765 | |
| 766 gcm_store = BuildGCMStore().Pass(); | |
| 767 gcm_store->Load(base::Bind( | |
| 768 &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result)); | |
| 769 PumpLoop(); | |
| 770 | |
| 771 ASSERT_EQ(2u, load_result->instance_id_data.size()); | |
| 772 ASSERT_TRUE(load_result->instance_id_data.find(kAppName) != | |
| 773 load_result->instance_id_data.end()); | |
| 774 ASSERT_TRUE(load_result->instance_id_data.find(kAppName2) != | |
| 775 load_result->instance_id_data.end()); | |
| 776 EXPECT_EQ(instance_id_data, load_result->instance_id_data[kAppName]); | |
| 777 EXPECT_EQ(instance_id_data2, load_result->instance_id_data[kAppName2]); | |
|
fgorski
2015/05/08 17:12:33
add a test for delete
jianli
2015/05/08 20:56:01
Done.
| |
| 778 } | |
| 779 | |
| 744 } // namespace | 780 } // namespace |
| 745 | 781 |
| 746 } // namespace gcm | 782 } // namespace gcm |
| OLD | NEW |