Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc

Issue 1988463002: MD Settings: Convert C++ handlers to be JavaScript-lifecycle aware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698