| 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/settings_manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
| 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_manager.h" | 10 #include "chrome/test/base/testing_profile_manager.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 content::TestBrowserThreadBundle thread_bundle_; | 66 content::TestBrowserThreadBundle thread_bundle_; |
| 67 TestingProfileManager profile_manager_; | 67 TestingProfileManager profile_manager_; |
| 68 content::TestWebUI web_ui_; | 68 content::TestWebUI web_ui_; |
| 69 | 69 |
| 70 Profile* profile_; | 70 Profile* profile_; |
| 71 std::unique_ptr<TestManageProfileHandler> handler_; | 71 std::unique_ptr<TestManageProfileHandler> handler_; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 TEST_F(ManageProfileHandlerTest, HandleSetProfileIconAndName) { | 74 TEST_F(ManageProfileHandlerTest, HandleSetProfileIconAndName) { |
| 75 base::ListValue list_args; | 75 base::ListValue list_args; |
| 76 list_args.Append( | 76 list_args.AppendString("chrome://theme/IDR_PROFILE_AVATAR_15"); |
| 77 new base::StringValue("chrome://theme/IDR_PROFILE_AVATAR_15")); | 77 list_args.AppendString("New Profile Name"); |
| 78 list_args.Append(new base::StringValue("New Profile Name")); | |
| 79 handler()->HandleSetProfileIconAndName(&list_args); | 78 handler()->HandleSetProfileIconAndName(&list_args); |
| 80 | 79 |
| 81 PrefService* pref_service = profile()->GetPrefs(); | 80 PrefService* pref_service = profile()->GetPrefs(); |
| 82 | 81 |
| 83 EXPECT_EQ(15, pref_service->GetInteger(prefs::kProfileAvatarIndex)); | 82 EXPECT_EQ(15, pref_service->GetInteger(prefs::kProfileAvatarIndex)); |
| 84 EXPECT_FALSE(pref_service->GetBoolean(prefs::kProfileUsingDefaultAvatar)); | 83 EXPECT_FALSE(pref_service->GetBoolean(prefs::kProfileUsingDefaultAvatar)); |
| 85 EXPECT_FALSE(pref_service->GetBoolean(prefs::kProfileUsingGAIAAvatar)); | 84 EXPECT_FALSE(pref_service->GetBoolean(prefs::kProfileUsingGAIAAvatar)); |
| 86 EXPECT_EQ("New Profile Name", pref_service->GetString(prefs::kProfileName)); | 85 EXPECT_EQ("New Profile Name", pref_service->GetString(prefs::kProfileName)); |
| 87 } | 86 } |
| 88 | 87 |
| 89 TEST_F(ManageProfileHandlerTest, HandleGetAvailableIcons) { | 88 TEST_F(ManageProfileHandlerTest, HandleGetAvailableIcons) { |
| 90 base::ListValue list_args; | 89 base::ListValue list_args; |
| 91 list_args.Append(new base::StringValue("get-icons-callback-id")); | 90 list_args.AppendString("get-icons-callback-id"); |
| 92 handler()->HandleGetAvailableIcons(&list_args); | 91 handler()->HandleGetAvailableIcons(&list_args); |
| 93 | 92 |
| 94 EXPECT_EQ(1U, web_ui()->call_data().size()); | 93 EXPECT_EQ(1U, web_ui()->call_data().size()); |
| 95 | 94 |
| 96 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); | 95 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| 97 EXPECT_EQ("cr.webUIResponse", data.function_name()); | 96 EXPECT_EQ("cr.webUIResponse", data.function_name()); |
| 98 | 97 |
| 99 std::string callback_id; | 98 std::string callback_id; |
| 100 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); | 99 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); |
| 101 EXPECT_EQ("get-icons-callback-id", callback_id); | 100 EXPECT_EQ("get-icons-callback-id", callback_id); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 112 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); | 111 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 113 | 112 |
| 114 std::string event_id; | 113 std::string event_id; |
| 115 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 114 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 116 EXPECT_EQ("available-icons-changed", event_id); | 115 EXPECT_EQ("available-icons-changed", event_id); |
| 117 | 116 |
| 118 VerifyIconList(data.arg2()); | 117 VerifyIconList(data.arg2()); |
| 119 } | 118 } |
| 120 | 119 |
| 121 } // namespace settings | 120 } // namespace settings |
| OLD | NEW |