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

Unified Diff: google_apis/gcm/engine/gcm_store_impl_unittest.cc

Issue 1121003003: [GCM] Adding handling of heartbeat intervals to the GCM store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@heartbeat-gcm
Patch Set: Adding histrograms Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698