| 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 d060cc0b7d6df22be5debf3978129a503be8ff15..10870fe3a1749ad6caa2d22d194bd3de2241b657 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::GetRegistrationIdFromSenderId("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::GetRegistrationIdFromSenderId("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::GetRegistrationIdFromSenderId("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,22 +771,17 @@ 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, "sender1@error");
|
|
|
| WaitUntilCompleted();
|
| EXPECT_TRUE(consumer()->registration_id().empty());
|
| EXPECT_NE(GCMClient::SUCCESS, consumer()->registration_result());
|
| }
|
|
|
| -TEST_F(GCMProfileServiceSingleProfileTest, RegisterAgainWithSameSenderIDs) {
|
| - std::vector<std::string> sender_ids;
|
| - sender_ids.push_back("sender1");
|
| - sender_ids.push_back("sender2");
|
| - consumer()->Register(kTestingAppId, sender_ids);
|
| +TEST_F(GCMProfileServiceSingleProfileTest, RegisterAgainWithSameSenderID) {
|
| + consumer()->Register(kTestingAppId, "sender1");
|
| std::string expected_registration_id =
|
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
| + GCMClientMock::GetRegistrationIdFromSenderId("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) {
|
| - std::vector<std::string> sender_ids;
|
| - sender_ids.push_back("sender1");
|
| - consumer()->Register(kTestingAppId, sender_ids);
|
| + RegisterAgainWithDifferentSenderID) {
|
| + consumer()->Register(kTestingAppId, "sender1");
|
| std::string expected_registration_id =
|
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
| + GCMClientMock::GetRegistrationIdFromSenderId("sender1");
|
|
|
| WaitUntilCompleted();
|
| EXPECT_EQ(expected_registration_id, consumer()->registration_id());
|
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result());
|
|
|
| - // Make sender IDs different.
|
| - sender_ids.push_back("sender2");
|
| + // Make sender ID different.
|
| std::string expected_registration_id2 =
|
| - GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids);
|
| + GCMClientMock::GetRegistrationIdFromSenderId("sender2");
|
|
|
| - // Calling register 2nd time with the different sender IDs will get back a new
|
| + // Calling register 2nd time with a different sender ID 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());
|
| @@ -1097,37 +1066,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::GetRegistrationIdFromSenderId("sender1"),
|
| consumer()->registration_id());
|
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result());
|
|
|
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids2),
|
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderId("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::GetRegistrationIdFromSenderId("sender3"),
|
| consumer2()->registration_id());
|
| EXPECT_EQ(GCMClient::SUCCESS, consumer2()->registration_result());
|
| }
|
| @@ -1219,32 +1179,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::GetRegistrationIdFromSenderId("sender1"),
|
| consumer()->registration_id());
|
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result());
|
|
|
| - EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderIds(sender_ids3),
|
| + EXPECT_EQ(GCMClientMock::GetRegistrationIdFromSenderId("sender3"),
|
| consumer2()->registration_id());
|
| EXPECT_EQ(GCMClient::SUCCESS, consumer()->registration_result());
|
|
|
| @@ -1329,7 +1280,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());
|
|
|
|
|