Commit 2f90d82b authored by jianli's avatar jianli Committed by Commit bot

Clear GCMProfileService::account_id_ in when signing out

This fixed the bug that signing out and then signing in again does not
restart GCM.

BUG=393043
TEST=new test added

Review URL: https://codereview.chromium.org/535393002

Cr-Commit-Position: refs/heads/master@{#293319}
parent 1bd9a310
......@@ -111,6 +111,8 @@ void GCMProfileService::IdentityObserver::OnActiveAccountLogin() {
}
void GCMProfileService::IdentityObserver::OnActiveAccountLogout() {
account_id_.clear();
// Check is necessary to not crash browser_tests.
if (gcm_account_tracker_)
gcm_account_tracker_->Stop();
......
......@@ -61,6 +61,7 @@ class GCMProfileServiceTest : public testing::Test {
void CreateGCMProfileService();
void SignIn();
void SignOut();
void RegisterAndWaitForCompletion(const std::vector<std::string>& sender_ids);
void UnregisterAndWaitForCompletion();
......@@ -141,6 +142,13 @@ void GCMProfileServiceTest::SignIn() {
base::RunLoop().RunUntilIdle();
}
void GCMProfileServiceTest::SignOut() {
FakeSigninManager* signin_manager = static_cast<FakeSigninManager*>(
SigninManagerFactory::GetInstance()->GetForProfile(profile_.get()));
signin_manager->SignOut(signin_metrics::SIGNOUT_TEST);
base::RunLoop().RunUntilIdle();
}
void GCMProfileServiceTest::RegisterAndWaitForCompletion(
const std::vector<std::string>& sender_ids) {
base::RunLoop run_loop;
......@@ -218,6 +226,18 @@ TEST_F(GCMProfileServiceTest, CreateGCMProfileServiceAfterSignIn) {
EXPECT_TRUE(driver()->IsStarted());
}
TEST_F(GCMProfileServiceTest, SignInAgain) {
CreateGCMProfileService();
SignIn();
EXPECT_TRUE(driver()->IsStarted());
SignOut();
EXPECT_FALSE(driver()->IsStarted());
SignIn();
EXPECT_TRUE(driver()->IsStarted());
}
TEST_F(GCMProfileServiceTest, RegisterAndUnregister) {
CreateGCMProfileService();
SignIn();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment