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" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/testing_pref_service.h" | 10 #include "base/prefs/testing_pref_service.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 events_.clear(); | 185 events_.clear(); |
186 return result; | 186 return result; |
187 } | 187 } |
188 | 188 |
189 } // namespace | 189 } // namespace |
190 | 190 |
191 class AccountTrackerServiceTest : public testing::Test { | 191 class AccountTrackerServiceTest : public testing::Test { |
192 public: | 192 public: |
193 AccountTrackerServiceTest() {} | 193 AccountTrackerServiceTest() {} |
194 | 194 |
195 virtual ~AccountTrackerServiceTest() {} | 195 ~AccountTrackerServiceTest() override {} |
196 | 196 |
197 virtual void SetUp() override { | 197 void SetUp() override { |
198 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); | 198 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); |
199 | 199 |
200 pref_service_.registry()->RegisterListPref( | 200 pref_service_.registry()->RegisterListPref( |
201 AccountTrackerService::kAccountInfoPref); | 201 AccountTrackerService::kAccountInfoPref); |
202 pref_service_.registry()->RegisterIntegerPref( | 202 pref_service_.registry()->RegisterIntegerPref( |
203 prefs::kAccountIdMigrationState, | 203 prefs::kAccountIdMigrationState, |
204 AccountTrackerService::MIGRATION_NOT_STARTED); | 204 AccountTrackerService::MIGRATION_NOT_STARTED); |
205 | 205 |
206 account_tracker_.reset(new AccountTrackerService()); | 206 account_tracker_.reset(new AccountTrackerService()); |
207 account_tracker_->Initialize(fake_oauth2_token_service_.get(), | 207 account_tracker_->Initialize(fake_oauth2_token_service_.get(), |
208 &pref_service_, | 208 &pref_service_, |
209 new net::TestURLRequestContextGetter( | 209 new net::TestURLRequestContextGetter( |
210 message_loop_.message_loop_proxy())); | 210 message_loop_.message_loop_proxy())); |
211 account_tracker_->AddObserver(&observer_); | 211 account_tracker_->AddObserver(&observer_); |
212 } | 212 } |
213 | 213 |
214 virtual void TearDown() override { | 214 void TearDown() override { |
215 account_tracker_->RemoveObserver(&observer_); | 215 account_tracker_->RemoveObserver(&observer_); |
216 account_tracker_->Shutdown(); | 216 account_tracker_->Shutdown(); |
217 } | 217 } |
218 | 218 |
219 void SimulateTokenAvailable(const std::string& account_id) { | 219 void SimulateTokenAvailable(const std::string& account_id) { |
220 fake_oauth2_token_service_->AddAccount(account_id); | 220 fake_oauth2_token_service_->AddAccount(account_id); |
221 } | 221 } |
222 | 222 |
223 void SimulateTokenRevoked(const std::string& account_id) { | 223 void SimulateTokenRevoked(const std::string& account_id) { |
224 fake_oauth2_token_service_->RemoveAccount(account_id); | 224 fake_oauth2_token_service_->RemoveAccount(account_id); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 const std::string account_id = | 520 const std::string account_id = |
521 account_tracker()->PickAccountIdForAccount(gaia_id, email); | 521 account_tracker()->PickAccountIdForAccount(gaia_id, email); |
522 account_tracker()->SeedAccountInfo(gaia_id, email); | 522 account_tracker()->SeedAccountInfo(gaia_id, email); |
523 | 523 |
524 infos = account_tracker()->GetAccounts(); | 524 infos = account_tracker()->GetAccounts(); |
525 EXPECT_EQ(1u, infos.size()); | 525 EXPECT_EQ(1u, infos.size()); |
526 EXPECT_EQ(account_id, infos[0].account_id); | 526 EXPECT_EQ(account_id, infos[0].account_id); |
527 EXPECT_EQ(gaia_id, infos[0].gaia); | 527 EXPECT_EQ(gaia_id, infos[0].gaia); |
528 EXPECT_EQ(email, infos[0].email); | 528 EXPECT_EQ(email, infos[0].email); |
529 } | 529 } |
OLD | NEW |