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

Side by Side Diff: google_apis/gcm/engine/gservices_settings_unittest.cc

Issue 252933002: [GCM] fixing G-settings initialization from an empty store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "google_apis/gcm/engine/gservices_settings.h" 6 #include "google_apis/gcm/engine/gservices_settings.h"
7 #include "google_apis/gcm/engine/registration_info.h" 7 #include "google_apis/gcm/engine/registration_info.h"
8 #include "google_apis/gcm/gcm_client.h" 8 #include "google_apis/gcm/gcm_client.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace gcm { 11 namespace gcm {
12 12
13 namespace { 13 namespace {
14 14
15 const int64 kAlternativeCheckinInterval = 2000LL; 15 const int64 kAlternativeCheckinInterval = 16 * 60 * 60;
16 const char kAlternativeCheckinURL[] = "http://alternative.url/checkin"; 16 const char kAlternativeCheckinURL[] = "http://alternative.url/checkin";
17 const char kAlternativeMCSHostname[] = "http://alternative.gcm.host"; 17 const char kAlternativeMCSHostname[] = "http://alternative.gcm.host";
18 const int kAlternativeMCSSecurePort = 443; 18 const int kAlternativeMCSSecurePort = 443;
19 const char kAlternativeRegistrationURL[] = 19 const char kAlternativeRegistrationURL[] =
20 "http://alternative.url/registration"; 20 "http://alternative.url/registration";
21 21
22 const int64 kDefaultCheckinInterval = 2 * 24 * 60 * 60; // seconds = 2 days. 22 const int64 kDefaultCheckinInterval = 2 * 24 * 60 * 60; // seconds = 2 days.
23 const char kDefaultCheckinURL[] = "https://android.clients.google.com/checkin"; 23 const char kDefaultCheckinURL[] = "https://android.clients.google.com/checkin";
24 const char kDefaultMCSHostname[] = "https://mtalk.google.com"; 24 const char kDefaultMCSHostname[] = "https://mtalk.google.com";
25 const int kDefaultMCSSecurePort = 5228; 25 const int kDefaultMCSSecurePort = 5228;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 } 171 }
172 172
173 // Verifies default values of the G-services settings and settings digest. 173 // Verifies default values of the G-services settings and settings digest.
174 TEST_F(GServicesSettingsTest, DefaultSettingsAndDigest) { 174 TEST_F(GServicesSettingsTest, DefaultSettingsAndDigest) {
175 CheckAllSetToDefault(); 175 CheckAllSetToDefault();
176 EXPECT_EQ(std::string(), settings().digest()); 176 EXPECT_EQ(std::string(), settings().digest());
177 } 177 }
178 178
179 // Verifies that the settings are set correctly based on the load result. 179 // Verifies that the settings are set correctly based on the load result.
180 TEST_F(GServicesSettingsTest, UpdateFromEmptyLoadResult) {
181 GCMStore::LoadResult result;
182 result.gservices_digest = "digest_value";
183 settings().UpdateFromLoadResult(result);
184
185 CheckAllSetToDefault();
186 EXPECT_EQ(std::string(), settings().digest());
187 }
188
189 // Verifies that the settings are set correctly based on the load result.
180 TEST_F(GServicesSettingsTest, UpdateFromLoadResult) { 190 TEST_F(GServicesSettingsTest, UpdateFromLoadResult) {
181 GCMStore::LoadResult result; 191 GCMStore::LoadResult result;
182 result.gservices_settings = alternative_settings(); 192 result.gservices_settings = alternative_settings();
183 result.gservices_digest = "digest_value"; 193 result.gservices_digest = "digest_value";
184 settings().UpdateFromLoadResult(result); 194 settings().UpdateFromLoadResult(result);
185 195
186 CheckAllSetToAlternative(); 196 CheckAllSetToAlternative();
187 EXPECT_EQ("digest_value", settings().digest()); 197 EXPECT_EQ("digest_value", settings().digest());
188 } 198 }
189 199
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 checkin_response.set_digest("old_digest"); 235 checkin_response.set_digest("old_digest");
226 SetWithAlternativeSettings(checkin_response); 236 SetWithAlternativeSettings(checkin_response);
227 settings().UpdateFromCheckinResponse(checkin_response); 237 settings().UpdateFromCheckinResponse(checkin_response);
228 EXPECT_FALSE(gcm_store().settings_saved()); 238 EXPECT_FALSE(gcm_store().settings_saved());
229 239
230 CheckAllSetToAlternative(); 240 CheckAllSetToAlternative();
231 EXPECT_EQ("old_digest", settings().digest()); 241 EXPECT_EQ("old_digest", settings().digest());
232 } 242 }
233 243
234 } // namespace gcm 244 } // namespace gcm
OLDNEW
« google_apis/gcm/engine/gservices_settings.cc ('K') | « google_apis/gcm/engine/gservices_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698