| 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" | 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" | |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 24 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 25 #include "google_apis/gaia/google_service_auth_error.h" | 23 #include "google_apis/gaia/google_service_auth_error.h" |
| 26 #include "google_apis/gaia/oauth2_mint_token_flow.h" | 24 #include "google_apis/gaia/oauth2_mint_token_flow.h" |
| 27 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 28 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 MOCK_METHOD1(CreateMintTokenFlow, | 135 MOCK_METHOD1(CreateMintTokenFlow, |
| 138 OAuth2MintTokenFlow* (OAuth2MintTokenFlow::Mode mode)); | 136 OAuth2MintTokenFlow* (OAuth2MintTokenFlow::Mode mode)); |
| 139 private: | 137 private: |
| 140 ~MockGetAuthTokenFunction() {} | 138 ~MockGetAuthTokenFunction() {} |
| 141 bool install_ui_result_; | 139 bool install_ui_result_; |
| 142 bool login_ui_shown_; | 140 bool login_ui_shown_; |
| 143 bool install_ui_shown_; | 141 bool install_ui_shown_; |
| 144 }; | 142 }; |
| 145 | 143 |
| 146 class GetAuthTokenFunctionTest : public ExtensionBrowserTest { | 144 class GetAuthTokenFunctionTest : public ExtensionBrowserTest { |
| 147 public: | |
| 148 virtual void SetUp() OVERRIDE { | |
| 149 ExtensionBrowserTest::SetUp(); | |
| 150 ManifestHandler::Register(extension_manifest_keys::kOAuth2, | |
| 151 make_linked_ptr(new OAuth2ManifestHandler)); | |
| 152 } | |
| 153 protected: | 145 protected: |
| 154 enum OAuth2Fields { | 146 enum OAuth2Fields { |
| 155 NONE = 0, | 147 NONE = 0, |
| 156 CLIENT_ID = 1, | 148 CLIENT_ID = 1, |
| 157 SCOPES = 2 | 149 SCOPES = 2 |
| 158 }; | 150 }; |
| 159 | 151 |
| 160 virtual ~GetAuthTokenFunctionTest() {} | 152 virtual ~GetAuthTokenFunctionTest() {} |
| 161 | 153 |
| 162 // Helper to create an extension with specific OAuth2Info fields set. | 154 // Helper to create an extension with specific OAuth2Info fields set. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, Bounds) { | 447 IN_PROC_BROWSER_TEST_F(LaunchWebAuthFlowFunctionTest, Bounds) { |
| 456 RunAndCheckBounds("", 0, 0, 0, 0); | 448 RunAndCheckBounds("", 0, 0, 0, 0); |
| 457 RunAndCheckBounds("\"width\": 100, \"height\": 200", 0, 0, 100, 200); | 449 RunAndCheckBounds("\"width\": 100, \"height\": 200", 0, 0, 100, 200); |
| 458 RunAndCheckBounds("\"left\": 100, \"top\": 200", 100, 200, 0, 0); | 450 RunAndCheckBounds("\"left\": 100, \"top\": 200", 100, 200, 0, 0); |
| 459 RunAndCheckBounds( | 451 RunAndCheckBounds( |
| 460 "\"left\": 100, \"top\": 200, \"width\": 300, \"height\": 400", | 452 "\"left\": 100, \"top\": 200, \"width\": 300, \"height\": 400", |
| 461 100, 200, 300, 400); | 453 100, 200, 300, 400); |
| 462 } | 454 } |
| 463 | 455 |
| 464 } // namespace extensions | 456 } // namespace extensions |
| OLD | NEW |