#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"
#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:
}
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());
};
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,
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_;
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);
};
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() {
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());
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);
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) {
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);
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);
"[\"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);
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_);
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) {
"[\"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_);
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
// 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_);
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) {
"[\"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_);
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) {
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_);
}
"[\"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());
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());
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());
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.