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

Unified Diff: chrome/browser/services/gcm/fake_gcm_profile_service.cc

Issue 785983002: Have FakeGCMProfileService return different registration IDs each time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IntToString instead of UintToString Created 6 years 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: chrome/browser/services/gcm/fake_gcm_profile_service.cc
diff --git a/chrome/browser/services/gcm/fake_gcm_profile_service.cc b/chrome/browser/services/gcm/fake_gcm_profile_service.cc
index b5bdb17f1432151ac7b9509bea12d73500e59cb3..c2f05eda599ad38d7c3dde779ba1c889f6256490 100644
--- a/chrome/browser/services/gcm/fake_gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/fake_gcm_profile_service.cc
@@ -111,7 +111,8 @@ KeyedService* FakeGCMProfileService::Build(content::BrowserContext* context) {
}
FakeGCMProfileService::FakeGCMProfileService(Profile* profile)
- : collect_(false) {
+ : collect_(false),
+ registration_count_(0) {
static_cast<PushMessagingServiceImpl*>(push_messaging_service())
->SetProfileForTesting(profile);
}
@@ -126,11 +127,17 @@ void FakeGCMProfileService::RegisterFinished(
last_registered_sender_ids_ = sender_ids;
}
+ // Generate fake registration IDs with an incrementing count (even for the
+ // same app_id - there's no caching), so tests can distinguish registrations.
+ // The ID also encodes the number of sender IDs which is used by
+ // GcmApiTest.RegisterValidation, but in the most common case of a single
+ // sender ID, this component will be zero (to avoid rebasing existing tests).
+ int registration_id = ++registration_count_ + 1000 * (sender_ids.size() - 1);
fgorski 2014/12/08 22:36:59 why not? int registration_id = registration_count_
johnme 2014/12/10 14:12:53 Ok, I've changed it to a simpler format: sende
+
CustomFakeGCMDriver* custom_driver =
static_cast<CustomFakeGCMDriver*>(driver());
- custom_driver->OnRegisterFinished(app_id,
- base::UintToString(sender_ids.size()),
- GCMClient::SUCCESS);
+ custom_driver->OnRegisterFinished(app_id, base::IntToString(registration_id),
+ GCMClient::SUCCESS);
}
void FakeGCMProfileService::UnregisterFinished(const std::string& app_id) {

Powered by Google App Engine
This is Rietveld 408576698