| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 function->SetArgs(parsed_args.get()); | 131 function->SetArgs(parsed_args.get()); |
| 132 | 132 |
| 133 if (!function->extension()) { | 133 if (!function->extension()) { |
| 134 scoped_refptr<Extension> empty_extension( | 134 scoped_refptr<Extension> empty_extension( |
| 135 test_util::CreateEmptyExtension()); | 135 test_util::CreateEmptyExtension()); |
| 136 function->set_extension(empty_extension.get()); | 136 function->set_extension(empty_extension.get()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 function->set_browser_context(browser()->profile()); | 139 function->set_browser_context(browser()->profile()); |
| 140 function->set_has_callback(true); | 140 function->set_has_callback(true); |
| 141 function->Run()->Execute(); | 141 function->RunWithValidation()->Execute(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 std::string WaitForError(UIThreadExtensionFunction* function) { | 144 std::string WaitForError(UIThreadExtensionFunction* function) { |
| 145 RunMessageLoopUntilResponse(); | 145 RunMessageLoopUntilResponse(); |
| 146 EXPECT_FALSE(function->GetResultList()) << "Did not expect a result"; | 146 EXPECT_FALSE(function->GetResultList()) << "Did not expect a result"; |
| 147 return function->GetError(); | 147 return function->GetError(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 base::Value* WaitForSingleResult(UIThreadExtensionFunction* function) { | 150 base::Value* WaitForSingleResult(UIThreadExtensionFunction* function) { |
| 151 RunMessageLoopUntilResponse(); | 151 RunMessageLoopUntilResponse(); |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1385 EXPECT_TRUE(value->GetAsString(&access_token)); | 1385 EXPECT_TRUE(value->GetAsString(&access_token)); |
| 1386 EXPECT_EQ(std::string(kAccessToken), access_token); | 1386 EXPECT_EQ(std::string(kAccessToken), access_token); |
| 1387 EXPECT_TRUE(func->login_ui_shown()); | 1387 EXPECT_TRUE(func->login_ui_shown()); |
| 1388 EXPECT_TRUE(func->scope_ui_shown()); | 1388 EXPECT_TRUE(func->scope_ui_shown()); |
| 1389 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN, | 1389 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN, |
| 1390 GetCachedToken(std::string()).status()); | 1390 GetCachedToken(std::string()).status()); |
| 1391 } | 1391 } |
| 1392 | 1392 |
| 1393 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ComponentWithChromeClientId) { | 1393 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ComponentWithChromeClientId) { |
| 1394 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1394 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
| 1395 func->ignore_did_respond_for_testing(); |
| 1395 scoped_refptr<const Extension> extension( | 1396 scoped_refptr<const Extension> extension( |
| 1396 CreateExtension(SCOPES | AS_COMPONENT)); | 1397 CreateExtension(SCOPES | AS_COMPONENT)); |
| 1397 func->set_extension(extension.get()); | 1398 func->set_extension(extension.get()); |
| 1398 const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); | 1399 const OAuth2Info& oauth2_info = OAuth2Info::GetOAuth2Info(extension.get()); |
| 1399 EXPECT_TRUE(oauth2_info.client_id.empty()); | 1400 EXPECT_TRUE(oauth2_info.client_id.empty()); |
| 1400 EXPECT_FALSE(func->GetOAuth2ClientId().empty()); | 1401 EXPECT_FALSE(func->GetOAuth2ClientId().empty()); |
| 1401 EXPECT_NE("client1", func->GetOAuth2ClientId()); | 1402 EXPECT_NE("client1", func->GetOAuth2ClientId()); |
| 1402 } | 1403 } |
| 1403 | 1404 |
| 1404 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ComponentWithNormalClientId) { | 1405 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, ComponentWithNormalClientId) { |
| 1405 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); | 1406 scoped_refptr<FakeGetAuthTokenFunction> func(new FakeGetAuthTokenFunction()); |
| 1407 func->ignore_did_respond_for_testing(); |
| 1406 scoped_refptr<const Extension> extension( | 1408 scoped_refptr<const Extension> extension( |
| 1407 CreateExtension(CLIENT_ID | SCOPES | AS_COMPONENT)); | 1409 CreateExtension(CLIENT_ID | SCOPES | AS_COMPONENT)); |
| 1408 func->set_extension(extension.get()); | 1410 func->set_extension(extension.get()); |
| 1409 EXPECT_EQ("client1", func->GetOAuth2ClientId()); | 1411 EXPECT_EQ("client1", func->GetOAuth2ClientId()); |
| 1410 } | 1412 } |
| 1411 | 1413 |
| 1412 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, MultiDefaultUser) { | 1414 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, MultiDefaultUser) { |
| 1413 SignIn("primary@example.com"); | 1415 SignIn("primary@example.com"); |
| 1414 SetAccountState(CreateIds("primary@example.com", "1"), true); | 1416 SetAccountState(CreateIds("primary@example.com", "1"), true); |
| 1415 SetAccountState(CreateIds("secondary@example.com", "2"), true); | 1417 SetAccountState(CreateIds("secondary@example.com", "2"), true); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1898 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
| 1897 url); | 1899 url); |
| 1898 } | 1900 } |
| 1899 | 1901 |
| 1900 } // namespace extensions | 1902 } // namespace extensions |
| 1901 | 1903 |
| 1902 // Tests the chrome.identity API implemented by custom JS bindings . | 1904 // Tests the chrome.identity API implemented by custom JS bindings . |
| 1903 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1905 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
| 1904 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1906 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
| 1905 } | 1907 } |
| OLD | NEW |