| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/signin/mutable_profile_oauth2_token_service.h" | 6 #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" |
| 7 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 7 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 9 #include "chrome/browser/webdata/web_data_service_factory.h" | 9 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "components/signin/core/webdata/token_web_data.h" | 11 #include "components/signin/core/webdata/token_web_data.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "google_apis/gaia/gaia_constants.h" | 13 #include "google_apis/gaia/gaia_constants.h" |
| 14 #include "google_apis/gaia/gaia_urls.h" | 14 #include "google_apis/gaia/gaia_urls.h" |
| 15 #include "google_apis/gaia/oauth2_token_service_test_util.h" | 15 #include "google_apis/gaia/oauth2_token_service_test_util.h" |
| 16 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
| 17 #include "net/url_request/test_url_fetcher_factory.h" | 17 #include "net/url_request/test_url_fetcher_factory.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 21 #include "components/encryptor/encryptor.h" | 21 #include "components/encryptor/os_crypt.h" |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 // Defining constant here to handle backward compatiblity tests, but this | 24 // Defining constant here to handle backward compatiblity tests, but this |
| 25 // constant is no longer used in current versions of chrome. | 25 // constant is no longer used in current versions of chrome. |
| 26 static const char kLSOService[] = "lso"; | 26 static const char kLSOService[] = "lso"; |
| 27 static const char kEmail[] = "user@gmail.com"; | 27 static const char kEmail[] = "user@gmail.com"; |
| 28 | 28 |
| 29 class MutableProfileOAuth2TokenServiceTest : | 29 class MutableProfileOAuth2TokenServiceTest : |
| 30 public testing::Test, | 30 public testing::Test, |
| 31 public OAuth2TokenService::Observer { | 31 public OAuth2TokenService::Observer { |
| 32 public: | 32 public: |
| 33 MutableProfileOAuth2TokenServiceTest() | 33 MutableProfileOAuth2TokenServiceTest() |
| 34 : factory_(NULL), | 34 : factory_(NULL), |
| 35 oauth2_service_(NULL), | 35 oauth2_service_(NULL), |
| 36 token_available_count_(0), | 36 token_available_count_(0), |
| 37 token_revoked_count_(0), | 37 token_revoked_count_(0), |
| 38 tokens_loaded_count_(0) { | 38 tokens_loaded_count_(0) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 Encryptor::UseMockKeychain(true); | 43 OSCrypt::UseMockKeychain(true); |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 profile_.reset(new TestingProfile); | 46 profile_.reset(new TestingProfile); |
| 47 profile_->CreateWebDataService(); | 47 profile_->CreateWebDataService(); |
| 48 | 48 |
| 49 factory_.SetFakeResponse(GaiaUrls::GetInstance()->oauth2_revoke_url(), | 49 factory_.SetFakeResponse(GaiaUrls::GetInstance()->oauth2_revoke_url(), |
| 50 "", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 50 "", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 51 oauth2_service_ = | 51 oauth2_service_ = |
| 52 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 52 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| 53 profile()); | 53 profile()); |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); | 338 oauth2_service_->set_max_authorization_token_fetch_retries_for_testing(0); |
| 339 oauth2_service_->UpdateCredentials(kEmail, "refreshToken"); | 339 oauth2_service_->UpdateCredentials(kEmail, "refreshToken"); |
| 340 ExpectOneTokenAvailableNotification(); | 340 ExpectOneTokenAvailableNotification(); |
| 341 | 341 |
| 342 scoped_ptr<OAuth2TokenService::Request> request( | 342 scoped_ptr<OAuth2TokenService::Request> request( |
| 343 oauth2_service_->StartRequest(kEmail, scope_list, &consumer_)); | 343 oauth2_service_->StartRequest(kEmail, scope_list, &consumer_)); |
| 344 base::RunLoop().RunUntilIdle(); | 344 base::RunLoop().RunUntilIdle(); |
| 345 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), | 345 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), |
| 346 oauth2_service_->signin_global_error()->GetLastAuthError()); | 346 oauth2_service_->signin_global_error()->GetLastAuthError()); |
| 347 } | 347 } |
| OLD | NEW |