Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 11 #include "chrome/browser/signin/account_reconcilor_factory.h" | 11 #include "chrome/browser/signin/account_reconcilor_factory.h" |
| 12 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 12 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 15 #include "chrome/browser/signin/fake_signin_manager.h" | 15 #include "chrome/browser/signin/fake_signin_manager.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/signin/test_signin_client_builder.h" | 18 #include "chrome/browser/signin/test_signin_client_builder.h" |
| 19 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "chrome/test/base/testing_profile_manager.h" | 21 #include "chrome/test/base/testing_profile_manager.h" |
| 22 #include "chrome/test/base/uma_histogram_helper.h" | |
| 22 #include "components/signin/core/browser/account_reconcilor.h" | 23 #include "components/signin/core/browser/account_reconcilor.h" |
| 23 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 24 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 24 #include "components/signin/core/browser/signin_manager.h" | 25 #include "components/signin/core/browser/signin_manager.h" |
| 25 //#include "components/signin/core/browser/test_signin_client.h" | |
| 26 #include "components/signin/core/common/signin_switches.h" | 26 #include "components/signin/core/common/signin_switches.h" |
| 27 #include "content/public/test/test_browser_thread_bundle.h" | 27 #include "content/public/test/test_browser_thread_bundle.h" |
| 28 #include "google_apis/gaia/gaia_urls.h" | 28 #include "google_apis/gaia/gaia_urls.h" |
| 29 #include "net/url_request/test_url_fetcher_factory.h" | 29 #include "net/url_request/test_url_fetcher_factory.h" |
| 30 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 const char kTestEmail[] = "user@gmail.com"; | 35 const char kTestEmail[] = "user@gmail.com"; |
| 36 const char* kHistogramsToSnapshot[] = { | |
|
Ilya Sherman
2014/06/13 19:58:11
nit: "const char* const" (MOAR const :P)
Mike Lerman
2014/06/16 14:59:13
Done. KKKKAAAAAHHHHHHHHNNNNNst!
| |
| 37 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", | |
| 38 "Signin.Reconciler.AddedToCookieJar.FirstRun", | |
| 39 "Signin.Reconciler.AddedToChrome.FirstRun", | |
| 40 "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun", | |
| 41 "Signin.Reconciler.AddedToCookieJar.SubsequentRun", | |
| 42 "Signin.Reconciler.AddedToChrome.SubsequentRun"}; | |
| 36 | 43 |
| 37 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> { | 44 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> { |
| 38 public: | 45 public: |
| 39 static KeyedService* Build(content::BrowserContext* context); | 46 static KeyedService* Build(content::BrowserContext* context); |
| 40 | 47 |
| 41 MockAccountReconcilor(ProfileOAuth2TokenService* token_service, | 48 MockAccountReconcilor(ProfileOAuth2TokenService* token_service, |
| 42 SigninManagerBase* signin_manager, | 49 SigninManagerBase* signin_manager, |
| 43 SigninClient* client); | 50 SigninClient* client); |
| 44 virtual ~MockAccountReconcilor() {} | 51 virtual ~MockAccountReconcilor() {} |
| 45 | 52 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 69 MockAccountReconcilor::MockAccountReconcilor( | 76 MockAccountReconcilor::MockAccountReconcilor( |
| 70 ProfileOAuth2TokenService* token_service, | 77 ProfileOAuth2TokenService* token_service, |
| 71 SigninManagerBase* signin_manager, | 78 SigninManagerBase* signin_manager, |
| 72 SigninClient* client) | 79 SigninClient* client) |
| 73 : testing::StrictMock<AccountReconcilor>(token_service, | 80 : testing::StrictMock<AccountReconcilor>(token_service, |
| 74 signin_manager, | 81 signin_manager, |
| 75 client) {} | 82 client) {} |
| 76 | 83 |
| 77 } // namespace | 84 } // namespace |
| 78 | 85 |
| 79 class AccountReconcilorTest : public testing::Test { | 86 class AccountReconcilorTest : public ::testing::TestWithParam<bool> { |
| 80 public: | 87 public: |
| 81 AccountReconcilorTest(); | 88 AccountReconcilorTest(); |
| 82 virtual void SetUp() OVERRIDE; | 89 virtual void SetUp() OVERRIDE; |
| 83 | 90 |
| 84 TestingProfile* profile() { return profile_; } | 91 TestingProfile* profile() { return profile_; } |
| 85 FakeSigninManagerForTesting* signin_manager() { return signin_manager_; } | 92 FakeSigninManagerForTesting* signin_manager() { return signin_manager_; } |
| 86 FakeProfileOAuth2TokenService* token_service() { return token_service_; } | 93 FakeProfileOAuth2TokenService* token_service() { return token_service_; } |
| 94 UMAHistogramHelper* histogram_helper() { return &histogram_helper_; } | |
| 87 | 95 |
| 88 void SetFakeResponse(const std::string& url, | 96 void SetFakeResponse(const std::string& url, |
| 89 const std::string& data, | 97 const std::string& data, |
| 90 net::HttpStatusCode code, | 98 net::HttpStatusCode code, |
| 91 net::URLRequestStatus::Status status) { | 99 net::URLRequestStatus::Status status) { |
| 92 url_fetcher_factory_.SetFakeResponse(GURL(url), data, code, status); | 100 url_fetcher_factory_.SetFakeResponse(GURL(url), data, code, status); |
| 93 } | 101 } |
| 94 | 102 |
| 95 MockAccountReconcilor* GetMockReconcilor(); | 103 MockAccountReconcilor* GetMockReconcilor(); |
| 96 | 104 |
| 97 void SimulateMergeSessionCompleted( | 105 void SimulateMergeSessionCompleted( |
| 98 MergeSessionHelper::Observer* observer, | 106 MergeSessionHelper::Observer* observer, |
| 99 const std::string& account_id, | 107 const std::string& account_id, |
| 100 const GoogleServiceAuthError& error); | 108 const GoogleServiceAuthError& error); |
| 101 | 109 |
| 102 void SimulateRefreshTokenFetched( | 110 void SimulateRefreshTokenFetched( |
| 103 AccountReconcilor* reconcilor, | 111 AccountReconcilor* reconcilor, |
| 104 const std::string& account_id, | 112 const std::string& account_id, |
| 105 const std::string& refresh_token); | 113 const std::string& refresh_token); |
| 106 | 114 |
| 107 private: | 115 private: |
| 108 content::TestBrowserThreadBundle bundle_; | 116 content::TestBrowserThreadBundle bundle_; |
| 109 TestingProfile* profile_; | 117 TestingProfile* profile_; |
| 110 FakeSigninManagerForTesting* signin_manager_; | 118 FakeSigninManagerForTesting* signin_manager_; |
| 111 FakeProfileOAuth2TokenService* token_service_; | 119 FakeProfileOAuth2TokenService* token_service_; |
| 112 MockAccountReconcilor* mock_reconcilor_; | 120 MockAccountReconcilor* mock_reconcilor_; |
| 113 net::FakeURLFetcherFactory url_fetcher_factory_; | 121 net::FakeURLFetcherFactory url_fetcher_factory_; |
| 114 scoped_ptr<TestingProfileManager> testing_profile_manager_; | 122 scoped_ptr<TestingProfileManager> testing_profile_manager_; |
| 123 UMAHistogramHelper histogram_helper_; | |
| 115 }; | 124 }; |
| 116 | 125 |
| 117 AccountReconcilorTest::AccountReconcilorTest() | 126 AccountReconcilorTest::AccountReconcilorTest() |
| 118 : signin_manager_(NULL), | 127 : signin_manager_(NULL), |
| 119 token_service_(NULL), | 128 token_service_(NULL), |
| 120 mock_reconcilor_(NULL), | 129 mock_reconcilor_(NULL), |
| 121 url_fetcher_factory_(NULL) {} | 130 url_fetcher_factory_(NULL) {} |
| 122 | 131 |
| 123 void AccountReconcilorTest::SetUp() { | 132 void AccountReconcilorTest::SetUp() { |
| 124 CommandLine::ForCurrentProcess()->AppendSwitch( | 133 // If it's a non-parameterized test, or we have a parameter of true, set flag. |
| 125 switches::kNewProfileManagement); | 134 if (!::testing::UnitTest::GetInstance()->current_test_info()->value_param() |
| 135 || GetParam()) { | |
| 136 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 137 switches::kNewProfileManagement); | |
| 138 } | |
| 126 | 139 |
| 127 testing_profile_manager_.reset( | 140 testing_profile_manager_.reset( |
| 128 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); | 141 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); |
| 129 ASSERT_TRUE(testing_profile_manager_.get()->SetUp()); | 142 ASSERT_TRUE(testing_profile_manager_.get()->SetUp()); |
| 130 | 143 |
| 131 TestingProfile::TestingFactories factories; | 144 TestingProfile::TestingFactories factories; |
| 132 factories.push_back(std::make_pair(ChromeSigninClientFactory::GetInstance(), | 145 factories.push_back(std::make_pair(ChromeSigninClientFactory::GetInstance(), |
| 133 signin::BuildTestSigninClient)); | 146 signin::BuildTestSigninClient)); |
| 134 factories.push_back(std::make_pair( | 147 factories.push_back(std::make_pair( |
| 135 ProfileOAuth2TokenServiceFactory::GetInstance(), | 148 ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 136 BuildFakeProfileOAuth2TokenService)); | 149 BuildFakeProfileOAuth2TokenService)); |
| 137 factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(), | 150 factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(), |
| 138 FakeSigninManagerBase::Build)); | 151 FakeSigninManagerBase::Build)); |
| 139 factories.push_back(std::make_pair(AccountReconcilorFactory::GetInstance(), | 152 factories.push_back(std::make_pair(AccountReconcilorFactory::GetInstance(), |
| 140 MockAccountReconcilor::Build)); | 153 MockAccountReconcilor::Build)); |
| 141 | 154 |
| 142 profile_ = testing_profile_manager_.get()->CreateTestingProfile("name", | 155 profile_ = testing_profile_manager_.get()->CreateTestingProfile("name", |
| 143 scoped_ptr<PrefServiceSyncable>(), | 156 scoped_ptr<PrefServiceSyncable>(), |
| 144 base::UTF8ToUTF16("name"), 0, std::string(), | 157 base::UTF8ToUTF16("name"), 0, std::string(), |
| 145 factories); | 158 factories); |
| 146 | 159 |
| 147 signin_manager_ = | 160 signin_manager_ = |
| 148 static_cast<FakeSigninManagerForTesting*>( | 161 static_cast<FakeSigninManagerForTesting*>( |
| 149 SigninManagerFactory::GetForProfile(profile())); | 162 SigninManagerFactory::GetForProfile(profile())); |
| 150 | 163 |
| 151 token_service_ = | 164 token_service_ = |
| 152 static_cast<FakeProfileOAuth2TokenService*>( | 165 static_cast<FakeProfileOAuth2TokenService*>( |
| 153 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())); | 166 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())); |
| 167 | |
| 168 // Take a new snapshot of the concerned histograms before each test | |
| 169 histogram_helper_.PrepareSnapshot(kHistogramsToSnapshot, | |
| 170 arraysize(kHistogramsToSnapshot)); | |
|
Ilya Sherman
2014/06/13 19:58:11
nit: Please align the params, or have them both be
Mike Lerman
2014/06/16 14:59:13
TIL about git cl format. Thanks!
| |
| 154 } | 171 } |
| 155 | 172 |
| 156 MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() { | 173 MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() { |
| 157 if (!mock_reconcilor_) { | 174 if (!mock_reconcilor_) { |
| 158 mock_reconcilor_ = | 175 mock_reconcilor_ = |
| 159 static_cast<MockAccountReconcilor*>( | 176 static_cast<MockAccountReconcilor*>( |
| 160 AccountReconcilorFactory::GetForProfile(profile())); | 177 AccountReconcilorFactory::GetForProfile(profile())); |
| 161 } | 178 } |
| 162 | 179 |
| 163 return mock_reconcilor_; | 180 return mock_reconcilor_; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 | 348 |
| 332 token_service()->IssueErrorForAllPendingRequests( | 349 token_service()->IssueErrorForAllPendingRequests( |
| 333 GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); | 350 GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); |
| 334 | 351 |
| 335 base::RunLoop().RunUntilIdle(); | 352 base::RunLoop().RunUntilIdle(); |
| 336 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 353 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 337 ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size()); | 354 ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size()); |
| 338 ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size()); | 355 ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size()); |
| 339 } | 356 } |
| 340 | 357 |
| 341 TEST_F(AccountReconcilorTest, StartReconcileNoop) { | 358 TEST_P(AccountReconcilorTest, StartReconcileNoop) { |
| 342 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 359 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 343 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 360 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 344 | 361 |
| 345 AccountReconcilor* reconcilor = | 362 AccountReconcilor* reconcilor = |
| 346 AccountReconcilorFactory::GetForProfile(profile()); | 363 AccountReconcilorFactory::GetForProfile(profile()); |
| 347 ASSERT_TRUE(reconcilor); | 364 ASSERT_TRUE(reconcilor); |
| 348 | 365 |
| 349 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 366 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 350 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 367 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 351 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 368 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 352 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), | 369 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 353 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 370 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 354 | 371 |
| 355 reconcilor->StartReconcile(); | 372 reconcilor->StartReconcile(); |
| 356 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); | 373 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); |
| 357 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 374 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 358 | 375 |
| 359 base::RunLoop().RunUntilIdle(); | 376 base::RunLoop().RunUntilIdle(); |
| 360 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); | 377 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); |
| 361 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); | 378 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); |
| 362 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 379 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 363 | 380 |
| 364 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 381 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 365 base::Time::Now() + base::TimeDelta::FromHours(1)); | 382 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 366 | 383 |
| 367 base::RunLoop().RunUntilIdle(); | 384 base::RunLoop().RunUntilIdle(); |
| 368 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 385 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 369 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 386 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 387 | |
| 388 histogram_helper()->Fetch(); | |
| 389 histogram_helper()->ExpectTotalCount( | |
| 390 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1); | |
| 391 histogram_helper()->ExpectUniqueSample( | |
| 392 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 370 } | 393 } |
| 371 | 394 |
| 372 // This is test is needed until chrome changes to use gaia obfuscated id. | 395 // This is test is needed until chrome changes to use gaia obfuscated id. |
| 373 // The signin manager and token service use the gaia "email" property, which | 396 // The signin manager and token service use the gaia "email" property, which |
| 374 // preserves dots in usernames and preserves case. gaia::ParseListAccountsData() | 397 // preserves dots in usernames and preserves case. gaia::ParseListAccountsData() |
| 375 // however uses gaia "displayEmail" which does not preserve case, and then | 398 // however uses gaia "displayEmail" which does not preserve case, and then |
| 376 // passes the string through gaia::CanonicalizeEmail() which removes dots. This | 399 // passes the string through gaia::CanonicalizeEmail() which removes dots. This |
| 377 // tests makes sure that an email like "Dot.S@hmail.com", as seen by the | 400 // tests makes sure that an email like "Dot.S@hmail.com", as seen by the |
| 378 // token service, will be considered the same as "dots@gmail.com" as returned | 401 // token service, will be considered the same as "dots@gmail.com" as returned |
| 379 // by gaia::ParseListAccountsData(). | 402 // by gaia::ParseListAccountsData(). |
| 380 TEST_F(AccountReconcilorTest, StartReconcileNoopWithDots) { | 403 TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) { |
| 381 signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com"); | 404 signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com"); |
| 382 token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token"); | 405 token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token"); |
| 383 | 406 |
| 384 AccountReconcilor* reconcilor = | 407 AccountReconcilor* reconcilor = |
| 385 AccountReconcilorFactory::GetForProfile(profile()); | 408 AccountReconcilorFactory::GetForProfile(profile()); |
| 386 ASSERT_TRUE(reconcilor); | 409 ASSERT_TRUE(reconcilor); |
| 387 | 410 |
| 388 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 411 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 389 "[\"f\", [[\"b\", 0, \"n\", \"dot.s@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 412 "[\"f\", [[\"b\", 0, \"n\", \"dot.s@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 390 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 413 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 401 ASSERT_STREQ("dots@gmail.com", | 424 ASSERT_STREQ("dots@gmail.com", |
| 402 reconcilor->GetGaiaAccountsForTesting()[0].first.c_str()); | 425 reconcilor->GetGaiaAccountsForTesting()[0].first.c_str()); |
| 403 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 426 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 404 | 427 |
| 405 token_service()->IssueAllTokensForAccount("Dot.S@gmail.com", "access_token", | 428 token_service()->IssueAllTokensForAccount("Dot.S@gmail.com", "access_token", |
| 406 base::Time::Now() + base::TimeDelta::FromHours(1)); | 429 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 407 | 430 |
| 408 base::RunLoop().RunUntilIdle(); | 431 base::RunLoop().RunUntilIdle(); |
| 409 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 432 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 410 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 433 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 434 | |
| 435 histogram_helper()->Fetch(); | |
| 436 histogram_helper()->ExpectUniqueSample( | |
| 437 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 411 } | 438 } |
| 412 | 439 |
| 413 TEST_F(AccountReconcilorTest, StartReconcileNoopMultiple) { | 440 TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) { |
| 414 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 441 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 415 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 442 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 416 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 443 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 417 | 444 |
| 418 AccountReconcilor* reconcilor = | 445 AccountReconcilor* reconcilor = |
| 419 AccountReconcilorFactory::GetForProfile(profile()); | 446 AccountReconcilorFactory::GetForProfile(profile()); |
| 420 ASSERT_TRUE(reconcilor); | 447 ASSERT_TRUE(reconcilor); |
| 421 | 448 |
| 422 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 449 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 423 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 450 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 440 | 467 |
| 441 base::RunLoop().RunUntilIdle(); | 468 base::RunLoop().RunUntilIdle(); |
| 442 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 469 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 443 | 470 |
| 444 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 471 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 445 base::Time::Now() + base::TimeDelta::FromHours(1)); | 472 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 446 | 473 |
| 447 base::RunLoop().RunUntilIdle(); | 474 base::RunLoop().RunUntilIdle(); |
| 448 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 475 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 449 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 476 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 477 | |
| 478 histogram_helper()->Fetch(); | |
| 479 histogram_helper()->ExpectTotalCount( | |
| 480 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1); | |
| 481 histogram_helper()->ExpectUniqueSample( | |
| 482 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 450 } | 483 } |
| 451 | 484 |
| 452 TEST_F(AccountReconcilorTest, StartReconcileAddToCookie) { | 485 TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) { |
| 453 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 486 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 454 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 487 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 455 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 488 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 456 | 489 |
| 457 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); | 490 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); |
| 458 | 491 |
| 459 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 492 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 460 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 493 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 461 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 494 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 462 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), | 495 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 463 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 496 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 464 | 497 |
| 465 AccountReconcilor* reconcilor = GetMockReconcilor(); | 498 AccountReconcilor* reconcilor = GetMockReconcilor(); |
| 466 reconcilor->StartReconcile(); | 499 reconcilor->StartReconcile(); |
| 467 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | 500 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", |
| 468 base::Time::Now() + base::TimeDelta::FromHours(1)); | 501 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 469 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 502 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 470 base::Time::Now() + base::TimeDelta::FromHours(1)); | 503 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 471 | 504 |
| 472 base::RunLoop().RunUntilIdle(); | 505 base::RunLoop().RunUntilIdle(); |
| 473 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 506 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 474 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", | 507 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", |
| 475 GoogleServiceAuthError::AuthErrorNone()); | 508 GoogleServiceAuthError::AuthErrorNone()); |
| 476 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 509 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 510 | |
| 511 histogram_helper()->Fetch(); | |
| 512 histogram_helper()->ExpectUniqueSample( | |
| 513 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 514 histogram_helper()->ExpectUniqueSample( | |
| 515 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1); | |
| 516 histogram_helper()->ExpectUniqueSample( | |
| 517 "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1); | |
| 477 } | 518 } |
| 478 | 519 |
| 479 TEST_F(AccountReconcilorTest, StartReconcileAddToChrome) { | 520 TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) { |
| 521 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | |
| 522 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | |
| 523 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | |
| 524 | |
| 525 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); | |
| 526 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("third@gmail.com")); | |
| 527 | |
| 528 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | |
| 529 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | |
| 530 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | |
| 531 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), | |
| 532 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | |
| 533 | |
| 534 AccountReconcilor* reconcilor = GetMockReconcilor(); | |
| 535 reconcilor->StartReconcile(); | |
| 536 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | |
| 537 base::Time::Now() + base::TimeDelta::FromHours(1)); | |
| 538 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | |
| 539 base::Time::Now() + base::TimeDelta::FromHours(1)); | |
| 540 | |
| 541 base::RunLoop().RunUntilIdle(); | |
| 542 ASSERT_TRUE(reconcilor->is_reconcile_started_); | |
| 543 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", | |
| 544 GoogleServiceAuthError::AuthErrorNone()); | |
| 545 ASSERT_FALSE(reconcilor->is_reconcile_started_); | |
| 546 | |
| 547 histogram_helper()->Fetch(); | |
| 548 histogram_helper()->ExpectUniqueSample( | |
| 549 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 550 histogram_helper()->ExpectUniqueSample( | |
| 551 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1); | |
| 552 histogram_helper()->ExpectUniqueSample( | |
| 553 "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1); | |
| 554 | |
| 555 // Do another pass after I've added a third account to the token service | |
| 556 | |
| 557 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | |
| 558 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | |
| 559 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | |
| 560 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | |
| 561 // This will cause the reconcilor to fire. | |
| 562 token_service()->UpdateCredentials("third@gmail.com", "refresh_token"); | |
| 563 | |
| 564 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | |
| 565 base::Time::Now() + base::TimeDelta::FromHours(1)); | |
| 566 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | |
| 567 base::Time::Now() + base::TimeDelta::FromHours(1)); | |
| 568 token_service()->IssueAllTokensForAccount("third@gmail.com", "access_token", | |
| 569 base::Time::Now() + base::TimeDelta::FromHours(1)); | |
| 570 | |
| 571 base::RunLoop().RunUntilIdle(); | |
| 572 | |
| 573 ASSERT_TRUE(reconcilor->is_reconcile_started_); | |
| 574 SimulateMergeSessionCompleted(reconcilor, "third@gmail.com", | |
| 575 GoogleServiceAuthError::AuthErrorNone()); | |
| 576 ASSERT_FALSE(reconcilor->is_reconcile_started_); | |
| 577 | |
| 578 histogram_helper()->Fetch(); | |
| 579 histogram_helper()->ExpectUniqueSample( | |
| 580 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 581 histogram_helper()->ExpectUniqueSample( | |
| 582 "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1); | |
| 583 histogram_helper()->ExpectUniqueSample( | |
| 584 "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1); | |
| 585 histogram_helper()->ExpectUniqueSample( | |
| 586 "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun", 0, 1); | |
| 587 histogram_helper()->ExpectUniqueSample( | |
| 588 "Signin.Reconciler.AddedToCookieJar.SubsequentRun", 1, 1); | |
| 589 histogram_helper()->ExpectUniqueSample( | |
| 590 "Signin.Reconciler.AddedToChrome.SubsequentRun", 0, 1); | |
| 591 } | |
| 592 | |
| 593 TEST_P(AccountReconcilorTest, StartReconcileAddToChrome) { | |
| 480 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 594 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 481 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 595 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 482 | 596 |
| 483 EXPECT_CALL(*GetMockReconcilor(), | 597 EXPECT_CALL(*GetMockReconcilor(), |
| 484 PerformAddToChromeAction("other@gmail.com", 1)); | 598 PerformAddToChromeAction("other@gmail.com", 1)); |
| 485 | 599 |
| 486 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 600 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 487 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 601 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| 488 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 602 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 489 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 603 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 490 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), | 604 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 491 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 605 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 492 | 606 |
| 493 AccountReconcilor* reconcilor = GetMockReconcilor(); | 607 AccountReconcilor* reconcilor = GetMockReconcilor(); |
| 494 reconcilor->StartReconcile(); | 608 reconcilor->StartReconcile(); |
| 495 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 609 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 496 base::Time::Now() + base::TimeDelta::FromHours(1)); | 610 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 497 | 611 |
| 498 base::RunLoop().RunUntilIdle(); | 612 base::RunLoop().RunUntilIdle(); |
| 499 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 613 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 500 SimulateRefreshTokenFetched(reconcilor, "other@gmail.com", ""); | 614 SimulateRefreshTokenFetched(reconcilor, "other@gmail.com", ""); |
| 501 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 615 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 616 | |
| 617 histogram_helper()->Fetch(); | |
| 618 histogram_helper()->ExpectUniqueSample( | |
| 619 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1); | |
| 620 histogram_helper()->ExpectUniqueSample( | |
| 621 "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1); | |
| 622 histogram_helper()->ExpectUniqueSample( | |
| 623 "Signin.Reconciler.AddedToChrome.FirstRun", 1, 1); | |
| 502 } | 624 } |
| 503 | 625 |
| 504 TEST_F(AccountReconcilorTest, StartReconcileBadPrimary) { | 626 TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) { |
| 505 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 627 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 506 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 628 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 507 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 629 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 508 | 630 |
| 509 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); | 631 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); |
| 510 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); | 632 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); |
| 511 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); | 633 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); |
| 512 | 634 |
| 513 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 635 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 514 "[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 636 "[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 525 base::Time::Now() + base::TimeDelta::FromHours(1)); | 647 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 526 | 648 |
| 527 base::RunLoop().RunUntilIdle(); | 649 base::RunLoop().RunUntilIdle(); |
| 528 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 650 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 529 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", | 651 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", |
| 530 GoogleServiceAuthError::AuthErrorNone()); | 652 GoogleServiceAuthError::AuthErrorNone()); |
| 531 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 653 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 532 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", | 654 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", |
| 533 GoogleServiceAuthError::AuthErrorNone()); | 655 GoogleServiceAuthError::AuthErrorNone()); |
| 534 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 656 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 657 | |
| 658 histogram_helper()->Fetch(); | |
| 659 histogram_helper()->ExpectUniqueSample( | |
| 660 "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1, 1); | |
| 661 histogram_helper()->ExpectUniqueSample( | |
| 662 "Signin.Reconciler.AddedToCookieJar.FirstRun", 2, 1); | |
| 663 histogram_helper()->ExpectUniqueSample( | |
| 664 "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1); | |
| 535 } | 665 } |
| 536 | 666 |
| 537 TEST_F(AccountReconcilorTest, StartReconcileOnlyOnce) { | 667 TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) { |
| 538 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 668 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 539 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 669 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 540 | 670 |
| 541 AccountReconcilor* reconcilor = | 671 AccountReconcilor* reconcilor = |
| 542 AccountReconcilorFactory::GetForProfile(profile()); | 672 AccountReconcilorFactory::GetForProfile(profile()); |
| 543 ASSERT_TRUE(reconcilor); | 673 ASSERT_TRUE(reconcilor); |
| 544 | 674 |
| 545 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 675 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 546 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 676 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 547 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 677 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 548 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), | 678 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 549 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 679 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 550 | 680 |
| 551 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 681 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 552 reconcilor->StartReconcile(); | 682 reconcilor->StartReconcile(); |
| 553 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 683 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 554 | 684 |
| 555 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 685 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 556 base::Time::Now() + base::TimeDelta::FromHours(1)); | 686 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 557 | 687 |
| 558 base::RunLoop().RunUntilIdle(); | 688 base::RunLoop().RunUntilIdle(); |
| 559 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 689 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 560 } | 690 } |
| 561 | 691 |
| 562 TEST_F(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) { | 692 TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) { |
| 563 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 693 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 564 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 694 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 565 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 695 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 566 | 696 |
| 567 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); | 697 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); |
| 568 | 698 |
| 569 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 699 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 570 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]," | 700 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]," |
| 571 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 701 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 572 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 702 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 584 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 714 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 585 base::Time::Now() + base::TimeDelta::FromHours(1)); | 715 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 586 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | 716 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", |
| 587 base::Time::Now() + base::TimeDelta::FromHours(1)); | 717 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 588 | 718 |
| 589 base::RunLoop().RunUntilIdle(); | 719 base::RunLoop().RunUntilIdle(); |
| 590 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", | 720 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", |
| 591 GoogleServiceAuthError::AuthErrorNone()); | 721 GoogleServiceAuthError::AuthErrorNone()); |
| 592 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 722 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 593 } | 723 } |
| 724 | |
| 725 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, | |
| 726 AccountReconcilorTest, | |
| 727 testing::Bool()); | |
| OLD | NEW |