| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 account_tracker_->EnableNetworkFetches(); | 257 account_tracker_->EnableNetworkFetches(); |
| 258 account_tracker_->AddObserver(&observer_); | 258 account_tracker_->AddObserver(&observer_); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void TearDown() override { | 261 void TearDown() override { |
| 262 account_tracker_->RemoveObserver(&observer_); | 262 account_tracker_->RemoveObserver(&observer_); |
| 263 account_tracker_->Shutdown(); | 263 account_tracker_->Shutdown(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 void SimulateTokenAvailable(const std::string& account_id) { | 266 void SimulateTokenAvailable(const std::string& account_id) { |
| 267 fake_oauth2_token_service_->AddAccount(account_id); | 267 fake_oauth2_token_service_->GetDelegate()->UpdateCredentials( |
| 268 account_id, "refresh_token"); |
| 268 } | 269 } |
| 269 | 270 |
| 270 void SimulateTokenRevoked(const std::string& account_id) { | 271 void SimulateTokenRevoked(const std::string& account_id) { |
| 271 fake_oauth2_token_service_->RemoveAccount(account_id); | 272 fake_oauth2_token_service_->GetDelegate()->RevokeCredentials(account_id); |
| 272 } | 273 } |
| 273 | 274 |
| 274 // Helpers to fake access token and user info fetching | 275 // Helpers to fake access token and user info fetching |
| 275 void IssueAccessToken(const std::string& account_id) { | 276 void IssueAccessToken(const std::string& account_id) { |
| 276 fake_oauth2_token_service_->IssueAllTokensForAccount( | 277 fake_oauth2_token_service_->IssueAllTokensForAccount( |
| 277 account_id, "access_token-" + account_id, base::Time::Max()); | 278 account_id, "access_token-" + account_id, base::Time::Max()); |
| 278 } | 279 } |
| 279 | 280 |
| 280 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { | 281 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { |
| 281 return base::StringPrintf( | 282 return base::StringPrintf( |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 tracker.GetAccounts(); | 733 tracker.GetAccounts(); |
| 733 ASSERT_EQ(2u, infos.size()); | 734 ASSERT_EQ(2u, infos.size()); |
| 734 ASSERT_TRUE(infos[0].IsValid()); | 735 ASSERT_TRUE(infos[0].IsValid()); |
| 735 ASSERT_TRUE(infos[1].IsValid()); | 736 ASSERT_TRUE(infos[1].IsValid()); |
| 736 | 737 |
| 737 tracker.EnableNetworkFetches(); | 738 tracker.EnableNetworkFetches(); |
| 738 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); | 739 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); |
| 739 tracker.Shutdown(); | 740 tracker.Shutdown(); |
| 740 } | 741 } |
| 741 } | 742 } |
| OLD | NEW |