| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/webui/settings/profile_info_handler.h" | 5 #include "chrome/browser/ui/webui/settings/profile_info_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 user_manager::FakeUserManager* user_manager_; | 89 user_manager::FakeUserManager* user_manager_; |
| 90 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 90 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 Profile* profile_; | 93 Profile* profile_; |
| 94 std::unique_ptr<TestProfileInfoHandler> handler_; | 94 std::unique_ptr<TestProfileInfoHandler> handler_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 TEST_F(ProfileInfoHandlerTest, GetProfileInfo) { | 97 TEST_F(ProfileInfoHandlerTest, GetProfileInfo) { |
| 98 base::ListValue list_args; | 98 base::ListValue list_args; |
| 99 list_args.Append(new base::StringValue("get-profile-info-callback-id")); | 99 list_args.AppendString("get-profile-info-callback-id"); |
| 100 handler()->HandleGetProfileInfo(&list_args); | 100 handler()->HandleGetProfileInfo(&list_args); |
| 101 | 101 |
| 102 EXPECT_EQ(1U, web_ui()->call_data().size()); | 102 EXPECT_EQ(1U, web_ui()->call_data().size()); |
| 103 | 103 |
| 104 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); | 104 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| 105 EXPECT_EQ("cr.webUIResponse", data.function_name()); | 105 EXPECT_EQ("cr.webUIResponse", data.function_name()); |
| 106 | 106 |
| 107 std::string callback_id; | 107 std::string callback_id; |
| 108 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); | 108 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); |
| 109 EXPECT_EQ("get-profile-info-callback-id", callback_id); | 109 EXPECT_EQ("get-profile-info-callback-id", callback_id); |
| 110 | 110 |
| 111 bool success = false; | 111 bool success = false; |
| 112 ASSERT_TRUE(data.arg2()->GetAsBoolean(&success)); | 112 ASSERT_TRUE(data.arg2()->GetAsBoolean(&success)); |
| 113 EXPECT_TRUE(success); | 113 EXPECT_TRUE(success); |
| 114 | 114 |
| 115 VerifyResponse(data.arg3()); | 115 VerifyResponse(data.arg3()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 TEST_F(ProfileInfoHandlerTest, PushProfileInfo) { | 118 TEST_F(ProfileInfoHandlerTest, PushProfileInfo) { |
| 119 base::ListValue list_args; | 119 base::ListValue list_args; |
| 120 list_args.Append(new base::StringValue("get-profile-info-callback-id")); | 120 list_args.AppendString("get-profile-info-callback-id"); |
| 121 handler()->HandleGetProfileInfo(&list_args); | 121 handler()->HandleGetProfileInfo(&list_args); |
| 122 | 122 |
| 123 handler()->OnProfileAvatarChanged(base::FilePath()); | 123 handler()->OnProfileAvatarChanged(base::FilePath()); |
| 124 | 124 |
| 125 EXPECT_EQ(2U, web_ui()->call_data().size()); | 125 EXPECT_EQ(2U, web_ui()->call_data().size()); |
| 126 | 126 |
| 127 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); | 127 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| 128 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); | 128 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 129 | 129 |
| 130 std::string event_id; | 130 std::string event_id; |
| 131 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 131 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 132 EXPECT_EQ(ProfileInfoHandler::kProfileInfoChangedEventName, event_id); | 132 EXPECT_EQ(ProfileInfoHandler::kProfileInfoChangedEventName, event_id); |
| 133 | 133 |
| 134 VerifyResponse(data.arg2()); | 134 VerifyResponse(data.arg2()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace settings | 137 } // namespace settings |
| OLD | NEW |