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

Side by Side Diff: chrome/browser/signin/account_reconcilor_unittest.cc

Issue 1104153002: Expose ReconcilorState. Rename MergeSession in Signin Tracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: VLOGging the reconcilor Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/signin/fake_gaia_cookie_manager_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 const std::string account_id = 316 const std::string account_id =
317 ConnectProfileToAccount("12345", "user@gmail.com"); 317 ConnectProfileToAccount("12345", "user@gmail.com");
318 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry( 318 cookie_manager_service()->SetListAccountsResponseOneAccountWithExpiry(
319 "user@gmail.com", true); 319 "user@gmail.com", true);
320 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id)); 320 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction(account_id));
321 321
322 AccountReconcilor* reconcilor = 322 AccountReconcilor* reconcilor =
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 reconcilor->StartReconcile(); 327 reconcilor->StartReconcile();
328 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION,
329 reconcilor->GetState());
327 base::RunLoop().RunUntilIdle(); 330 base::RunLoop().RunUntilIdle();
331 ASSERT_EQ(AccountReconcilor::State::APPLYING_CHANGES, reconcilor->GetState());
328 332
329 std::vector<std::pair<std::string, bool> > accounts; 333 std::vector<std::pair<std::string, bool> > accounts;
330 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts)); 334 ASSERT_TRUE(cookie_manager_service()->ListAccounts(&accounts));
331 ASSERT_EQ(1u, accounts.size()); 335 ASSERT_EQ(1u, accounts.size());
332 ASSERT_EQ(account_id, accounts[0].first); 336 ASSERT_EQ(account_id, accounts[0].first);
333 } 337 }
334 338
335 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) { 339 TEST_F(AccountReconcilorTest, GetAccountsFromCookieFailure) {
336 ConnectProfileToAccount("12345", "user@gmail.com"); 340 ConnectProfileToAccount("12345", "user@gmail.com");
337 cookie_manager_service()->SetListAccountsResponseHttpNotFound(); 341 cookie_manager_service()->SetListAccountsResponseWebLoginRequired();
338 342
339 AccountReconcilor* reconcilor = 343 AccountReconcilor* reconcilor =
340 AccountReconcilorFactory::GetForProfile(profile()); 344 AccountReconcilorFactory::GetForProfile(profile());
341 ASSERT_TRUE(reconcilor); 345 ASSERT_TRUE(reconcilor);
342 346
347 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING, reconcilor->GetState());
343 reconcilor->StartReconcile(); 348 reconcilor->StartReconcile();
349 ASSERT_EQ(AccountReconcilor::State::GATHERING_INFORMATION,
350 reconcilor->GetState());
344 base::RunLoop().RunUntilIdle(); 351 base::RunLoop().RunUntilIdle();
345 352
346 std::vector<std::pair<std::string, bool> > accounts; 353 std::vector<std::pair<std::string, bool> > accounts;
347 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts)); 354 ASSERT_FALSE(cookie_manager_service()->ListAccounts(&accounts));
348 ASSERT_EQ(0u, accounts.size()); 355 ASSERT_EQ(0u, accounts.size());
356
357 base::RunLoop().RunUntilIdle();
358 ASSERT_EQ(AccountReconcilor::State::NOT_RECONCILING_ERROR_OCCURED,
359 reconcilor->GetState());
349 } 360 }
350 361
351 TEST_P(AccountReconcilorTest, StartReconcileNoop) { 362 TEST_P(AccountReconcilorTest, StartReconcileNoop) {
352 const std::string account_id = 363 const std::string account_id =
353 ConnectProfileToAccount("12345", "user@gmail.com"); 364 ConnectProfileToAccount("12345", "user@gmail.com");
354 365
355 AccountReconcilor* reconcilor = 366 AccountReconcilor* reconcilor =
356 AccountReconcilorFactory::GetForProfile(profile()); 367 AccountReconcilorFactory::GetForProfile(profile());
357 ASSERT_TRUE(reconcilor); 368 ASSERT_TRUE(reconcilor);
358 369
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ASSERT_TRUE(reconcilor->is_reconcile_started_); 756 ASSERT_TRUE(reconcilor->is_reconcile_started_);
746 757
747 SimulateAddAccountToCookieCompleted(reconcilor, account_id, 758 SimulateAddAccountToCookieCompleted(reconcilor, account_id,
748 GoogleServiceAuthError::AuthErrorNone()); 759 GoogleServiceAuthError::AuthErrorNone());
749 ASSERT_FALSE(reconcilor->is_reconcile_started_); 760 ASSERT_FALSE(reconcilor->is_reconcile_started_);
750 } 761 }
751 762
752 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, 763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled,
753 AccountReconcilorTest, 764 AccountReconcilorTest,
754 testing::Bool()); 765 testing::Bool());
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/signin/fake_gaia_cookie_manager_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698