| 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 22 matching lines...) Expand all Loading... |
| 33 ManageProfileHandlerTest() | 33 ManageProfileHandlerTest() |
| 34 : profile_manager_(TestingBrowserProcess::GetGlobal()), | 34 : profile_manager_(TestingBrowserProcess::GetGlobal()), |
| 35 profile_(nullptr) {} | 35 profile_(nullptr) {} |
| 36 | 36 |
| 37 void SetUp() override { | 37 void SetUp() override { |
| 38 ASSERT_TRUE(profile_manager_.SetUp()); | 38 ASSERT_TRUE(profile_manager_.SetUp()); |
| 39 profile_ = profile_manager_.CreateTestingProfile("Profile 1"); | 39 profile_ = profile_manager_.CreateTestingProfile("Profile 1"); |
| 40 | 40 |
| 41 handler_.reset(new TestManageProfileHandler(profile_)); | 41 handler_.reset(new TestManageProfileHandler(profile_)); |
| 42 handler_->set_web_ui(&web_ui_); | 42 handler_->set_web_ui(&web_ui_); |
| 43 |
| 44 // Do initial fetch of available icons to AllowJavascript. |
| 45 base::ListValue list_args; |
| 46 list_args.Append(new base::StringValue("get-icons-callback-id")); |
| 47 handler()->HandleGetAvailableIcons(&list_args); |
| 48 |
| 49 web_ui()->ClearTrackedCalls(); |
| 43 } | 50 } |
| 44 | 51 |
| 45 void VerifyIconList(const base::Value* value) { | 52 void VerifyIconList(const base::Value* value) { |
| 46 const base::ListValue* icon_urls = nullptr; | 53 const base::ListValue* icon_urls = nullptr; |
| 47 ASSERT_TRUE(value->GetAsList(&icon_urls)); | 54 ASSERT_TRUE(value->GetAsList(&icon_urls)); |
| 48 | 55 |
| 49 // Expect the list of icon URLs to be a non-empty list of non-empty strings. | 56 // Expect the list of icon URLs to be a non-empty list of non-empty strings. |
| 50 EXPECT_FALSE(icon_urls->empty()); | 57 EXPECT_FALSE(icon_urls->empty()); |
| 51 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { | 58 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { |
| 52 std::string icon_url; | 59 std::string icon_url; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); | 116 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 110 | 117 |
| 111 std::string event_id; | 118 std::string event_id; |
| 112 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 119 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 113 EXPECT_EQ("available-icons-changed", event_id); | 120 EXPECT_EQ("available-icons-changed", event_id); |
| 114 | 121 |
| 115 VerifyIconList(data.arg2()); | 122 VerifyIconList(data.arg2()); |
| 116 } | 123 } |
| 117 | 124 |
| 118 } // namespace settings | 125 } // namespace settings |
| OLD | NEW |