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 "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/identity/identity_api.h" | 8 #include "chrome/browser/extensions/api/identity/identity_api.h" |
9 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" | 9 #include "chrome/browser/extensions/api/identity/web_auth_flow.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_browsertest.h" | 11 #include "chrome/browser/extensions/extension_browsertest.h" |
12 #include "chrome/browser/extensions/extension_function_test_utils.h" | 12 #include "chrome/browser/extensions/extension_function_test_utils.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
| 19 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 20 #include "chrome/common/extensions/manifest_handler.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 23 #include "content/public/browser/notification_source.h" |
21 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
22 #include "google_apis/gaia/google_service_auth_error.h" | 25 #include "google_apis/gaia/google_service_auth_error.h" |
23 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 26 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
24 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
27 | 30 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 NONE = 0, | 150 NONE = 0, |
148 CLIENT_ID = 1, | 151 CLIENT_ID = 1, |
149 SCOPES = 2 | 152 SCOPES = 2 |
150 }; | 153 }; |
151 | 154 |
152 ~GetAuthTokenFunctionTest() {} | 155 ~GetAuthTokenFunctionTest() {} |
153 | 156 |
154 // Helper to create an extension with specific OAuth2Info fields set. | 157 // Helper to create an extension with specific OAuth2Info fields set. |
155 // |fields_to_set| should be computed by using fields of Oauth2Fields enum. | 158 // |fields_to_set| should be computed by using fields of Oauth2Fields enum. |
156 const Extension* CreateExtension(int fields_to_set) { | 159 const Extension* CreateExtension(int fields_to_set) { |
| 160 extensions::ManifestHandler::Register(extension_manifest_keys::kOAuth2, |
| 161 new extensions::OAuth2ManifestHandler); |
157 const Extension* ext = LoadExtension( | 162 const Extension* ext = LoadExtension( |
158 test_data_dir_.AppendASCII("platform_apps/oauth2")); | 163 test_data_dir_.AppendASCII("platform_apps/oauth2")); |
159 Extension::OAuth2Info& oauth2_info = const_cast<Extension::OAuth2Info&>( | 164 extensions::OAuth2Info& oauth2_info = const_cast<extensions::OAuth2Info&>( |
160 ext->oauth2_info()); | 165 extensions::OAuth2Info::GetOAuth2Info(ext)); |
161 if ((fields_to_set & CLIENT_ID) != 0) | 166 if ((fields_to_set & CLIENT_ID) != 0) |
162 oauth2_info.client_id = "client1"; | 167 oauth2_info.client_id = "client1"; |
163 if ((fields_to_set & SCOPES) != 0) { | 168 if ((fields_to_set & SCOPES) != 0) { |
164 oauth2_info.scopes.push_back("scope1"); | 169 oauth2_info.scopes.push_back("scope1"); |
165 oauth2_info.scopes.push_back("scope2"); | 170 oauth2_info.scopes.push_back("scope2"); |
166 } | 171 } |
167 return ext; | 172 return ext; |
168 } | 173 } |
169 }; | 174 }; |
170 | 175 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 }; | 450 }; |
446 | 451 |
447 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, Bounds) { | 452 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, Bounds) { |
448 RunAndCheckBounds("", 0, 0, 0, 0); | 453 RunAndCheckBounds("", 0, 0, 0, 0); |
449 RunAndCheckBounds("\"width\": 100, \"height\": 200", 0, 0, 100, 200); | 454 RunAndCheckBounds("\"width\": 100, \"height\": 200", 0, 0, 100, 200); |
450 RunAndCheckBounds("\"left\": 100, \"top\": 200", 100, 200, 0, 0); | 455 RunAndCheckBounds("\"left\": 100, \"top\": 200", 100, 200, 0, 0); |
451 RunAndCheckBounds( | 456 RunAndCheckBounds( |
452 "\"left\": 100, \"top\": 200, \"width\": 300, \"height\": 400", | 457 "\"left\": 100, \"top\": 200, \"width\": 300, \"height\": 400", |
453 100, 200, 300, 400); | 458 100, 200, 300, 400); |
454 } | 459 } |
OLD | NEW |