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/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 AccountReconcilorFactory::GetForProfile(profile()); | 323 AccountReconcilorFactory::GetForProfile(profile()); |
| 324 ASSERT_TRUE(reconcilor); | 324 ASSERT_TRUE(reconcilor); |
| 325 | 325 |
| 326 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING, reconcilor->GetState()); | 326 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING, reconcilor->GetState()); |
| 327 reconcilor->StartReconcile(); | 327 reconcilor->StartReconcile(); |
| 328 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION, | 328 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION, |
| 329 reconcilor->GetState()); | 329 reconcilor->GetState()); |
| 330 base::RunLoop().RunUntilIdle(); | 330 base::RunLoop().RunUntilIdle(); |
| 331 ASSERT_EQ(AccountReconcilor::State::APPLYING_CHANGES, reconcilor->GetState()); | 331 ASSERT_EQ(AccountReconcilor::State::APPLYING_CHANGES, reconcilor->GetState()); |
| 332 | 332 |
| 333 std::vector<std::pair<std::string, bool> > accounts; | 333 std::vector<gaia::ListedAccount> accounts; |
| 334 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts)); | 334 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts)); |
| 335 ASSERT_EQ(1u, accounts.size()); | 335 ASSERT_EQ(1u, accounts.size()); |
| 336 ASSERT_EQ(account_id, accounts[0].first); | 336 ASSERT_EQ(account_id, accounts[0].email); |
|
Roger Tawa OOO till Jul 10th
2015/06/02 21:58:41
Shouldn't this be: accounts[0].account_id ?
| |
| 337 } | 337 } |
| 338 | 338 |
| 339 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) { | 339 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) { |
| 340 ConnectProfileToAccount("12345", "user@gmail.com"); | 340 ConnectProfileToAccount("12345", "user@gmail.com"); |
| 341 cookie_manager_service()->SetListAccountsResponseWebLoginRequired(); | 341 cookie_manager_service()->SetListAccountsResponseWebLoginRequired(); |
| 342 | 342 |
| 343 AccountReconcilor* reconcilor = | 343 AccountReconcilor* reconcilor = |
| 344 AccountReconcilorFactory::GetForProfile(profile()); | 344 AccountReconcilorFactory::GetForProfile(profile()); |
| 345 ASSERT_TRUE(reconcilor); | 345 ASSERT_TRUE(reconcilor); |
| 346 | 346 |
| 347 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING, reconcilor->GetState()); | 347 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING, reconcilor->GetState()); |
| 348 reconcilor->StartReconcile(); | 348 reconcilor->StartReconcile(); |
| 349 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION, | 349 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION, |
| 350 reconcilor->GetState()); | 350 reconcilor->GetState()); |
| 351 base::RunLoop().RunUntilIdle(); | 351 base::RunLoop().RunUntilIdle(); |
| 352 | 352 |
| 353 std::vector<std::pair<std::string, bool> > accounts; | 353 std::vector<gaia::ListedAccount> accounts; |
| 354 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts)); | 354 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts)); |
| 355 ASSERT_EQ(0u, accounts.size()); | 355 ASSERT_EQ(0u, accounts.size()); |
| 356 | 356 |
| 357 base::RunLoop().RunUntilIdle(); | 357 base::RunLoop().RunUntilIdle(); |
| 358 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING_ERROR_OCCURED, | 358 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING_ERROR_OCCURED, |
| 359 reconcilor->GetState()); | 359 reconcilor->GetState()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_P(AccountReconcilorTest, StartReconcileNoop) { | 362 TEST_P(AccountReconcilorTest, StartReconcileNoop) { |
| 363 const std::string account_id = | 363 const std::string account_id = |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 390 test_signin_client()->set_are_signin_cookies_allowed(false); | 390 test_signin_client()->set_are_signin_cookies_allowed(false); |
| 391 | 391 |
| 392 AccountReconcilor* reconcilor = | 392 AccountReconcilor* reconcilor = |
| 393 AccountReconcilorFactory::GetForProfile(profile()); | 393 AccountReconcilorFactory::GetForProfile(profile()); |
| 394 ASSERT_TRUE(reconcilor); | 394 ASSERT_TRUE(reconcilor); |
| 395 | 395 |
| 396 reconcilor->StartReconcile(); | 396 reconcilor->StartReconcile(); |
| 397 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 397 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 398 | 398 |
| 399 base::RunLoop().RunUntilIdle(); | 399 base::RunLoop().RunUntilIdle(); |
| 400 std::vector<std::pair<std::string, bool> > accounts; | 400 std::vector<gaia::ListedAccount> accounts; |
| 401 // This will be the first call to ListAccounts. | 401 // This will be the first call to ListAccounts. |
| 402 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts)); | 402 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts)); |
| 403 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 403 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 404 } | 404 } |
| 405 | 405 |
| 406 TEST_P(AccountReconcilorTest, StartReconcileContentSettings) { | 406 TEST_P(AccountReconcilorTest, StartReconcileContentSettings) { |
| 407 const std::string account_id = | 407 const std::string account_id = |
| 408 ConnectProfileToAccount("12345", "user@gmail.com"); | 408 ConnectProfileToAccount("12345", "user@gmail.com"); |
| 409 token_service()->UpdateCredentials(account_id, "refresh_token"); | 409 token_service()->UpdateCredentials(account_id, "refresh_token"); |
| 410 | 410 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 756 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 756 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 757 | 757 |
| 758 SimulateAddAccountToCookieCompleted(reconcilor, account_id, | 758 SimulateAddAccountToCookieCompleted(reconcilor, account_id, |
| 759 GoogleServiceAuthError::AuthErrorNone()); | 759 GoogleServiceAuthError::AuthErrorNone()); |
| 760 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 760 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 761 } | 761 } |
| 762 | 762 |
| 763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, | 763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, |
| 764 AccountReconcilorTest, | 764 AccountReconcilorTest, |
| 765 testing::Bool()); | 765 testing::Bool()); |
| OLD | NEW |