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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); | 830 utils::RunFunctionAndReturnError(func.get(), "[{}]", browser()); |
831 EXPECT_TRUE(StartsWithASCII(error, errors::kAuthFailure, false)); | 831 EXPECT_TRUE(StartsWithASCII(error, errors::kAuthFailure, false)); |
832 EXPECT_FALSE(func->login_ui_shown()); | 832 EXPECT_FALSE(func->login_ui_shown()); |
833 EXPECT_FALSE(func->scope_ui_shown()); | 833 EXPECT_FALSE(func->scope_ui_shown()); |
834 | 834 |
835 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), | 835 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), |
836 id_api()->GetAuthStatusForTest()); | 836 id_api()->GetAuthStatusForTest()); |
837 } | 837 } |
838 | 838 |
839 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, | 839 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
| 840 NoOptionsSuccess) { |
| 841 #if defined(OS_WIN) && defined(USE_ASH) |
| 842 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 843 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 844 return; |
| 845 #endif |
| 846 |
| 847 scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); |
| 848 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); |
| 849 func->set_extension(extension.get()); |
| 850 EXPECT_CALL(*func.get(), HasLoginToken()).WillOnce(Return(true)); |
| 851 TestOAuth2MintTokenFlow* flow = new TestOAuth2MintTokenFlow( |
| 852 TestOAuth2MintTokenFlow::MINT_TOKEN_SUCCESS, func.get()); |
| 853 EXPECT_CALL(*func.get(), CreateMintTokenFlow(_)).WillOnce(Return(flow)); |
| 854 scoped_ptr<base::Value> value(utils::RunFunctionAndReturnSingleResult( |
| 855 func.get(), "[]", browser())); |
| 856 std::string access_token; |
| 857 EXPECT_TRUE(value->GetAsString(&access_token)); |
| 858 EXPECT_EQ(std::string(kAccessToken), access_token); |
| 859 EXPECT_FALSE(func->login_ui_shown()); |
| 860 EXPECT_FALSE(func->scope_ui_shown()); |
| 861 EXPECT_EQ(IdentityTokenCacheValue::CACHE_STATUS_TOKEN, |
| 862 GetCachedToken(std::string()).status()); |
| 863 } |
| 864 |
| 865 IN_PROC_BROWSER_TEST_F(GetAuthTokenFunctionTest, |
840 NonInteractiveSuccess) { | 866 NonInteractiveSuccess) { |
841 #if defined(OS_WIN) && defined(USE_ASH) | 867 #if defined(OS_WIN) && defined(USE_ASH) |
842 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 868 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
843 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 869 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
844 return; | 870 return; |
845 #endif | 871 #endif |
846 | 872 |
847 scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); | 873 scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction()); |
848 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); | 874 scoped_refptr<const Extension> extension(CreateExtension(CLIENT_ID | SCOPES)); |
849 func->set_extension(extension.get()); | 875 func->set_extension(extension.get()); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1746 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1721 url); | 1747 url); |
1722 } | 1748 } |
1723 | 1749 |
1724 } // namespace extensions | 1750 } // namespace extensions |
1725 | 1751 |
1726 // Tests the chrome.identity API implemented by custom JS bindings . | 1752 // Tests the chrome.identity API implemented by custom JS bindings . |
1727 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1753 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1728 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1754 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1729 } | 1755 } |
OLD | NEW |