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

Unified Diff: components/gcm_driver/gcm_account_mapper_unittest.cc

Issue 618003002: [GCM] Handling connection events in GCMAccountTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing the test failing on a mac Created 6 years, 2 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
« no previous file with comments | « components/gcm_driver/gcm_account_mapper.cc ('k') | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_account_mapper_unittest.cc
diff --git a/components/gcm_driver/gcm_account_mapper_unittest.cc b/components/gcm_driver/gcm_account_mapper_unittest.cc
index 58fd82540c071725c1b3ba11bcf904da94592d27..a6a8412c60f57d7fff58efa739dabf3b6b39d299 100644
--- a/components/gcm_driver/gcm_account_mapper_unittest.cc
+++ b/components/gcm_driver/gcm_account_mapper_unittest.cc
@@ -16,7 +16,6 @@ namespace gcm {
namespace {
const char kGCMAccountMapperSenderId[] = "745476177629";
-const char kGCMAccountMapperAppId[] = "com.google.android.gms";
const char kRegistrationId[] = "reg_id";
AccountMapping MakeAccountMapping(const std::string& account_id,
@@ -272,6 +271,7 @@ GCMAccountMapperTest::~GCMAccountMapperTest() {
void GCMAccountMapperTest::Restart() {
if (account_mapper_)
account_mapper_->ShutdownHandler();
+ gcm_driver_.RemoveAppHandler(kGCMAccountMapperAppId);
account_mapper_.reset(new GCMAccountMapper(&gcm_driver_));
scoped_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock);
clock_ = clock.get();
@@ -434,6 +434,7 @@ TEST_F(GCMAccountMapperTest, AddMappingMessageQueued) {
// Tests status change from ADDING to MAPPED (Message is acknowledged).
TEST_F(GCMAccountMapperTest, AddMappingMessageAcknowledged) {
mapper()->Initialize(GCMAccountMapper::AccountMappings());
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
std::vector<GCMClient::AccountTokenInfo> account_tokens;
@@ -470,6 +471,7 @@ TEST_F(GCMAccountMapperTest, AddMappingMessageAcknowledged) {
// after Chrome was restarted).
TEST_F(GCMAccountMapperTest, AddMappingMessageAckedAfterRestart) {
mapper()->Initialize(GCMAccountMapper::AccountMappings());
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
std::vector<GCMClient::AccountTokenInfo> account_tokens;
@@ -484,6 +486,7 @@ TEST_F(GCMAccountMapperTest, AddMappingMessageAckedAfterRestart) {
GCMAccountMapper::AccountMappings stored_mappings;
stored_mappings.push_back(gcm_driver().last_account_mapping());
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
clock()->SetNow(base::Time::Now());
gcm_driver().AcknowledgeSend(gcm_driver().last_message_id());
@@ -511,6 +514,7 @@ TEST_F(GCMAccountMapperTest, AddMappingMessageAckedAfterRestart) {
// Tests a case when ADD message times out for a new account.
TEST_F(GCMAccountMapperTest, AddMappingMessageSendErrorForNewAccount) {
mapper()->Initialize(GCMAccountMapper::AccountMappings());
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
std::vector<GCMClient::AccountTokenInfo> account_tokens;
@@ -544,6 +548,7 @@ TEST_F(GCMAccountMapperTest, AddMappingMessageSendErrorForMappedAccount) {
GCMAccountMapper::AccountMappings stored_mappings;
stored_mappings.push_back(mapping);
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
clock()->SetNow(base::Time::Now());
@@ -651,6 +656,7 @@ TEST_F(GCMAccountMapperTest, RemoveMappingMessageAcknowledged) {
GCMAccountMapper::AccountMappings stored_mappings;
stored_mappings.push_back(mapping);
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
clock()->SetNow(base::Time::Now());
@@ -676,6 +682,7 @@ TEST_F(GCMAccountMapperTest, RemoveMappingMessageAckedAfterRestart) {
GCMAccountMapper::AccountMappings stored_mappings;
stored_mappings.push_back(mapping);
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().AcknowledgeSend("remove_message_id");
@@ -698,6 +705,7 @@ TEST_F(GCMAccountMapperTest, RemoveMappingMessageSendError) {
GCMAccountMapper::AccountMappings stored_mappings;
stored_mappings.push_back(mapping);
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
clock()->SetNow(base::Time::Now());
gcm_driver().MessageSendError("remove_message_id");
@@ -812,6 +820,7 @@ TEST_F(GCMAccountMapperTest, MultipleAccountMappings) {
"acc_id_2", AccountMapping::REMOVING, half_hour_ago, "acc_id_2_msg"));
mapper()->Initialize(stored_mappings);
+ gcm_driver().AddAppHandler(kGCMAccountMapperAppId, mapper());
gcm_driver().CompleteRegister(kRegistrationId, GCMClient::SUCCESS);
GCMAccountMapper::AccountMappings expected_mappings(stored_mappings);
« no previous file with comments | « components/gcm_driver/gcm_account_mapper.cc ('k') | components/gcm_driver/gcm_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698