Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Unified Diff: chrome/browser/signin/account_reconcilor_unittest.cc

Issue 344513005: Revert "Improve the no-op reconcilor so that it doesn't "hang" after the first execution, but inste… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/statistics_delta_reader.h ('k') | chrome/test/base/uma_histogram_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/account_reconcilor_unittest.cc
diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc
index d1edb3ee5a86e3cc6612292cc5fb28fab937ccc7..a7ec9ef2a15b0320b00d8a58d496fc3d286bf651 100644
--- a/chrome/browser/signin/account_reconcilor_unittest.cc
+++ b/chrome/browser/signin/account_reconcilor_unittest.cc
@@ -20,11 +20,11 @@
#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"
#include "components/signin/core/common/profile_management_switches.h"
+#include "components/signin/core/common/signin_switches.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/url_request/test_url_fetcher_factory.h"
@@ -34,13 +34,6 @@
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:
@@ -84,7 +77,7 @@ MockAccountReconcilor::MockAccountReconcilor(
} // namespace
-class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
+class AccountReconcilorTest : public testing::Test {
public:
AccountReconcilorTest();
virtual void SetUp() OVERRIDE;
@@ -92,7 +85,6 @@ 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_; }
void SetFakeResponse(const std::string& url,
const std::string& data,
@@ -121,9 +113,6 @@ class AccountReconcilorTest : public ::testing::TestWithParam<bool> {
MockAccountReconcilor* mock_reconcilor_;
net::FakeURLFetcherFactory url_fetcher_factory_;
scoped_ptr<TestingProfileManager> testing_profile_manager_;
- UMAHistogramHelper histogram_helper_;
-
- DISALLOW_COPY_AND_ASSIGN(AccountReconcilorTest);
};
AccountReconcilorTest::AccountReconcilorTest()
@@ -133,12 +122,8 @@ AccountReconcilorTest::AccountReconcilorTest()
url_fetcher_factory_(NULL) {}
void AccountReconcilorTest::SetUp() {
- // If it's a non-parameterized test, or we have a parameter of true, set flag.
- if (!::testing::UnitTest::GetInstance()->current_test_info()->value_param() ||
- GetParam()) {
- switches::EnableAccountConsistencyForTesting(
- CommandLine::ForCurrentProcess());
- }
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableNewProfileManagement);
testing_profile_manager_.reset(
new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
@@ -167,10 +152,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() {
@@ -358,7 +339,7 @@ TEST_F(AccountReconcilorTest, ValidateAccountsFromTokensFailedTokenRequest) {
ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size());
}
-TEST_P(AccountReconcilorTest, StartReconcileNoop) {
+TEST_F(AccountReconcilorTest, StartReconcileNoop) {
signin_manager()->SetAuthenticatedUsername(kTestEmail);
token_service()->UpdateCredentials(kTestEmail, "refresh_token");
@@ -387,12 +368,6 @@ TEST_P(AccountReconcilorTest, StartReconcileNoop) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectTotalCount(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
}
// This is test is needed until chrome changes to use gaia obfuscated id.
@@ -403,7 +378,7 @@ TEST_P(AccountReconcilorTest, StartReconcileNoop) {
// tests makes sure that an email like "Dot.S@hmail.com", as seen by the
// token service, will be considered the same as "dots@gmail.com" as returned
// by gaia::ParseListAccountsData().
-TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
+TEST_F(AccountReconcilorTest, StartReconcileNoopWithDots) {
signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com");
token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token");
@@ -434,13 +409,9 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopWithDots) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
}
-TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
+TEST_F(AccountReconcilorTest, StartReconcileNoopMultiple) {
signin_manager()->SetAuthenticatedUsername("user@gmail.com");
token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
@@ -477,15 +448,9 @@ TEST_P(AccountReconcilorTest, StartReconcileNoopMultiple) {
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectTotalCount(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
}
-TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
+TEST_F(AccountReconcilorTest, StartReconcileAddToCookie) {
signin_manager()->SetAuthenticatedUsername("user@gmail.com");
token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
@@ -510,106 +475,9 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToCookie) {
SimulateMergeSessionCompleted(reconcilor, "other@gmail.com",
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
-}
-
-TEST_P(AccountReconcilorTest, StartReconcileAddToCookieTwice) {
- signin_manager()->SetAuthenticatedUsername("user@gmail.com");
- token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
- token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
-
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com"));
- EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("third@gmail.com"));
-
- 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(GaiaUrls::GetInstance()->people_get_url().spec(),
- "{\"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_);
- SimulateMergeSessionCompleted(
- reconcilor, "other@gmail.com", GoogleServiceAuthError::AuthErrorNone());
- ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
-
- // Do another pass after I've added a third account to the token service
-
- 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);
- // 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_);
- SimulateMergeSessionCompleted(
- reconcilor, "third@gmail.com", GoogleServiceAuthError::AuthErrorNone());
- ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.FirstRun", 1, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.SubsequentRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.SubsequentRun", 1, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.SubsequentRun", 0, 1);
}
-TEST_P(AccountReconcilorTest, StartReconcileAddToChrome) {
+TEST_F(AccountReconcilorTest, StartReconcileAddToChrome) {
signin_manager()->SetAuthenticatedUsername("user@gmail.com");
token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
@@ -632,17 +500,9 @@ TEST_P(AccountReconcilorTest, StartReconcileAddToChrome) {
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", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.FirstRun", 0, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.FirstRun", 1, 1);
}
-TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
+TEST_F(AccountReconcilorTest, StartReconcileBadPrimary) {
signin_manager()->SetAuthenticatedUsername("user@gmail.com");
token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
@@ -673,17 +533,9 @@ TEST_P(AccountReconcilorTest, StartReconcileBadPrimary) {
SimulateMergeSessionCompleted(reconcilor, "user@gmail.com",
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
-
- histogram_helper()->Fetch();
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.DifferentPrimaryAccounts.FirstRun", 1, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToCookieJar.FirstRun", 2, 1);
- histogram_helper()->ExpectUniqueSample(
- "Signin.Reconciler.AddedToChrome.FirstRun", 0, 1);
}
-TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
+TEST_F(AccountReconcilorTest, StartReconcileOnlyOnce) {
signin_manager()->SetAuthenticatedUsername(kTestEmail);
token_service()->UpdateCredentials(kTestEmail, "refresh_token");
@@ -708,7 +560,7 @@ TEST_P(AccountReconcilorTest, StartReconcileOnlyOnce) {
ASSERT_FALSE(reconcilor->is_reconcile_started_);
}
-TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
+TEST_F(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
signin_manager()->SetAuthenticatedUsername("user@gmail.com");
token_service()->UpdateCredentials("user@gmail.com", "refresh_token");
token_service()->UpdateCredentials("other@gmail.com", "refresh_token");
@@ -740,7 +592,3 @@ TEST_P(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) {
GoogleServiceAuthError::AuthErrorNone());
ASSERT_FALSE(reconcilor->is_reconcile_started_);
}
-
-INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled,
- AccountReconcilorTest,
- testing::Bool());
« no previous file with comments | « base/test/statistics_delta_reader.h ('k') | chrome/test/base/uma_histogram_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698