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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/signin/fake_signin_manager.h" | 26 #include "chrome/browser/signin/fake_signin_manager.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/common/extensions/api/identity/oauth2_manifest_handler.h" | 33 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.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/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
37 #include "components/signin/core/common/profile_management_switches.h" | 38 #include "components/signin/core/common/profile_management_switches.h" |
38 #include "components/signin/core/common/signin_pref_names.h" | 39 #include "components/signin/core/common/signin_pref_names.h" |
39 #include "content/public/browser/notification_service.h" | 40 #include "content/public/browser/notification_service.h" |
40 #include "content/public/browser/notification_source.h" | 41 #include "content/public/browser/notification_source.h" |
41 #include "content/public/test/test_utils.h" | 42 #include "content/public/test/test_utils.h" |
42 #include "extensions/browser/guest_view/guest_view_base.h" | 43 #include "extensions/browser/guest_view/guest_view_base.h" |
43 #include "extensions/common/id_util.h" | |
44 #include "google_apis/gaia/google_service_auth_error.h" | 44 #include "google_apis/gaia/google_service_auth_error.h" |
45 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 45 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
46 #include "net/test/spawned_test_server/spawned_test_server.h" | 46 #include "net/test/spawned_test_server/spawned_test_server.h" |
47 #include "testing/gmock/include/gmock/gmock.h" | 47 #include "testing/gmock/include/gmock/gmock.h" |
48 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
49 #include "url/gurl.h" | 49 #include "url/gurl.h" |
50 | 50 |
51 using testing::_; | 51 using testing::_; |
52 using testing::Return; | 52 using testing::Return; |
53 using testing::ReturnRef; | 53 using testing::ReturnRef; |
(...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 std::string("[{\"token\": \"") + kAccessToken + "\"}]", | 1600 std::string("[{\"token\": \"") + kAccessToken + "\"}]", |
1601 browser(), | 1601 browser(), |
1602 extension_function_test_utils::NONE); | 1602 extension_function_test_utils::NONE); |
1603 } | 1603 } |
1604 | 1604 |
1605 IdentityAPI* id_api() { | 1605 IdentityAPI* id_api() { |
1606 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); | 1606 return IdentityAPI::GetFactoryInstance()->Get(browser()->profile()); |
1607 } | 1607 } |
1608 | 1608 |
1609 void SetCachedToken(IdentityTokenCacheValue& token_data) { | 1609 void SetCachedToken(IdentityTokenCacheValue& token_data) { |
1610 ExtensionTokenKey key(extensions::id_util::GenerateId(kExtensionId), | 1610 ExtensionTokenKey key(crx_file::id_util::GenerateId(kExtensionId), |
1611 "test@example.com", | 1611 "test@example.com", |
1612 std::set<std::string>()); | 1612 std::set<std::string>()); |
1613 id_api()->SetCachedToken(key, token_data); | 1613 id_api()->SetCachedToken(key, token_data); |
1614 } | 1614 } |
1615 | 1615 |
1616 const IdentityTokenCacheValue& GetCachedToken() { | 1616 const IdentityTokenCacheValue& GetCachedToken() { |
1617 return id_api()->GetCachedToken( | 1617 return id_api()->GetCachedToken( |
1618 ExtensionTokenKey(extensions::id_util::GenerateId(kExtensionId), | 1618 ExtensionTokenKey(crx_file::id_util::GenerateId(kExtensionId), |
1619 "test@example.com", | 1619 "test@example.com", |
1620 std::set<std::string>())); | 1620 std::set<std::string>())); |
1621 } | 1621 } |
1622 }; | 1622 }; |
1623 | 1623 |
1624 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, NotFound) { | 1624 IN_PROC_BROWSER_TEST_F(RemoveCachedAuthTokenFunctionTest, NotFound) { |
1625 EXPECT_TRUE(InvalidateDefaultToken()); | 1625 EXPECT_TRUE(InvalidateDefaultToken()); |
1626 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND, | 1626 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_NOTFOUND, |
1627 GetCachedToken().status()); | 1627 GetCachedToken().status()); |
1628 } | 1628 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1819 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1820 url); | 1820 url); |
1821 } | 1821 } |
1822 | 1822 |
1823 } // namespace extensions | 1823 } // namespace extensions |
1824 | 1824 |
1825 // Tests the chrome.identity API implemented by custom JS bindings . | 1825 // Tests the chrome.identity API implemented by custom JS bindings . |
1826 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1826 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1827 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1827 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1828 } | 1828 } |
OLD | NEW |