Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc |
| diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc |
| index 7569be53ee753120eb2a3c5969ce25808f3ab0d4..c0572e63e0263358c5ff714c106ff33bcf6557af 100644 |
| --- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc |
| +++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc |
| @@ -42,6 +42,19 @@ class ManageProfileHandlerTest : public testing::Test { |
| handler_->set_web_ui(&web_ui_); |
| } |
| + void VerifyIconList(const base::Value* value) { |
| + const base::ListValue* icon_urls = nullptr; |
| + ASSERT_TRUE(value->GetAsList(&icon_urls)); |
| + |
| + // Expect the list of icon URLs to be a non-empty list of non-empty strings. |
| + EXPECT_FALSE(icon_urls->empty()); |
| + for (size_t i = 0; i < icon_urls->GetSize(); ++i) { |
| + std::string icon_url; |
| + EXPECT_TRUE(icon_urls->GetString(i, &icon_url)); |
| + EXPECT_FALSE(icon_url.empty()); |
| + } |
| + } |
| + |
| content::TestWebUI* web_ui() { return &web_ui_; } |
| Profile* profile() const { return profile_; } |
| TestManageProfileHandler* handler() const { return handler_.get(); } |
| @@ -71,27 +84,35 @@ TEST_F(ManageProfileHandlerTest, SetProfileIconAndName) { |
| } |
| TEST_F(ManageProfileHandlerTest, GetAvailableIcons) { |
|
dpapad
2016/04/07 20:34:24
Nit: TEST_F(ManageProfileHandlerTest, HandleGetAva
tommycli
2016/04/07 20:48:38
Done.
|
| - handler()->HandleGetAvailableIcons(nullptr); |
| + base::ListValue list_args; |
| + list_args.Append(new base::StringValue("get-icons-callback-id")); |
| + handler()->HandleGetAvailableIcons(&list_args); |
| EXPECT_EQ(1U, web_ui()->call_data().size()); |
| const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| - EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| + EXPECT_EQ("cr.webUIResponse", data.function_name()); |
| std::string callback_id; |
| ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); |
| - EXPECT_EQ("available-icons-changed", callback_id); |
| + EXPECT_EQ("get-icons-callback-id", callback_id); |
| - const base::ListValue* icon_urls = nullptr; |
| - ASSERT_TRUE(data.arg2()->GetAsList(&icon_urls)); |
| + VerifyIconList(data.arg3()); |
| +} |
| - // Expect the list of icon URLs to be a non-empty list of non-empty strings. |
| - EXPECT_FALSE(icon_urls->empty()); |
| - for (size_t i = 0; i < icon_urls->GetSize(); ++i) { |
| - std::string icon_url; |
| - EXPECT_TRUE(icon_urls->GetString(i, &icon_url)); |
| - EXPECT_FALSE(icon_url.empty()); |
| - } |
| +TEST_F(ManageProfileHandlerTest, ProfileAvatarChangedWebUIEvent) { |
| + handler()->OnProfileAvatarChanged(base::FilePath()); |
| + |
| + EXPECT_EQ(1U, web_ui()->call_data().size()); |
| + |
| + const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| + EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| + |
| + std::string event_id; |
| + ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| + EXPECT_EQ("available-icons-changed", event_id); |
| + |
| + VerifyIconList(data.arg2()); |
| } |
| } // namespace settings |