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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void set_should_post_quit(bool should_quit) { | 90 void set_should_post_quit(bool should_quit) { |
91 should_post_quit_ = should_quit; | 91 should_post_quit_ = should_quit; |
92 } | 92 } |
93 | 93 |
94 bool HasResponse() { | 94 bool HasResponse() { |
95 return response_.get() != NULL; | 95 return response_.get() != NULL; |
96 } | 96 } |
97 | 97 |
98 bool GetResponse() { | 98 bool GetResponse() { |
99 EXPECT_TRUE(HasResponse()); | 99 EXPECT_TRUE(HasResponse()); |
100 return *response_.get(); | 100 return *response_; |
101 } | 101 } |
102 | 102 |
103 void OnSendResponse(UIThreadExtensionFunction* function, | 103 void OnSendResponse(UIThreadExtensionFunction* function, |
104 bool success, | 104 bool success, |
105 bool bad_message) override { | 105 bool bad_message) override { |
106 ASSERT_FALSE(bad_message); | 106 ASSERT_FALSE(bad_message); |
107 ASSERT_FALSE(HasResponse()); | 107 ASSERT_FALSE(HasResponse()); |
108 response_.reset(new bool); | 108 response_.reset(new bool); |
109 *response_ = success; | 109 *response_ = success; |
110 if (should_post_quit_) { | 110 if (should_post_quit_) { |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 }; | 619 }; |
620 | 620 |
621 class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin { | 621 class IdentityGetProfileUserInfoFunctionTest : public IdentityTestWithSignin { |
622 protected: | 622 protected: |
623 std::unique_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { | 623 std::unique_ptr<api::identity::ProfileUserInfo> RunGetProfileUserInfo() { |
624 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 624 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
625 new IdentityGetProfileUserInfoFunction); | 625 new IdentityGetProfileUserInfoFunction); |
626 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); | 626 func->set_extension(test_util::CreateEmptyExtension(kExtensionId).get()); |
627 std::unique_ptr<base::Value> value( | 627 std::unique_ptr<base::Value> value( |
628 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); | 628 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); |
629 return api::identity::ProfileUserInfo::FromValue(*value.get()); | 629 return api::identity::ProfileUserInfo::FromValue(*value); |
630 } | 630 } |
631 | 631 |
632 std::unique_ptr<api::identity::ProfileUserInfo> | 632 std::unique_ptr<api::identity::ProfileUserInfo> |
633 RunGetProfileUserInfoWithEmail() { | 633 RunGetProfileUserInfoWithEmail() { |
634 scoped_refptr<IdentityGetProfileUserInfoFunction> func( | 634 scoped_refptr<IdentityGetProfileUserInfoFunction> func( |
635 new IdentityGetProfileUserInfoFunction); | 635 new IdentityGetProfileUserInfoFunction); |
636 func->set_extension(CreateExtensionWithEmailPermission()); | 636 func->set_extension(CreateExtensionWithEmailPermission()); |
637 std::unique_ptr<base::Value> value( | 637 std::unique_ptr<base::Value> value( |
638 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); | 638 utils::RunFunctionAndReturnSingleResult(func.get(), "[]", browser())); |
639 return api::identity::ProfileUserInfo::FromValue(*value.get()); | 639 return api::identity::ProfileUserInfo::FromValue(*value); |
640 } | 640 } |
641 | 641 |
642 private: | 642 private: |
643 scoped_refptr<Extension> CreateExtensionWithEmailPermission() { | 643 scoped_refptr<Extension> CreateExtensionWithEmailPermission() { |
644 std::unique_ptr<base::DictionaryValue> test_extension_value( | 644 std::unique_ptr<base::DictionaryValue> test_extension_value( |
645 api_test_utils::ParseDictionary( | 645 api_test_utils::ParseDictionary( |
646 "{\"name\": \"Test\", \"version\": \"1.0\", " | 646 "{\"name\": \"Test\", \"version\": \"1.0\", " |
647 "\"permissions\": [\"identity.email\"]}")); | 647 "\"permissions\": [\"identity.email\"]}")); |
648 return api_test_utils::CreateExtension(test_extension_value.get()); | 648 return api_test_utils::CreateExtension(test_extension_value.get()); |
649 } | 649 } |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1899 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1900 url); | 1900 url); |
1901 } | 1901 } |
1902 | 1902 |
1903 } // namespace extensions | 1903 } // namespace extensions |
1904 | 1904 |
1905 // Tests the chrome.identity API implemented by custom JS bindings . | 1905 // Tests the chrome.identity API implemented by custom JS bindings . |
1906 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1906 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1907 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1907 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1908 } | 1908 } |
OLD | NEW |