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

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

Issue 429073002: [GCM] Persistence of account mappings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing the gn build Created 6 years, 4 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
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ad4b024ee02bebd6c9e4a849e6c9fb7c5e5c3ff5..cb477499577a4147d05c2ba6aa670317a27880dc 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -45,8 +45,6 @@ class GCMStoreImplTest : public testing::Test {
GCMStoreImplTest();
virtual ~GCMStoreImplTest();
- virtual void SetUp() OVERRIDE;
-
scoped_ptr<GCMStore> BuildGCMStore();
std::string GetNextPersistentId();
@@ -74,10 +72,6 @@ GCMStoreImplTest::GCMStoreImplTest()
GCMStoreImplTest::~GCMStoreImplTest() {}
-void GCMStoreImplTest::SetUp() {
- testing::Test::SetUp();
-}
-
scoped_ptr<GCMStore> GCMStoreImplTest::BuildGCMStore() {
return scoped_ptr<GCMStore>(new GCMStoreImpl(
temp_directory_.path(),
@@ -506,6 +500,81 @@ TEST_F(GCMStoreImplTest, PerAppMessageLimits) {
}
}
+TEST_F(GCMStoreImplTest, AccountMapping) {
+ scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
+ scoped_ptr<GCMStore::LoadResult> load_result;
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+
+ // Add account mappings.
+ AccountInfo account_info1;
+ account_info1.account_id = "account_id_1";
+ account_info1.email = "account_id_1@gmail.com";
+ account_info1.last_message_type = AccountInfo::MSG_ADD;
+ account_info1.last_message_id = "message_1";
+ account_info1.last_message_timestamp =
+ base::Time::FromInternalValue(1305797421259935LL);
+ AccountInfo account_info2;
+ account_info2.account_id = "account_id_2";
+ account_info2.email = "account_id_2@gmail.com";
+ account_info2.last_message_type = AccountInfo::MSG_REMOVE;
+ account_info2.last_message_id = "message_2";
+ account_info2.last_message_timestamp =
+ base::Time::FromInternalValue(1305734521259935LL);
+
+ gcm_store->AddAccountMapping(
+ account_info1,
+ base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
+ PumpLoop();
+ gcm_store->AddAccountMapping(
+ account_info2,
+ 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->account_infos.size());
+ GCMStore::AccountInfoMap::iterator iter = load_result->account_infos.begin();
+ EXPECT_EQ("account_id_1", iter->first);
+ EXPECT_EQ(account_info1.account_id, iter->second.account_id);
+ EXPECT_EQ(account_info1.email, iter->second.email);
+ EXPECT_EQ(account_info1.last_message_type, iter->second.last_message_type);
+ EXPECT_EQ(account_info1.last_message_id, iter->second.last_message_id);
+ EXPECT_EQ(account_info1.last_message_timestamp,
+ iter->second.last_message_timestamp);
+ ++iter;
+ EXPECT_EQ("account_id_2", iter->first);
+ EXPECT_EQ(account_info2.account_id, iter->second.account_id);
+ EXPECT_EQ(account_info2.email, iter->second.email);
+ EXPECT_EQ(account_info2.last_message_type, iter->second.last_message_type);
+ EXPECT_EQ(account_info2.last_message_id, iter->second.last_message_id);
+ EXPECT_EQ(account_info2.last_message_timestamp,
+ iter->second.last_message_timestamp);
+
+ gcm_store->RemoveAccountMapping(
+ account_info1.account_id,
+ 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->account_infos.size());
+ iter = load_result->account_infos.begin();
+ EXPECT_EQ("account_id_2", iter->first);
+ EXPECT_EQ(account_info2.account_id, iter->second.account_id);
+ EXPECT_EQ(account_info2.email, iter->second.email);
+ EXPECT_EQ(account_info2.last_message_type, iter->second.last_message_type);
+ EXPECT_EQ(account_info2.last_message_id, iter->second.last_message_id);
+ EXPECT_EQ(account_info2.last_message_timestamp,
+ iter->second.last_message_timestamp);
+}
+
// 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.
« no previous file with comments | « google_apis/gcm/engine/gcm_store_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698