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

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: Tweak argument wrapping 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..3d2d2109cdfbe5eb0858b789bccd4fbc4c3e5837 100644
--- a/chrome/browser/services/gcm/fake_gcm_profile_service.cc
+++ b/chrome/browser/services/gcm/fake_gcm_profile_service.cc
@@ -5,8 +5,10 @@
#include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
#include "base/bind.h"
+#include "base/format_macros.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/profiles/profile.h"
#include "components/gcm_driver/fake_gcm_client_factory.h"
#include "components/gcm_driver/fake_gcm_driver.h"
@@ -111,7 +113,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 +129,18 @@ void FakeGCMProfileService::RegisterFinished(
last_registered_sender_ids_ = sender_ids;
}
+ // Generate fake registration IDs, encoding the number of sender IDs (used by
+ // GcmApiTest.RegisterValidation), then an incrementing count (even for the
+ // same app_id - there's no caching) so tests can distinguish registrations.
+ std::string registration_id = base::StringPrintf("%" PRIuS "-%d",
+ sender_ids.size(),
+ registration_count_);
+ ++registration_count_;
+
CustomFakeGCMDriver* custom_driver =
static_cast<CustomFakeGCMDriver*>(driver());
- custom_driver->OnRegisterFinished(app_id,
- base::UintToString(sender_ids.size()),
- GCMClient::SUCCESS);
+ custom_driver->OnRegisterFinished(
+ app_id, registration_id, GCMClient::SUCCESS);
}
void FakeGCMProfileService::UnregisterFinished(const std::string& app_id) {
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_profile_service.h ('k') | chrome/browser/services/gcm/push_messaging_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698