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_tracker_service_factory.h" | 22 #include "chrome/browser/signin/account_tracker_service_factory.h" |
23 #include "chrome/browser/signin/fake_gaia_cookie_manager_service.h" | 23 #include "chrome/browser/signin/fake_gaia_cookie_manager_service.h" |
24 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 24 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
25 #include "chrome/browser/signin/fake_signin_manager.h" | 25 #include "chrome/browser/signin/fake_signin_manager_builder.h" |
26 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" | 26 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" |
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
28 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/extensions/api/identity.h" | 32 #include "chrome/common/extensions/api/identity.h" |
33 #include "chrome/test/base/in_process_browser_test.h" | 33 #include "chrome/test/base/in_process_browser_test.h" |
34 #include "chrome/test/base/test_switches.h" | 34 #include "chrome/test/base/test_switches.h" |
35 #include "components/crx_file/id_util.h" | 35 #include "components/crx_file/id_util.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 OnWillCreateBrowserContextServices, | 546 OnWillCreateBrowserContextServices, |
547 base::Unretained(this))) | 547 base::Unretained(this))) |
548 .Pass(); | 548 .Pass(); |
549 } | 549 } |
550 | 550 |
551 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { | 551 void OnWillCreateBrowserContextServices(content::BrowserContext* context) { |
552 // Replace the signin manager and token service with fakes. Do this ahead of | 552 // Replace the signin manager and token service with fakes. Do this ahead of |
553 // creating the browser so that a bunch of classes don't register as | 553 // creating the browser so that a bunch of classes don't register as |
554 // observers and end up needing to unregister when the fake is substituted. | 554 // observers and end up needing to unregister when the fake is substituted. |
555 SigninManagerFactory::GetInstance()->SetTestingFactory( | 555 SigninManagerFactory::GetInstance()->SetTestingFactory( |
556 context, &FakeSigninManagerBase::Build); | 556 context, &BuildFakeSigninManagerBase); |
557 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( | 557 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( |
558 context, &BuildFakeProfileOAuth2TokenService); | 558 context, &BuildFakeProfileOAuth2TokenService); |
559 GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory( | 559 GaiaCookieManagerServiceFactory::GetInstance()->SetTestingFactory( |
560 context, &FakeGaiaCookieManagerService::Build); | 560 context, &FakeGaiaCookieManagerService::Build); |
561 } | 561 } |
562 | 562 |
563 void SetUpOnMainThread() override { | 563 void SetUpOnMainThread() override { |
564 AsyncExtensionBrowserTest::SetUpOnMainThread(); | 564 AsyncExtensionBrowserTest::SetUpOnMainThread(); |
565 | 565 |
566 // Grab references to the fake signin manager and token service. | 566 // Grab references to the fake signin manager and token service. |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1835 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1836 url); | 1836 url); |
1837 } | 1837 } |
1838 | 1838 |
1839 } // namespace extensions | 1839 } // namespace extensions |
1840 | 1840 |
1841 // Tests the chrome.identity API implemented by custom JS bindings . | 1841 // Tests the chrome.identity API implemented by custom JS bindings . |
1842 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1842 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1843 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1843 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1844 } | 1844 } |
OLD | NEW |