| 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 c5fb250ed50518476a9f72149d140c7dda428f53..2b1e5014642e4cb160de5395474d9526bbf58e12 100644
|
| --- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
|
| +++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
|
| @@ -59,6 +59,9 @@ class GCMProfileServiceTest : public testing::Test {
|
|
|
| FakeGCMClient* GetGCMClient() const;
|
|
|
| + void CreateGCMProfileService();
|
| + void SignIn();
|
| +
|
| void RegisterAndWaitForCompletion(const std::vector<std::string>& sender_ids);
|
| void UnregisterAndWaitForCompletion();
|
| void SendAndWaitForCompletion(const GCMClient::OutgoingMessage& message);
|
| @@ -116,24 +119,28 @@ void GCMProfileServiceTest::SetUp() {
|
| builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
|
| FakeSigninManager::Build);
|
| profile_ = builder.Build();
|
| +}
|
| +
|
| +void GCMProfileServiceTest::TearDown() {
|
| + gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID);
|
| +}
|
|
|
| +void GCMProfileServiceTest::CreateGCMProfileService() {
|
| gcm_profile_service_ = static_cast<GCMProfileService*>(
|
| GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse(
|
| profile_.get(),
|
| &BuildGCMProfileService));
|
| gcm_profile_service_->driver()->AddAppHandler(
|
| kTestAppID, gcm_app_handler_.get());
|
| +}
|
|
|
| +void GCMProfileServiceTest::SignIn() {
|
| FakeSigninManager* signin_manager = static_cast<FakeSigninManager*>(
|
| SigninManagerFactory::GetInstance()->GetForProfile(profile_.get()));
|
| signin_manager->SignIn(kTestAccountID);
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| -void GCMProfileServiceTest::TearDown() {
|
| - gcm_profile_service_->driver()->RemoveAppHandler(kTestAppID);
|
| -}
|
| -
|
| void GCMProfileServiceTest::RegisterAndWaitForCompletion(
|
| const std::vector<std::string>& sender_ids) {
|
| base::RunLoop run_loop;
|
| @@ -194,7 +201,27 @@ void GCMProfileServiceTest::SendCompleted(
|
| callback.Run();
|
| }
|
|
|
| +TEST_F(GCMProfileServiceTest, CreateGCMProfileServiceBeforeSignIn) {
|
| + CreateGCMProfileService();
|
| + EXPECT_FALSE(driver()->IsStarted());
|
| +
|
| + SignIn();
|
| + EXPECT_TRUE(driver()->IsStarted());
|
| +}
|
| +
|
| +TEST_F(GCMProfileServiceTest, CreateGCMProfileServiceAfterSignIn) {
|
| + SignIn();
|
| + // Note that we can't check if GCM is started or not since the
|
| + // GCMProfileService that hosts the GCMDriver is not created yet.
|
| +
|
| + CreateGCMProfileService();
|
| + EXPECT_TRUE(driver()->IsStarted());
|
| +}
|
| +
|
| TEST_F(GCMProfileServiceTest, RegisterAndUnregister) {
|
| + CreateGCMProfileService();
|
| + SignIn();
|
| +
|
| std::vector<std::string> sender_ids;
|
| sender_ids.push_back("sender");
|
| RegisterAndWaitForCompletion(sender_ids);
|
| @@ -209,6 +236,9 @@ TEST_F(GCMProfileServiceTest, RegisterAndUnregister) {
|
| }
|
|
|
| TEST_F(GCMProfileServiceTest, Send) {
|
| + CreateGCMProfileService();
|
| + SignIn();
|
| +
|
| GCMClient::OutgoingMessage message;
|
| message.id = "1";
|
| message.data["key1"] = "value1";
|
|
|