Chromium Code Reviews| 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..2c610720683d92d89df8f7f6bf07ce980a77aa6e 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", |
|
fgorski
2014/12/10 17:34:55
huh? What is that thing?
johnme
2014/12/11 14:25:06
It's how you printf a size_t. See:
https://google
|
| + 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, |
|
fgorski
2014/12/10 17:34:55
put all of the arguments on a single line below th
johnme
2014/12/11 14:25:06
Done.
|
| + GCMClient::SUCCESS); |
| } |
| void FakeGCMProfileService::UnregisterFinished(const std::string& app_id) { |