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 "chrome/browser/services/gcm/gcm_account_tracker.h" | 5 #include "chrome/browser/services/gcm/gcm_account_tracker.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 tracker_.reset(new GCMAccountTracker(gaia_account_tracker.Pass(), &driver_)); | 204 tracker_.reset(new GCMAccountTracker(gaia_account_tracker.Pass(), &driver_)); |
205 } | 205 } |
206 | 206 |
207 GCMAccountTrackerTest::~GCMAccountTrackerTest() { | 207 GCMAccountTrackerTest::~GCMAccountTrackerTest() { |
208 if (tracker_) | 208 if (tracker_) |
209 tracker_->Shutdown(); | 209 tracker_->Shutdown(); |
210 } | 210 } |
211 | 211 |
212 void GCMAccountTrackerTest::StartAccountSignIn(const std::string& account_key) { | 212 void GCMAccountTrackerTest::StartAccountSignIn(const std::string& account_key) { |
213 fake_identity_provider_->LogIn(account_key); | 213 fake_identity_provider_->LogIn(account_key); |
214 fake_token_service_->AddAccount(account_key); | 214 fake_token_service_->GetDelegate()->UpdateCredentials(account_key, |
| 215 "refresh_token"); |
215 } | 216 } |
216 | 217 |
217 void GCMAccountTrackerTest::FinishAccountSignIn( | 218 void GCMAccountTrackerTest::FinishAccountSignIn( |
218 const std::string& account_key) { | 219 const std::string& account_key) { |
219 IssueAccessToken(account_key); | 220 IssueAccessToken(account_key); |
220 | 221 |
221 net::TestURLFetcher* fetcher = test_fetcher_factory_.GetFetcherByID( | 222 net::TestURLFetcher* fetcher = test_fetcher_factory_.GetFetcherByID( |
222 gaia::GaiaOAuthClient::kUrlFetcherId); | 223 gaia::GaiaOAuthClient::kUrlFetcherId); |
223 ASSERT_TRUE(fetcher); | 224 ASSERT_TRUE(fetcher); |
224 fetcher->set_response_code(net::HTTP_OK); | 225 fetcher->set_response_code(net::HTTP_OK); |
225 fetcher->SetResponseString(GetValidTokenInfoResponse(account_key)); | 226 fetcher->SetResponseString(GetValidTokenInfoResponse(account_key)); |
226 fetcher->delegate()->OnURLFetchComplete(fetcher); | 227 fetcher->delegate()->OnURLFetchComplete(fetcher); |
227 } | 228 } |
228 | 229 |
229 void GCMAccountTrackerTest::SignInAccount(const std::string& account_key) { | 230 void GCMAccountTrackerTest::SignInAccount(const std::string& account_key) { |
230 StartAccountSignIn(account_key); | 231 StartAccountSignIn(account_key); |
231 FinishAccountSignIn(account_key); | 232 FinishAccountSignIn(account_key); |
232 } | 233 } |
233 | 234 |
234 void GCMAccountTrackerTest::SignOutAccount(const std::string& account_key) { | 235 void GCMAccountTrackerTest::SignOutAccount(const std::string& account_key) { |
235 fake_token_service_->RemoveAccount(account_key); | 236 fake_token_service_->GetDelegate()->RevokeCredentials(account_key); |
236 } | 237 } |
237 | 238 |
238 void GCMAccountTrackerTest::IssueAccessToken(const std::string& account_key) { | 239 void GCMAccountTrackerTest::IssueAccessToken(const std::string& account_key) { |
239 fake_token_service_->IssueAllTokensForAccount( | 240 fake_token_service_->IssueAllTokensForAccount( |
240 account_key, MakeAccessToken(account_key), base::Time::Max()); | 241 account_key, MakeAccessToken(account_key), base::Time::Max()); |
241 } | 242 } |
242 | 243 |
243 void GCMAccountTrackerTest::IssueExpiredAccessToken( | 244 void GCMAccountTrackerTest::IssueExpiredAccessToken( |
244 const std::string& account_key) { | 245 const std::string& account_key) { |
245 fake_token_service_->IssueAllTokensForAccount( | 246 fake_token_service_->IssueAllTokensForAccount( |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // but we have the update call. | 512 // but we have the update call. |
512 SignOutAccount(kAccountId1); | 513 SignOutAccount(kAccountId1); |
513 EXPECT_TRUE(driver()->update_accounts_called()); | 514 EXPECT_TRUE(driver()->update_accounts_called()); |
514 EXPECT_FALSE(IsTokenReportingRequired()); | 515 EXPECT_FALSE(IsTokenReportingRequired()); |
515 } | 516 } |
516 | 517 |
517 // TODO(fgorski): Add test for adding account after removal >> make sure it does | 518 // TODO(fgorski): Add test for adding account after removal >> make sure it does |
518 // not mark removal. | 519 // not mark removal. |
519 | 520 |
520 } // namespace gcm | 521 } // namespace gcm |
OLD | NEW |