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

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

Issue 215363007: [GCM] Adding basic G-services handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding unit tests and addressing CR feedback Created 6 years, 9 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 0656ad2fe6b0daded0c1c2c8915d39b916677594..d190f65898fa6803fd6f5929c3780baf385d303d 100644
--- a/google_apis/gcm/engine/gcm_store_impl_unittest.cc
+++ b/google_apis/gcm/engine/gcm_store_impl_unittest.cc
@@ -108,6 +108,8 @@ TEST_F(GCMStoreImplTest, LoadNew) {
EXPECT_EQ(0U, load_result->device_security_token);
EXPECT_TRUE(load_result->incoming_messages.empty());
EXPECT_TRUE(load_result->outgoing_messages.empty());
+ EXPECT_TRUE(load_result->gservices_settings.empty());
+ EXPECT_EQ(base::Time::FromInternalValue(0LL), load_result->last_checkin_time);
}
TEST_F(GCMStoreImplTest, DeviceCredentials) {
@@ -132,6 +134,87 @@ TEST_F(GCMStoreImplTest, DeviceCredentials) {
ASSERT_EQ(kDeviceToken, load_result->device_security_token);
}
+TEST_F(GCMStoreImplTest, GServicesSettings) {
+ scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
+ scoped_ptr<GCMStore::LoadResult> load_result;
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+ PumpLoop();
+
+ std::vector<std::string> settings_to_remove;
+ std::map<std::string, std::string> settings_to_add;
+ settings_to_add["checkin_interval"] = "12345";
+ settings_to_add["mcs_port"] = "438";
+ settings_to_add["checkin_url"] = "http://checkin.google.com";
+ base::Time last_checkin_time = base::Time::Now();
+
+ std::map<std::string, std::string> expected_settings = settings_to_add;
+
+ gcm_store->UpdateGServicesSettings(
+ settings_to_remove,
+ settings_to_add,
+ last_checkin_time,
+ 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();
+
+ ASSERT_EQ(expected_settings, load_result->gservices_settings);
+ ASSERT_EQ(last_checkin_time, load_result->last_checkin_time);
+
+ // Remove some, and add some.
+ settings_to_add.clear();
+ settings_to_add["checkin_interval"] = "54321";
+ settings_to_add["registration_url"] = "http://registration.google.com";
+ settings_to_remove.push_back("checkin_url");
+ expected_settings = settings_to_add;
+ expected_settings["mcs_port"] = "438";
+ last_checkin_time = base::Time::Now();
+
+ gcm_store->UpdateGServicesSettings(
+ settings_to_remove,
+ settings_to_add,
+ last_checkin_time,
+ base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
+
+ gcm_store = BuildGCMStore().Pass();
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+ PumpLoop();
+
+ ASSERT_EQ(expected_settings, load_result->gservices_settings);
+ ASSERT_EQ(last_checkin_time, load_result->last_checkin_time);
+
+ // Replace the complete set of settings with a new set.
+ settings_to_add.clear();
+ settings_to_add["checkin_interval"] = "12345";
+ settings_to_add["checkin_url"] = "http://checkin.google.com";
+ settings_to_add["registration_url"] = "http://registration.google.com";
+ settings_to_remove.clear();
+ settings_to_remove.push_back("checkin_interval");
+ settings_to_remove.push_back("registration_url");
+ settings_to_remove.push_back("mcs_port");
+ expected_settings = settings_to_add;
+ last_checkin_time = base::Time::Now();
+
+ gcm_store->UpdateGServicesSettings(
+ settings_to_remove,
+ settings_to_add,
+ last_checkin_time,
+ base::Bind(&GCMStoreImplTest::UpdateCallback, base::Unretained(this)));
+
+ gcm_store = BuildGCMStore().Pass();
+ gcm_store->Load(base::Bind(
+ &GCMStoreImplTest::LoadCallback, base::Unretained(this), &load_result));
+ PumpLoop();
+
+ ASSERT_EQ(expected_settings, load_result->gservices_settings);
+ ASSERT_EQ(last_checkin_time, load_result->last_checkin_time);
+}
+
TEST_F(GCMStoreImplTest, Registrations) {
scoped_ptr<GCMStore> gcm_store(BuildGCMStore());
scoped_ptr<GCMStore::LoadResult> load_result;

Powered by Google App Engine
This is Rietveld 408576698