| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "components/signin/core/browser/fake_account_fetcher_service.h" | 6 #include "components/signin/core/browser/fake_account_fetcher_service.h" |
| 7 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 7 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 8 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 8 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 9 #include "components/sync_driver/profile_sync_auth_provider.h" | 9 #include "components/sync_driver/profile_sync_auth_provider.h" |
| 10 #include "google_apis/gaia/gaia_constants.h" | 10 #include "google_apis/gaia/gaia_constants.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 void RequestTokenFinished(const GoogleServiceAuthError& error, | 34 void RequestTokenFinished(const GoogleServiceAuthError& error, |
| 35 const std::string& token) { | 35 const std::string& token) { |
| 36 issued_tokens_.push_back(token); | 36 issued_tokens_.push_back(token); |
| 37 request_token_errors_.push_back(error); | 37 request_token_errors_.push_back(error); |
| 38 } | 38 } |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 base::MessageLoop message_loop_; | 41 base::MessageLoop message_loop_; |
| 42 | 42 |
| 43 scoped_ptr<FakeProfileOAuth2TokenService> token_service_; | 43 std::unique_ptr<FakeProfileOAuth2TokenService> token_service_; |
| 44 scoped_ptr<ProfileSyncAuthProvider> auth_provider_frontend_; | 44 std::unique_ptr<ProfileSyncAuthProvider> auth_provider_frontend_; |
| 45 scoped_ptr<syncer::SyncAuthProvider> auth_provider_backend_; | 45 std::unique_ptr<syncer::SyncAuthProvider> auth_provider_backend_; |
| 46 | 46 |
| 47 std::vector<std::string> issued_tokens_; | 47 std::vector<std::string> issued_tokens_; |
| 48 std::vector<GoogleServiceAuthError> request_token_errors_; | 48 std::vector<GoogleServiceAuthError> request_token_errors_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 TEST_F(ProfileSyncAuthProviderTest, RequestToken) { | 51 TEST_F(ProfileSyncAuthProviderTest, RequestToken) { |
| 52 // Request access token, make sure it gets valid response. | 52 // Request access token, make sure it gets valid response. |
| 53 auth_provider_backend_->RequestAccessToken( | 53 auth_provider_backend_->RequestAccessToken( |
| 54 base::Bind(&ProfileSyncAuthProviderTest::RequestTokenFinished, | 54 base::Bind(&ProfileSyncAuthProviderTest::RequestTokenFinished, |
| 55 base::Unretained(this))); | 55 base::Unretained(this))); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 73 run_loop.RunUntilIdle(); | 73 run_loop.RunUntilIdle(); |
| 74 EXPECT_EQ(2U, request_token_errors_.size()); | 74 EXPECT_EQ(2U, request_token_errors_.size()); |
| 75 | 75 |
| 76 EXPECT_EQ("", issued_tokens_[0]); | 76 EXPECT_EQ("", issued_tokens_[0]); |
| 77 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, | 77 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, |
| 78 request_token_errors_[0].state()); | 78 request_token_errors_[0].state()); |
| 79 | 79 |
| 80 EXPECT_NE("", issued_tokens_[1]); | 80 EXPECT_NE("", issued_tokens_[1]); |
| 81 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), request_token_errors_[1]); | 81 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), request_token_errors_[1]); |
| 82 } | 82 } |
| OLD | NEW |