Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / signin / account_reconcilor_unittest.cc
index 501df05..0bb444c 100644 (file)
@@ -6,6 +6,7 @@
 #include "base/memory/scoped_ptr.h"
 #include "base/run_loop.h"
 #include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
 #include "chrome/browser/prefs/pref_service_syncable.h"
@@ -20,7 +21,6 @@
 #include "chrome/test/base/testing_browser_process.h"
 #include "chrome/test/base/testing_profile.h"
 #include "chrome/test/base/testing_profile_manager.h"
-#include "chrome/test/base/uma_histogram_helper.h"
 #include "components/signin/core/browser/account_reconcilor.h"
 #include "components/signin/core/browser/profile_oauth2_token_service.h"
 #include "components/signin/core/browser/signin_manager.h"
 namespace {
 
 const char kTestEmail[] = "user@gmail.com";
-const char* const kHistogramsToSnapshot[] = {
-    "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
-    "Signin.Reconciler.AddedToCookieJar.FirstRun",
-    "Signin.Reconciler.AddedToChrome.FirstRun",
-    "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun",
-    "Signin.Reconciler.AddedToCookieJar.SubsequentRun",
-    "Signin.Reconciler.AddedToChrome.SubsequentRun"};
 
 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
  public:
@@ -58,16 +51,6 @@ class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
   }
 
   MOCK_METHOD1(PerformMergeAction, void(const std::string& account_id));
-  MOCK_METHOD1(PerformStartRemoveAction, void(const std::string& account_id));
-  MOCK_METHOD3(
-      PerformFinishRemoveAction,
-      void(const std::string& account_id,
-           const GoogleServiceAuthError& error,
-           const std::vector<std::pair<std::string, bool> >& accounts));
-  MOCK_METHOD3(PerformAddToChromeAction,
-               void(const std::string& account_id,
-                    int session_index,
-                    const std::string& signin_scoped_device_id));
   MOCK_METHOD0(PerformLogoutAllAccountsAction, void());
 };
 
@@ -100,7 +83,7 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
   TestingProfile* profile() { return profile_; }
   FakeSigninManagerForTesting* signin_manager() { return signin_manager_; }
   FakeProfileOAuth2TokenService* token_service() { return token_service_; }
-  UMAHistogramHelper* histogram_helper() { return &histogram_helper_; }
+  base::HistogramTester* histogram_tester() { return &histogram_tester_; }
 
   void SetFakeResponse(const std::string& url,
                        const std::string& data,
@@ -116,11 +99,6 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
       const std::string& account_id,
       const GoogleServiceAuthError& error);
 
-  void SimulateRefreshTokenFetched(
-      AccountReconcilor* reconcilor,
-      const std::string& account_id,
-      const std::string& refresh_token);
-
  private:
   content::TestBrowserThreadBundle bundle_;
   TestingProfile* profile_;
@@ -129,7 +107,7 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
   MockAccountReconcilor* mock_reconcilor_;
   net::FakeURLFetcherFactory url_fetcher_factory_;
   scoped_ptr<TestingProfileManager> testing_profile_manager_;
-  UMAHistogramHelper histogram_helper_;
+  base::HistogramTester histogram_tester_;
 
   DISALLOW_COPY_AND_ASSIGN(AccountReconcilorTest);
 };
@@ -175,10 +153,6 @@ void AccountReconcilorTest::SetUp() {
   token_service_ =
       static_cast<FakeProfileOAuth2TokenService*>(
           ProfileOAuth2TokenServiceFactory::GetForProfile(profile()));
-
-  // Take a new snapshot of the concerned histograms before each test
-  histogram_helper_.PrepareSnapshot(kHistogramsToSnapshot,
-                                    arraysize(kHistogramsToSnapshot));
 }
 
 MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() {
@@ -198,13 +172,6 @@ void AccountReconcilorTest::SimulateMergeSessionCompleted(
   observer->MergeSessionCompleted(account_id, error);
 }
 
-void AccountReconcilorTest::SimulateRefreshTokenFetched(
-    AccountReconcilor* reconcilor,
-    const std::string& account_id,
-    const std::string& refresh_token) {
-  reconcilor->HandleRefreshTokenFetched(account_id, refresh_token);
-}
-
 TEST_F(AccountReconcilorTest, Basic) {
   AccountReconcilor* reconcilor =
       AccountReconcilorFactory::GetForProfile(profile());
@@ -266,6 +233,7 @@ TEST_F(AccountReconcilorTest, ProfileAlreadyConnected) {
 TEST_F(AccountReconcilorTest, GetAccountsFromCookieSuccess) {
   signin_manager()->SetAuthenticatedUsername(kTestEmail);
   token_service()->UpdateCredentials(kTestEmail, "refresh_token");
+  EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(kTestEmail));
   AccountReconcilor* reconcilor =
       AccountReconcilorFactory::GetForProfile(profile());
   ASSERT_TRUE(reconcilor);
@@ -299,71 +267,7 @@ TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) {
   ASSERT_FALSE(reconcilor->AreGaiaAccountsSet());
 
   base::RunLoop().RunUntilIdle();
-  ASSERT_EQ(0u, reconcilor->GetGaiaAccountsForTesting().size());
-}
-
-TEST_F(AccountReconcilorTest, ValidateAccountsFromTokens) {
-  signin_manager()->SetAuthenticatedUsername(kTestEmail);
-  token_service()->UpdateCredentials(kTestEmail, "refresh_token");
-
-  AccountReconcilor* reconcilor =
-      AccountReconcilorFactory::GetForProfile(profile());
-  ASSERT_TRUE(reconcilor);
-
-  reconcilor->ValidateAccountsFromTokenService();
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  token_service()->IssueTokenForAllPendingRequests("access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
-  ASSERT_EQ(1u, reconcilor->GetValidChromeAccountsForTesting().size());
-  ASSERT_EQ(0u, reconcilor->GetInvalidChromeAccountsForTesting().size());
-}
-
-TEST_F(AccountReconcilorTest, ValidateAccountsFromTokensFailedUserInfo) {
-  signin_manager()->SetAuthenticatedUsername(kTestEmail);
-  token_service()->UpdateCredentials(kTestEmail, "refresh_token");
-
-  AccountReconcilor* reconcilor =
-      AccountReconcilorFactory::GetForProfile(profile());
-  ASSERT_TRUE(reconcilor);
-
-  reconcilor->ValidateAccountsFromTokenService();
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "", net::HTTP_NOT_FOUND, net::URLRequestStatus::SUCCESS);
-  token_service()->IssueTokenForAllPendingRequests("access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
-  ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size());
-  ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size());
-}
-
-TEST_F(AccountReconcilorTest, ValidateAccountsFromTokensFailedTokenRequest) {
-  signin_manager()->SetAuthenticatedUsername(kTestEmail);
-  token_service()->UpdateCredentials(kTestEmail, "refresh_token");
-
-  AccountReconcilor* reconcilor =
-      AccountReconcilorFactory::GetForProfile(profile());
-  ASSERT_TRUE(reconcilor);
-
-  reconcilor->ValidateAccountsFromTokenService();
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  token_service()->IssueErrorForAllPendingRequests(
-      GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
-  ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size());
-  ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size());
+  ASSERT_FALSE(reconcilor->AreGaiaAccountsSet());
 }
 
 TEST_P(AccountReconcilorTest, StartReconcileNoop) {
@@ -377,29 +281,17 @@ TEST_P(AccountReconcilorTest, StartReconcileNoop) {
   SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(),
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   reconcilor->StartReconcile();
+  ASSERT_TRUE(reconcilor->is_reconcile_started_);
   ASSERT_FALSE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
 
   base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectTotalCount(
+  histogram_tester()->ExpectTotalCount(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
@@ -424,29 +316,14 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
   SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(),
       "[\"f\", [[\"b\", 0, \"n\", \"dot.s@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   reconcilor->StartReconcile();
   ASSERT_FALSE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size());
-  ASSERT_STREQ("dots@gmail.com",
-               reconcilor->GetGaiaAccountsForTesting()[0].first.c_str());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  token_service()->IssueAllTokensForAccount("Dot.S@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
 
   base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
@@ -465,35 +342,15 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], "
                "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   reconcilor->StartReconcile();
   ASSERT_FALSE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreGaiaAccountsSet());
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-  ASSERT_EQ(2u, reconcilor->GetGaiaAccountsForTesting().size());
-
-  token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked());
-
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
   base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectTotalCount(
+  histogram_tester()->ExpectTotalCount(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
@@ -509,15 +366,9 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
   SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(),
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   AccountReconcilor* reconcilor = GetMockReconcilor();
   reconcilor->StartReconcile();
-  token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
 
   base::RunLoop().RunUntilIdle();
   ASSERT_TRUE(reconcilor->is_reconcile_started_);
@@ -525,15 +376,45 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
                                 GoogleServiceAuthError::AuthErrorNone());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
+}
+
+TEST_P(AccountReconcilorTest, StartReconcileRemoveFromCookie) {
+  signin_manager()->SetAuthenticatedUsername("user@gmail.com");
+  token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
+
+  EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction());
+  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, 1], "
+               "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
+      net::HTTP_OK, net::URLRequestStatus::SUCCESS);
+
+  AccountReconcilor* reconcilor = GetMockReconcilor();
+  reconcilor->StartReconcile();
+  ASSERT_TRUE(reconcilor->is_reconcile_started_);
+
+  base::RunLoop().RunUntilIdle();
+  SimulateMergeSessionCompleted(reconcilor, "user@gmail.com",
+                                GoogleServiceAuthError::AuthErrorNone());
+  ASSERT_FALSE(reconcilor->is_reconcile_started_);
+
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
+      signin_metrics::ACCOUNTS_SAME,
+      1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 1, 1);
 }
 
 TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
@@ -549,21 +430,9 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK,
       net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-                  "{\"id\":\"foo\"}",
-                  net::HTTP_OK,
-                  net::URLRequestStatus::SUCCESS);
 
   AccountReconcilor* reconcilor = GetMockReconcilor();
   reconcilor->StartReconcile();
-  token_service()->IssueAllTokensForAccount(
-      "other@gmail.com",
-      "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount(
-      "user@gmail.com",
-      "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
 
   base::RunLoop().RunUntilIdle();
   ASSERT_TRUE(reconcilor->is_reconcile_started_);
@@ -571,15 +440,14 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
       reconcilor, "other@gmail.com", GoogleServiceAuthError::AuthErrorNone());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
 
   // Do another pass after I've added a third account to the token service
 
@@ -592,19 +460,6 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
   // This will cause the reconcilor to fire.
   token_service()->UpdateCredentials("third@gmail.com", "refresh_token");
 
-  token_service()->IssueAllTokensForAccount(
-      "other@gmail.com",
-      "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount(
-      "user@gmail.com",
-      "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount(
-      "third@gmail.com",
-      "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
   base::RunLoop().RunUntilIdle();
 
   ASSERT_TRUE(reconcilor->is_reconcile_started_);
@@ -612,58 +467,22 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
       reconcilor, "third@gmail.com", GoogleServiceAuthError::AuthErrorNone());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun",
       signin_metrics::ACCOUNTS_SAME,
       1);
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.AddedToCookieJar.SubsequentRun", 1, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.SubsequentRun", 0, 1);
-}
-
-TEST_P(AccountReconcilorTest, StartReconcileAddToChrome) {
-  signin_manager()->SetAuthenticatedUsername("user@gmail.com");
-  token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
-
-  EXPECT_CALL(*GetMockReconcilor(),
-              PerformAddToChromeAction("other@gmail.com", 1, ""));
-
-  SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(),
-      "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], "
-               "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
-      net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-
-  AccountReconcilor* reconcilor = GetMockReconcilor();
-  reconcilor->StartReconcile();
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
-  base::RunLoop().RunUntilIdle();
-  ASSERT_TRUE(reconcilor->is_reconcile_started_);
-  SimulateRefreshTokenFetched(reconcilor, "other@gmail.com", "");
-  ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
-      signin_metrics::ACCOUNTS_SAME,
-      1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.FirstRun", 1, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.SubsequentRun", 0, 1);
 }
 
 TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
@@ -679,15 +498,9 @@ TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
       "[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], "
                "[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   AccountReconcilor* reconcilor = GetMockReconcilor();
   reconcilor->StartReconcile();
-  token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
 
   base::RunLoop().RunUntilIdle();
   ASSERT_TRUE(reconcilor->is_reconcile_started_);
@@ -698,15 +511,14 @@ TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
                                 GoogleServiceAuthError::AuthErrorNone());
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 
-  histogram_helper()->Fetch();
-  histogram_helper()->ExpectUniqueSample(
+  histogram_tester()->ExpectUniqueSample(
       "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun",
       signin_metrics::COOKIE_AND_TOKEN_PRIMARIES_DIFFERENT,
       1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToCookieJar.FirstRun", 2, 1);
-  histogram_helper()->ExpectUniqueSample(
-      "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1);
+  histogram_tester()->ExpectUniqueSample(
+      "Signin.Reconciler.RemovedFromCookieJar.FirstRun", 0, 1);
 }
 
 TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
@@ -720,16 +532,11 @@ TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
   SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(),
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-  SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo",
-      "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS);
 
   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();
   ASSERT_FALSE(reconcilor->is_reconcile_started_);
 }
@@ -745,8 +552,6 @@ TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
       "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0],"
                "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]",
       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());
@@ -756,11 +561,6 @@ TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
   reconcilor->StartReconcile();
   ASSERT_TRUE(reconcilor->is_reconcile_started_);
 
-  token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-  token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token",
-      base::Time::Now() + base::TimeDelta::FromHours(1));
-
   base::RunLoop().RunUntilIdle();
   SimulateMergeSessionCompleted(reconcilor, "user@gmail.com",
                                 GoogleServiceAuthError::AuthErrorNone());
@@ -776,8 +576,6 @@ TEST_F(AccountReconcilorTest, MergeSessionCompletedWithBogusAccount) {
   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());
@@ -787,8 +585,6 @@ TEST_F(AccountReconcilorTest, MergeSessionCompletedWithBogusAccount) {
   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.