| 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/ui/app_list/speech_auth_helper.h" | 5 #include "chrome/browser/ui/app_list/speech_auth_helper.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/simple_test_clock.h" | 11 #include "base/test/simple_test_clock.h" |
| 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" | 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "chrome/test/base/testing_profile_manager.h" | 17 #include "chrome/test/base/testing_profile_manager.h" |
| 18 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" | 18 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h" |
| 19 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
| 20 #include "components/signin/core/browser/signin_manager_base.h" | 20 #include "components/signin/core/browser/signin_manager_base.h" |
| 21 #include "components/syncable_prefs/pref_service_syncable.h" | 21 #include "components/sync_preferences/pref_service_syncable.h" |
| 22 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 23 #include "google_apis/gaia/google_service_auth_error.h" | 23 #include "google_apis/gaia/google_service_auth_error.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 namespace app_list { | 26 namespace app_list { |
| 27 | 27 |
| 28 static const char* kTestGaiaId = "gaia_id"; | 28 static const char* kTestGaiaId = "gaia_id"; |
| 29 static const char* kTestUser = "test.user@chromium.org.test"; | 29 static const char* kTestUser = "test.user@chromium.org.test"; |
| 30 static const char* kScope = "https://www.googleapis.com/auth/webhistory"; | 30 static const char* kScope = "https://www.googleapis.com/auth/webhistory"; |
| 31 static const char* kAccessToken = "fake_access_token"; | 31 static const char* kAccessToken = "fake_access_token"; |
| 32 | 32 |
| 33 class SpeechAuthHelperTest : public testing::Test { | 33 class SpeechAuthHelperTest : public testing::Test { |
| 34 public: | 34 public: |
| 35 SpeechAuthHelperTest() | 35 SpeechAuthHelperTest() |
| 36 : testing_profile_manager_(new TestingProfileManager( | 36 : testing_profile_manager_(new TestingProfileManager( |
| 37 TestingBrowserProcess::GetGlobal())) { | 37 TestingBrowserProcess::GetGlobal())) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void SetUp() override { | 40 void SetUp() override { |
| 41 // Set up FakeProfileOAuth2TokenService. | 41 // Set up FakeProfileOAuth2TokenService. |
| 42 TestingProfile::TestingFactories factories; | 42 TestingProfile::TestingFactories factories; |
| 43 factories.push_back(std::make_pair( | 43 factories.push_back(std::make_pair( |
| 44 ProfileOAuth2TokenServiceFactory::GetInstance(), | 44 ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 45 &BuildAutoIssuingFakeProfileOAuth2TokenService)); | 45 &BuildAutoIssuingFakeProfileOAuth2TokenService)); |
| 46 | 46 |
| 47 ASSERT_TRUE(testing_profile_manager_->SetUp()); | 47 ASSERT_TRUE(testing_profile_manager_->SetUp()); |
| 48 profile_ = testing_profile_manager_->CreateTestingProfile( | 48 profile_ = testing_profile_manager_->CreateTestingProfile( |
| 49 kTestUser, std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), | 49 kTestUser, std::unique_ptr<sync_preferences::PrefServiceSyncable>(), |
| 50 base::UTF8ToUTF16(kTestUser), 0, std::string(), factories); | 50 base::UTF8ToUTF16(kTestUser), 0, std::string(), factories); |
| 51 | 51 |
| 52 // Set up the authenticated user name and ID. | 52 // Set up the authenticated user name and ID. |
| 53 SigninManagerFactory::GetForProfile(profile_)->SetAuthenticatedAccountInfo( | 53 SigninManagerFactory::GetForProfile(profile_)->SetAuthenticatedAccountInfo( |
| 54 kTestGaiaId, kTestUser); | 54 kTestGaiaId, kTestUser); |
| 55 } | 55 } |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 void SetupRefreshToken() { | 58 void SetupRefreshToken() { |
| 59 std::string account_id = SigninManagerFactory::GetForProfile(profile_) | 59 std::string account_id = SigninManagerFactory::GetForProfile(profile_) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 OAuth2TokenService::ScopeSet scopes; | 112 OAuth2TokenService::ScopeSet scopes; |
| 113 scopes.insert(kScope); | 113 scopes.insert(kScope); |
| 114 GetFakeProfileOAuth2TokenService()->IssueErrorForScope( | 114 GetFakeProfileOAuth2TokenService()->IssueErrorForScope( |
| 115 scopes, GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_ERROR)); | 115 scopes, GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_ERROR)); |
| 116 | 116 |
| 117 EXPECT_TRUE(helper.GetToken().empty()); | 117 EXPECT_TRUE(helper.GetToken().empty()); |
| 118 EXPECT_EQ(kScope, helper.GetScope()); | 118 EXPECT_EQ(kScope, helper.GetScope()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace app_list | 121 } // namespace app_list |
| OLD | NEW |