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

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

Issue 2068713003: Refactors profile avatar selector into a Polymer element to use in md-settings & md-user-manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 years, 6 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 28 matching lines...) Expand all
39 ASSERT_TRUE(profile_manager_.SetUp()); 39 ASSERT_TRUE(profile_manager_.SetUp());
40 profile_ = profile_manager_.CreateTestingProfile("Profile 1"); 40 profile_ = profile_manager_.CreateTestingProfile("Profile 1");
41 41
42 handler_.reset(new TestManageProfileHandler(profile_)); 42 handler_.reset(new TestManageProfileHandler(profile_));
43 handler_->set_web_ui(&web_ui_); 43 handler_->set_web_ui(&web_ui_);
44 handler()->AllowJavascript(); 44 handler()->AllowJavascript();
45 web_ui()->ClearTrackedCalls(); 45 web_ui()->ClearTrackedCalls();
46 } 46 }
47 47
48 void VerifyIconList(const base::Value* value) { 48 void VerifyIconList(const base::Value* value) {
49 const base::ListValue* icon_urls = nullptr; 49 const base::ListValue* icons = nullptr;
50 ASSERT_TRUE(value->GetAsList(&icon_urls)); 50 ASSERT_TRUE(value->GetAsList(&icons));
51 51
52 // Expect the list of icon URLs to be a non-empty list of non-empty strings. 52 // Expect the list of icon URLs to be a non-empty list of non-empty strings.
michaelpg 2016/06/20 17:01:10 update/remove comment
Moe 2016/06/20 18:48:56 Done.
53 EXPECT_FALSE(icon_urls->empty()); 53 EXPECT_FALSE(icons->empty());
54 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { 54 for (size_t i = 0; i < icons->GetSize(); ++i) {
55 const base::DictionaryValue* icon = nullptr;
56 EXPECT_TRUE(icons->GetDictionary(i, &icon));
55 std::string icon_url; 57 std::string icon_url;
56 EXPECT_TRUE(icon_urls->GetString(i, &icon_url)); 58 EXPECT_TRUE(icon->GetString("url", &icon_url));
57 EXPECT_FALSE(icon_url.empty()); 59 EXPECT_FALSE(icon_url.empty());
60 std::string icon_label;
61 EXPECT_TRUE(icon->GetString("label", &icon_label));
62 EXPECT_FALSE(icon_label.empty());
58 } 63 }
59 } 64 }
60 65
61 content::TestWebUI* web_ui() { return &web_ui_; } 66 content::TestWebUI* web_ui() { return &web_ui_; }
62 Profile* profile() const { return profile_; } 67 Profile* profile() const { return profile_; }
63 TestManageProfileHandler* handler() const { return handler_.get(); } 68 TestManageProfileHandler* handler() const { return handler_.get(); }
64 69
65 private: 70 private:
66 content::TestBrowserThreadBundle thread_bundle_; 71 content::TestBrowserThreadBundle thread_bundle_;
67 TestingProfileManager profile_manager_; 72 TestingProfileManager profile_manager_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); 116 EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
112 117
113 std::string event_id; 118 std::string event_id;
114 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); 119 ASSERT_TRUE(data.arg1()->GetAsString(&event_id));
115 EXPECT_EQ("available-icons-changed", event_id); 120 EXPECT_EQ("available-icons-changed", event_id);
116 121
117 VerifyIconList(data.arg2()); 122 VerifyIconList(data.arg2());
118 } 123 }
119 124
120 } // namespace settings 125 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698