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

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

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
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 14 matching lines...) Expand all
25 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/testing_profile_manager.h" 26 #include "chrome/test/base/testing_profile_manager.h"
27 #include "components/signin/core/browser/account_reconcilor.h" 27 #include "components/signin/core/browser/account_reconcilor.h"
28 #include "components/signin/core/browser/account_tracker_service.h" 28 #include "components/signin/core/browser/account_tracker_service.h"
29 #include "components/signin/core/browser/profile_oauth2_token_service.h" 29 #include "components/signin/core/browser/profile_oauth2_token_service.h"
30 #include "components/signin/core/browser/signin_manager.h" 30 #include "components/signin/core/browser/signin_manager.h"
31 #include "components/signin/core/browser/signin_metrics.h" 31 #include "components/signin/core/browser/signin_metrics.h"
32 #include "components/signin/core/browser/test_signin_client.h" 32 #include "components/signin/core/browser/test_signin_client.h"
33 #include "components/signin/core/common/profile_management_switches.h" 33 #include "components/signin/core/common/profile_management_switches.h"
34 #include "components/signin/core/common/signin_switches.h" 34 #include "components/signin/core/common/signin_switches.h"
35 #include "components/user_manager/user_id.h"
35 #include "content/public/test/test_browser_thread_bundle.h" 36 #include "content/public/test/test_browser_thread_bundle.h"
36 #include "google_apis/gaia/gaia_constants.h" 37 #include "google_apis/gaia/gaia_constants.h"
37 #include "google_apis/gaia/gaia_urls.h" 38 #include "google_apis/gaia/gaia_urls.h"
38 #include "net/url_request/test_url_fetcher_factory.h" 39 #include "net/url_request/test_url_fetcher_factory.h"
39 #include "testing/gmock/include/gmock/gmock.h" 40 #include "testing/gmock/include/gmock/gmock.h"
40 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
41 42
42 namespace { 43 namespace {
43 44
44 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> { 45 class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 void SetFakeResponse(const std::string& url, 98 void SetFakeResponse(const std::string& url,
98 const std::string& data, 99 const std::string& data,
99 net::HttpStatusCode code, 100 net::HttpStatusCode code,
100 net::URLRequestStatus::Status status) { 101 net::URLRequestStatus::Status status) {
101 url_fetcher_factory_.SetFakeResponse(GURL(url), data, code, status); 102 url_fetcher_factory_.SetFakeResponse(GURL(url), data, code, status);
102 } 103 }
103 104
104 MockAccountReconcilor* GetMockReconcilor(); 105 MockAccountReconcilor* GetMockReconcilor();
105 106
106 std::string ConnectProfileToAccount(const std::string& gaia_id, 107 std::string ConnectProfileToAccount(const user_manager::UserID& user_id);
107 const std::string& username);
108 108
109 std::string PickAccountIdForAccount(const std::string& gaia_id, 109 std::string PickAccountIdForAccount(const user_manager::UserID& user_id);
110 const std::string& username);
111 110
112 void SimulateAddAccountToCookieCompleted( 111 void SimulateAddAccountToCookieCompleted(
113 GaiaCookieManagerService::Observer* observer, 112 GaiaCookieManagerService::Observer* observer,
114 const std::string& account_id, 113 const user_manager::UserID& user_id,
115 const GoogleServiceAuthError& error); 114 const GoogleServiceAuthError& error);
116 115
117 void SimulateCookieContentSettingsChanged( 116 void SimulateCookieContentSettingsChanged(
118 content_settings::Observer* observer, 117 content_settings::Observer* observer,
119 const ContentSettingsPattern& primary_pattern); 118 const ContentSettingsPattern& primary_pattern);
120 119
121 GURL get_check_connection_info_url() { 120 GURL get_check_connection_info_url() {
122 return get_check_connection_info_url_; 121 return get_check_connection_info_url_;
123 } 122 }
124 123
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (!mock_reconcilor_) { 212 if (!mock_reconcilor_) {
214 mock_reconcilor_ = 213 mock_reconcilor_ =
215 static_cast<MockAccountReconcilor*>( 214 static_cast<MockAccountReconcilor*>(
216 AccountReconcilorFactory::GetForProfile(profile())); 215 AccountReconcilorFactory::GetForProfile(profile()));
217 } 216 }
218 217
219 return mock_reconcilor_; 218 return mock_reconcilor_;
220 } 219 }
221 220
222 std::string AccountReconcilorTest::ConnectProfileToAccount( 221 std::string AccountReconcilorTest::ConnectProfileToAccount(
223 const std::string& gaia_id, 222 const user_manager::UserID& user_id) {
224 const std::string& username) {
225 const std::string account_id = PickAccountIdForAccount(gaia_id, username);
226 #if !defined(OS_CHROMEOS) 223 #if !defined(OS_CHROMEOS)
227 signin_manager()->set_password("password"); 224 signin_manager()->set_password("password");
228 #endif 225 #endif
229 signin_manager()->SetAuthenticatedAccountInfo(gaia_id, username); 226 signin_manager()->SetAuthenticatedAccountInfo(user_id);
230 token_service()->UpdateCredentials(account_id, "refresh_token"); 227 token_service()->UpdateCredentials(user_id, "refresh_token");
231 return account_id; 228 return account_id;
232 } 229 }
233 230
234 std::string AccountReconcilorTest::PickAccountIdForAccount( 231 std::string AccountReconcilorTest::PickAccountIdForAccount(const user_manager::U serID& user_id) {
235 const std::string& gaia_id, 232 return account_tracker()->PickAccountIdForAccount(user_id);
236 const std::string& username) {
237 return account_tracker()->PickAccountIdForAccount(gaia_id, username);
238 } 233 }
239 234
240 void AccountReconcilorTest::SimulateAddAccountToCookieCompleted( 235 void AccountReconcilorTest::SimulateAddAccountToCookieCompleted(
241 GaiaCookieManagerService::Observer* observer, 236 GaiaCookieManagerService::Observer* observer,
242 const std::string& account_id, 237 const std::string& account_id,
243 const GoogleServiceAuthError& error) { 238 const GoogleServiceAuthError& error) {
244 observer->OnAddAccountToCookieCompleted(account_id, error); 239 observer->OnAddAccountToCookieCompleted(account_id, error);
245 } 240 }
246 241
247 void AccountReconcilorTest::SimulateCookieContentSettingsChanged( 242 void AccountReconcilorTest::SimulateCookieContentSettingsChanged(
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 ASSERT_TRUE(reconcilor->is_reconcile_started_); 751 ASSERT_TRUE(reconcilor->is_reconcile_started_);
757 752
758 SimulateAddAccountToCookieCompleted(reconcilor, account_id, 753 SimulateAddAccountToCookieCompleted(reconcilor, account_id,
759 GoogleServiceAuthError::AuthErrorNone()); 754 GoogleServiceAuthError::AuthErrorNone());
760 ASSERT_FALSE(reconcilor->is_reconcile_started_); 755 ASSERT_FALSE(reconcilor->is_reconcile_started_);
761 } 756 }
762 757
763 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled, 758 INSTANTIATE_TEST_CASE_P(AccountReconcilorMaybeEnabled,
764 AccountReconcilorTest, 759 AccountReconcilorTest,
765 testing::Bool()); 760 testing::Bool());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698