Chromium Code Reviews| Index: chrome/browser/services/gcm/gcm_profile_service_unittest.cc |
| diff --git a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc |
| index b3cac28fc7722ea00a3599b568ff54b75ce629c6..34aa59a982fd7cffe2c09404f515acda3627c7b2 100644 |
| --- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc |
| +++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc |
| @@ -360,10 +360,10 @@ class GCMProfileServiceTestConsumer : public GCMProfileService::TestingDelegate{ |
| } |
| void Register(const std::string& app_id, |
| - const std::vector<std::string>& sender_ids) { |
| + const std::string& sender_id) { |
| GetGCMProfileService()->Register( |
| app_id, |
| - sender_ids, |
| + sender_id, |
| kTestingSha1Cert, |
| base::Bind(&GCMProfileServiceTestConsumer::RegisterCompleted, |
| base::Unretained(this))); |
| @@ -652,9 +652,7 @@ TEST_F(GCMProfileServiceTest, SignOutAndThenSignIn) { |
| TEST_F(GCMProfileServiceTest, RegisterWhenNotSignedIn) { |
| consumer()->CreateGCMProfileServiceInstance(); |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); |
| @@ -673,9 +671,7 @@ TEST_F(GCMProfileServiceTest, RegisterUnderNeutralChannelSignal) { |
| EXPECT_EQ(GCMClientMock::UNINITIALIZED, consumer()->GetGCMClient()->status()); |
| // Invoking register will make GCMClient checked in. |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| WaitUntilCompleted(); |
| // GCMClient should be checked in. |
| @@ -684,7 +680,7 @@ TEST_F(GCMProfileServiceTest, RegisterUnderNeutralChannelSignal) { |
| // Registration should succeed. |
| std::string expected_registration_id = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender1"); |
| EXPECT_EQ(expected_registration_id, consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| } |
| @@ -747,11 +743,9 @@ class GCMProfileServiceSingleProfileTest : public GCMProfileServiceTest { |
| }; |
| TEST_F(GCMProfileServiceSingleProfileTest, Register) { |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| std::string expected_registration_id = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender1"); |
| WaitUntilCompleted(); |
| EXPECT_EQ(expected_registration_id, consumer()->registration_id()); |
| @@ -759,16 +753,13 @@ TEST_F(GCMProfileServiceSingleProfileTest, Register) { |
| } |
| TEST_F(GCMProfileServiceSingleProfileTest, DoubleRegister) { |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| std::string expected_registration_id = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender1"); |
| // Calling regsiter 2nd time without waiting 1st one to finish will fail |
| // immediately. |
| - sender_ids.push_back("sender2"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender2"); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| EXPECT_EQ(GCMClient::ASYNC_OPERATION_PENDING, |
| consumer()->registration_result()); |
| @@ -780,9 +771,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, DoubleRegister) { |
| } |
| TEST_F(GCMProfileServiceSingleProfileTest, RegisterError) { |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1@error"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sedner1@error"); |
|
jianli
2014/03/03 21:29:31
nit: typo for sender
fgorski
2014/03/03 23:14:16
Done. Brilliant catch!
|
| WaitUntilCompleted(); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| @@ -790,12 +779,9 @@ TEST_F(GCMProfileServiceSingleProfileTest, RegisterError) { |
| } |
| TEST_F(GCMProfileServiceSingleProfileTest, RegisterAgainWithSameSenderIDs) { |
|
jianli
2014/03/03 21:29:31
Remove the trailing "s" from the test case name.
fgorski
2014/03/03 23:14:16
Done.
|
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - sender_ids.push_back("sender2"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| std::string expected_registration_id = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender1"); |
| WaitUntilCompleted(); |
| EXPECT_EQ(expected_registration_id, consumer()->registration_id()); |
| @@ -805,37 +791,30 @@ TEST_F(GCMProfileServiceSingleProfileTest, RegisterAgainWithSameSenderIDs) { |
| // to call register 2nd time. |
| consumer()->clear_registration_result(); |
| - // Calling register 2nd time with the same set of sender IDs but different |
| - // ordering will get back the same registration ID. There is no need to wait |
| - // since register simply returns the cached registration ID. |
| - std::vector<std::string> another_sender_ids; |
| - another_sender_ids.push_back("sender2"); |
| - another_sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, another_sender_ids); |
| + // Calling register 2nd time will get back the same registration ID. There is |
| + // no need to wait since register simply returns the cached registration ID. |
| + consumer()->Register(kTestingAppId, "sender1"); |
| EXPECT_EQ(expected_registration_id, consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| } |
| TEST_F(GCMProfileServiceSingleProfileTest, |
| RegisterAgainWithDifferentSenderIDs) { |
|
jianli
2014/03/03 21:29:31
ditto.
fgorski
2014/03/03 23:14:16
Done.
|
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| std::string expected_registration_id = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender1"); |
| WaitUntilCompleted(); |
| EXPECT_EQ(expected_registration_id, consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| // Make sender IDs different. |
|
jianli
2014/03/03 21:29:31
IDs => ID
fgorski
2014/03/03 23:14:16
Done.
|
| - sender_ids.push_back("sender2"); |
| std::string expected_registration_id2 = |
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids); |
| + GCMClientMock::GetRegistrationIdFromSenderIds("sender2"); |
| // Calling register 2nd time with the different sender IDs will get back a new |
| // registration ID. |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender2"); |
| WaitUntilCompleted(); |
| EXPECT_EQ(expected_registration_id2, consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| @@ -844,9 +823,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, |
| TEST_F(GCMProfileServiceSingleProfileTest, ReadRegistrationFromStateStore) { |
| scoped_refptr<Extension> extension(consumer()->CreateExtension()); |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(extension->id(), sender_ids); |
| + consumer()->Register(extension->id(), "sender1"); |
| WaitUntilCompleted(); |
| EXPECT_FALSE(consumer()->registration_id().empty()); |
| @@ -868,7 +845,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, ReadRegistrationFromStateStore) { |
| consumer()->ReloadExtension(extension); |
| // This should read the registration info from the extension's state store. |
| - consumer()->Register(extension->id(), sender_ids); |
| + consumer()->Register(extension->id(), "sender1"); |
| PumpIOLoop(); |
| PumpUILoop(); |
| EXPECT_EQ(old_registration_id, consumer()->registration_id()); |
| @@ -879,9 +856,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, |
| GCMClientReadyAfterReadingRegistration) { |
| scoped_refptr<Extension> extension(consumer()->CreateExtension()); |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(extension->id(), sender_ids); |
| + consumer()->Register(extension->id(), "sender1"); |
| WaitUntilCompleted(); |
| EXPECT_FALSE(consumer()->registration_id().empty()); |
| @@ -901,7 +876,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, |
| // Read the registration info from the extension's state store. |
| // This would hold up because GCMClient is in loading state. |
| - consumer()->Register(extension->id(), sender_ids); |
| + consumer()->Register(extension->id(), "sender1"); |
| base::RunLoop().RunUntilIdle(); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| EXPECT_EQ(GCMClient::UNKNOWN_ERROR, consumer()->registration_result()); |
| @@ -915,9 +890,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, |
| TEST_F(GCMProfileServiceSingleProfileTest, |
| PersistedRegistrationInfoRemoveAfterSignOut) { |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| WaitUntilCompleted(); |
| // The app id and registration info should be persisted. |
| @@ -936,9 +909,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, RegisterAfterSignOut) { |
| // This will trigger check-out. |
| consumer()->SignOut(); |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); |
| @@ -947,9 +918,7 @@ TEST_F(GCMProfileServiceSingleProfileTest, RegisterAfterSignOut) { |
| TEST_F(GCMProfileServiceSingleProfileTest, Unregister) { |
| scoped_refptr<Extension> extension(consumer()->CreateExtension()); |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(extension->id(), sender_ids); |
| + consumer()->Register(extension->id(), "sender1"); |
| WaitUntilCompleted(); |
| EXPECT_FALSE(consumer()->registration_id().empty()); |
| @@ -1082,37 +1051,28 @@ class GCMProfileServiceMultiProfileTest : public GCMProfileServiceTest { |
| TEST_F(GCMProfileServiceMultiProfileTest, Register) { |
| // Register an app. |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| // Register the same app in a different profile. |
| - std::vector<std::string> sender_ids2; |
| - sender_ids2.push_back("foo"); |
| - sender_ids2.push_back("bar"); |
| - consumer2()->Register(kTestingAppId, sender_ids2); |
| + consumer2()->Register(kTestingAppId, "sender2"); |
| WaitUntilCompleted(); |
| WaitUntilCompleted(); |
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids), |
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds("sender1"), |
| consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids2), |
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds("sender2"), |
| consumer2()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| // Register a different app in a different profile. |
| - std::vector<std::string> sender_ids3; |
| - sender_ids3.push_back("sender1"); |
| - sender_ids3.push_back("sender2"); |
| - sender_ids3.push_back("sender3"); |
| - consumer2()->Register(kTestingAppId2, sender_ids3); |
| + consumer2()->Register(kTestingAppId2, "sender3"); |
| WaitUntilCompleted(); |
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids3), |
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds("sender3"), |
| consumer2()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer2()->registration_result()); |
| } |
| @@ -1204,32 +1164,23 @@ TEST_F(GCMProfileServiceMultiProfileTest, MessageReceived) { |
| // 9) The message to the new signed-in user will be routed. |
| TEST_F(GCMProfileServiceMultiProfileTest, Combined) { |
| // Register an app. |
| - std::vector<std::string> sender_ids; |
| - sender_ids.push_back("sender1"); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| // Register the same app in a different profile. |
| - std::vector<std::string> sender_ids2; |
| - sender_ids2.push_back("foo"); |
| - sender_ids2.push_back("bar"); |
| - consumer2()->Register(kTestingAppId, sender_ids2); |
| + consumer2()->Register(kTestingAppId, "sender2"); |
| // Register a different app in a different profile. |
| - std::vector<std::string> sender_ids3; |
| - sender_ids3.push_back("sender1"); |
| - sender_ids3.push_back("sender2"); |
| - sender_ids3.push_back("sender3"); |
| - consumer2()->Register(kTestingAppId2, sender_ids3); |
| + consumer2()->Register(kTestingAppId2, "sender3"); |
| WaitUntilCompleted(); |
| WaitUntilCompleted(); |
| WaitUntilCompleted(); |
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids), |
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds("sender1"), |
| consumer()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids3), |
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds("sender3"), |
| consumer2()->registration_id()); |
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result()); |
| @@ -1314,7 +1265,7 @@ TEST_F(GCMProfileServiceMultiProfileTest, Combined) { |
| // Register/send stops working for signed-out profile. |
| consumer()->gcm_event_router()->clear_results(); |
| - consumer()->Register(kTestingAppId, sender_ids); |
| + consumer()->Register(kTestingAppId, "sender1"); |
| EXPECT_TRUE(consumer()->registration_id().empty()); |
| EXPECT_EQ(GCMClient::NOT_SIGNED_IN, consumer()->registration_result()); |