OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | |
9 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
11 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
12 #include "components/signin/core/browser/account_tracker_service.h" | 11 #include "components/signin/core/browser/account_tracker_service.h" |
13 #include "components/signin/core/browser/test_signin_client.h" | 12 #include "components/signin/core/browser/test_signin_client.h" |
14 #include "components/signin/core/common/signin_pref_names.h" | 13 #include "components/signin/core/common/signin_pref_names.h" |
15 #include "google_apis/gaia/fake_oauth2_token_service.h" | 14 #include "google_apis/gaia/fake_oauth2_token_service.h" |
16 #include "google_apis/gaia/gaia_oauth_client.h" | 15 #include "google_apis/gaia/gaia_oauth_client.h" |
17 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
18 #include "net/url_request/test_url_fetcher_factory.h" | 17 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 252 |
254 pref_service_.registry()->RegisterListPref( | 253 pref_service_.registry()->RegisterListPref( |
255 AccountTrackerService::kAccountInfoPref); | 254 AccountTrackerService::kAccountInfoPref); |
256 pref_service_.registry()->RegisterIntegerPref( | 255 pref_service_.registry()->RegisterIntegerPref( |
257 prefs::kAccountIdMigrationState, | 256 prefs::kAccountIdMigrationState, |
258 AccountTrackerService::MIGRATION_NOT_STARTED); | 257 AccountTrackerService::MIGRATION_NOT_STARTED); |
259 pref_service_.registry()->RegisterInt64Pref( | 258 pref_service_.registry()->RegisterInt64Pref( |
260 AccountTrackerService::kAccountTrackerServiceLastUpdate, 0); | 259 AccountTrackerService::kAccountTrackerServiceLastUpdate, 0); |
261 signin_client_.reset(new TestSigninClient(&pref_service_)); | 260 signin_client_.reset(new TestSigninClient(&pref_service_)); |
262 signin_client_.get()->SetURLRequestContext( | 261 signin_client_.get()->SetURLRequestContext( |
263 new net::TestURLRequestContextGetter( | 262 new net::TestURLRequestContextGetter(message_loop_.task_runner())); |
264 message_loop_.message_loop_proxy())); | |
265 | 263 |
266 account_tracker_.reset(new AccountTrackerService()); | 264 account_tracker_.reset(new AccountTrackerService()); |
267 account_tracker_->Initialize(fake_oauth2_token_service_.get(), | 265 account_tracker_->Initialize(fake_oauth2_token_service_.get(), |
268 signin_client_.get()); | 266 signin_client_.get()); |
269 account_tracker_->EnableNetworkFetches(); | 267 account_tracker_->EnableNetworkFetches(); |
270 account_tracker_->AddObserver(&observer_); | 268 account_tracker_->AddObserver(&observer_); |
271 } | 269 } |
272 | 270 |
273 void TearDown() override { | 271 void TearDown() override { |
274 account_tracker_->RemoveObserver(&observer_); | 272 account_tracker_->RemoveObserver(&observer_); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 tracker.Initialize(token_service(), signin_client()); | 779 tracker.Initialize(token_service(), signin_client()); |
782 | 780 |
783 ASSERT_TRUE(tracker.IsAllUserInfoFetched()); | 781 ASSERT_TRUE(tracker.IsAllUserInfoFetched()); |
784 std::vector<AccountTrackerService::AccountInfo> infos = | 782 std::vector<AccountTrackerService::AccountInfo> infos = |
785 tracker.GetAccounts(); | 783 tracker.GetAccounts(); |
786 ASSERT_EQ(1u, infos.size()); | 784 ASSERT_EQ(1u, infos.size()); |
787 ASSERT_STREQ("foobar@gmail.com", infos[0].account_id.c_str()); | 785 ASSERT_STREQ("foobar@gmail.com", infos[0].account_id.c_str()); |
788 tracker.Shutdown(); | 786 tracker.Shutdown(); |
789 } | 787 } |
790 } | 788 } |
OLD | NEW |