OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/extensions/api/identity/identity_api.h" | 15 #include "chrome/browser/extensions/api/identity/identity_api.h" |
16 #include "chrome/browser/extensions/component_loader.h" | 16 #include "chrome/browser/extensions/component_loader.h" |
17 #include "chrome/browser/extensions/extension_apitest.h" | 17 #include "chrome/browser/extensions/extension_apitest.h" |
18 #include "chrome/browser/extensions/extension_browsertest.h" | 18 #include "chrome/browser/extensions/extension_browsertest.h" |
19 #include "chrome/browser/extensions/extension_function_test_utils.h" | 19 #include "chrome/browser/extensions/extension_function_test_utils.h" |
20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/signin/account_reconcilor_factory.h" | |
23 #include "chrome/browser/signin/account_tracker_service_factory.h" | 22 #include "chrome/browser/signin/account_tracker_service_factory.h" |
24 #include "chrome/browser/signin/fake_account_reconcilor.h" | 23 #include "chrome/browser/signin/fake_gaia_cookie_manager_service.h" |
25 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 24 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
26 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 25 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
27 #include "chrome/browser/signin/fake_signin_manager.h" | 26 #include "chrome/browser/signin/fake_signin_manager.h" |
| 27 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
29 #include "chrome/browser/signin/signin_manager_factory.h" | 29 #include "chrome/browser/signin/signin_manager_factory.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/extensions/api/identity.h" | 33 #include "chrome/common/extensions/api/identity.h" |
34 #include "chrome/test/base/in_process_browser_test.h" | 34 #include "chrome/test/base/in_process_browser_test.h" |
35 #include "chrome/test/base/test_switches.h" | 35 #include "chrome/test/base/test_switches.h" |
36 #include "components/crx_file/id_util.h" | 36 #include "components/crx_file/id_util.h" |
37 #include "components/signin/core/browser/account_tracker_service.h" | 37 #include "components/signin/core/browser/account_tracker_service.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 } | 548 } |
549 | 549 |
550 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { | 550 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { |
551 // Replace the signin manager and token service with fakes. Do this ahead of | 551 // Replace the signin manager and token service with fakes. Do this ahead of |
552 // creating the browser so that a bunch of classes don't register as | 552 // creating the browser so that a bunch of classes don't register as |
553 // observers and end up needing to unregister when the fake is substituted. | 553 // observers and end up needing to unregister when the fake is substituted. |
554 SigninManagerFactory::GetInstance()->SetTestingFactory( | 554 SigninManagerFactory::GetInstance()->SetTestingFactory( |
555 context, &FakeSigninManagerBase::Build); | 555 context, &FakeSigninManagerBase::Build); |
556 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | 556 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
557 context, &BuildFakeProfileOAuth2TokenService); | 557 context, &BuildFakeProfileOAuth2TokenService); |
558 AccountReconcilorFactory::GetInstance()->SetTestingFactory( | 558 GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory( |
559 context, &FakeAccountReconcilor::Build); | 559 context, &FakeGaiaCookieManagerService::Build); |
560 } | 560 } |
561 | 561 |
562 void SetUpOnMainThread() override { | 562 void SetUpOnMainThread() override { |
563 AsyncExtensionBrowserTest::SetUpOnMainThread(); | 563 AsyncExtensionBrowserTest::SetUpOnMainThread(); |
564 | 564 |
565 // Grab references to the fake signin manager and token service. | 565 // Grab references to the fake signin manager and token service. |
566 signin_manager_ = static_cast<FakeSigninManagerForTesting*>( | 566 signin_manager_ = static_cast<FakeSigninManagerForTesting*>( |
567 SigninManagerFactory::GetInstance()->GetForProfile(profile())); | 567 SigninManagerFactory::GetInstance()->GetForProfile(profile())); |
568 ASSERT_TRUE(signin_manager_); | 568 ASSERT_TRUE(signin_manager_); |
569 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( | 569 token_service_ = static_cast<FakeProfileOAuth2TokenService*>( |
570 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( | 570 ProfileOAuth2TokenServiceFactory::GetInstance()->GetForProfile( |
571 profile())); | 571 profile())); |
572 ASSERT_TRUE(token_service_); | 572 ASSERT_TRUE(token_service_); |
| 573 GaiaCookieManagerServiceFactory::GetInstance()->GetForProfile(profile()) |
| 574 ->Init(); |
573 } | 575 } |
574 | 576 |
575 protected: | 577 protected: |
576 void SignIn(const std::string& account_key) { | 578 void SignIn(const std::string& account_key) { |
577 SignIn(account_key, account_key); | 579 SignIn(account_key, account_key); |
578 } | 580 } |
579 | 581 |
580 void SignIn(const std::string& email, const std::string& gaia) { | 582 void SignIn(const std::string& email, const std::string& gaia) { |
581 AccountTrackerService* account_tracker = | 583 AccountTrackerService* account_tracker = |
582 AccountTrackerServiceFactory::GetForProfile(profile()); | 584 AccountTrackerServiceFactory::GetForProfile(profile()); |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1825 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1824 url); | 1826 url); |
1825 } | 1827 } |
1826 | 1828 |
1827 } // namespace extensions | 1829 } // namespace extensions |
1828 | 1830 |
1829 // Tests the chrome.identity API implemented by custom JS bindings . | 1831 // Tests the chrome.identity API implemented by custom JS bindings . |
1830 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1832 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1831 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1833 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1832 } | 1834 } |
OLD | NEW |