| Index: google_apis/gcm/engine/gcm_store_impl_unittest.cc
|
| diff --git a/google_apis/gcm/engine/gcm_store_impl_unittest.cc b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
|
| index 66177d261edab2f05b0a1edf29918ba1594de914..1a6c4bb996af57d9c9040106f73bb363cc8256dd 100644
|
| --- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
|
| +++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
|
| @@ -610,6 +610,57 @@ TEST_F(GCMStoreImplTest, AccountMapping) {
|
| EXPECT_EQ(account_mapping2.last_message_id, iter->last_message_id);
|
| }
|
|
|
| +TEST_F(GCMStoreImplTest, HeartbeatInterval) {
|
| + scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
|
| + scoped_ptr<GCMStore::LoadResult> load_result;
|
| + gcm_store->Load(base::Bind(
|
| + &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
|
| +
|
| + std::string scope1 = "scope1";
|
| + std::string scope2 = "scope2";
|
| + int heartbeat1 = 120 * 1000;
|
| + int heartbeat2 = 360 * 1000;
|
| +
|
| + gcm_store->AddHeartbeatInterval(
|
| + scope1,
|
| + heartbeat1,
|
| + base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
|
| + PumpLoop();
|
| + gcm_store->AddHeartbeatInterval(
|
| + scope2,
|
| + heartbeat2,
|
| + base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
|
| + PumpLoop();
|
| +
|
| + gcm_store = BuildGCMStore().Pass();
|
| + gcm_store->Load(base::Bind(
|
| + &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
|
| + PumpLoop();
|
| +
|
| + EXPECT_EQ(2UL, load_result->heartbeat_intervals.size());
|
| + ASSERT_TRUE(load_result->heartbeat_intervals.find(scope1) !=
|
| + load_result->heartbeat_intervals.end());
|
| + EXPECT_EQ(heartbeat1, load_result->heartbeat_intervals[scope1]);
|
| + ASSERT_TRUE(load_result->heartbeat_intervals.find(scope2) !=
|
| + load_result->heartbeat_intervals.end());
|
| + EXPECT_EQ(heartbeat2, load_result->heartbeat_intervals[scope2]);
|
| +
|
| + gcm_store->RemoveHeartbeatInterval(
|
| + scope2,
|
| + base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
|
| + PumpLoop();
|
| +
|
| + gcm_store = BuildGCMStore().Pass();
|
| + gcm_store->Load(base::Bind(
|
| + &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
|
| + PumpLoop();
|
| +
|
| + EXPECT_EQ(1UL, load_result->heartbeat_intervals.size());
|
| + ASSERT_TRUE(load_result->heartbeat_intervals.find(scope1) !=
|
| + load_result->heartbeat_intervals.end());
|
| + EXPECT_EQ(heartbeat1, load_result->heartbeat_intervals[scope1]);
|
| +}
|
| +
|
| // When the database is destroyed, all database updates should fail. At the
|
| // same time, they per-app message counts should not go up, as failures should
|
| // result in decrementing the counts.
|
|
|