diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 21:56:36 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 21:56:36 +0000 |
commit | aefb9170d057e26b554d7dc639699209a0bee2a2 (patch) | |
tree | 1a72fd8707491c96c280fcd2acfa8165d53650ba /chrome/browser/signin/account_reconcilor_unittest.cc | |
parent | dff32bfeb982b4942f2113c4a25c849f56a12bc9 (diff) | |
download | chromium_src-aefb9170d057e26b554d7dc639699209a0bee2a2.zip chromium_src-aefb9170d057e26b554d7dc639699209a0bee2a2.tar.gz chromium_src-aefb9170d057e26b554d7dc639699209a0bee2a2.tar.bz2 |
Make it so that the account reconcilor (or any other component that wants to react to token service changes in batches) only triggers its actions once all token changes are applied.
BUG=368903
Review URL: https://codereview.chromium.org/340533004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/signin/account_reconcilor_unittest.cc')
-rw-r--r-- | chrome/browser/signin/account_reconcilor_unittest.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc index 6a90a0e..c4e69e8 100644 --- a/chrome/browser/signin/account_reconcilor_unittest.cc +++ b/chrome/browser/signin/account_reconcilor_unittest.cc @@ -763,6 +763,41 @@ TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) { ASSERT_FALSE(reconcilor->is_reconcile_started_); } +TEST_F(AccountReconcilorTest, MergeSessionCompletedWithBogusAccount) { + signin_manager()->SetAuthenticatedUsername("user@gmail.com"); + token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); + + EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); + + SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), + "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]]]", + net::HTTP_OK, net::URLRequestStatus::SUCCESS); + SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", + "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); + + AccountReconcilor* reconcilor = + AccountReconcilorFactory::GetForProfile(profile()); + ASSERT_TRUE(reconcilor); + + ASSERT_FALSE(reconcilor->is_reconcile_started_); + reconcilor->StartReconcile(); + ASSERT_TRUE(reconcilor->is_reconcile_started_); + + token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", + base::Time::Now() + base::TimeDelta::FromHours(1)); + base::RunLoop().RunUntilIdle(); + + // If an unknown account id is sent, it should not upset the state. + SimulateMergeSessionCompleted(reconcilor, "bogus@gmail.com", + GoogleServiceAuthError::AuthErrorNone()); + ASSERT_TRUE(reconcilor->is_reconcile_started_); + + SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", + GoogleServiceAuthError::AuthErrorNone()); + ASSERT_FALSE(reconcilor->is_reconcile_started_); +} + INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, AccountReconcilorTest, testing::Bool()); + |