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

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: rebase 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 a non-empty list of dictionaries containing non-empty strings for
53 EXPECT_FALSE(icon_urls->empty()); 53 // profile avatar icon urls and labels.
54 for (size_t i = 0; i < icon_urls->GetSize(); ++i) { 54 EXPECT_FALSE(icons->empty());
55 for (size_t i = 0; i < icons->GetSize(); ++i) {
56 const base::DictionaryValue* icon = nullptr;
57 EXPECT_TRUE(icons->GetDictionary(i, &icon));
55 std::string icon_url; 58 std::string icon_url;
56 EXPECT_TRUE(icon_urls->GetString(i, &icon_url)); 59 EXPECT_TRUE(icon->GetString("url", &icon_url));
57 EXPECT_FALSE(icon_url.empty()); 60 EXPECT_FALSE(icon_url.empty());
61 std::string icon_label;
62 EXPECT_TRUE(icon->GetString("label", &icon_label));
63 EXPECT_FALSE(icon_label.empty());
58 } 64 }
59 } 65 }
60 66
61 content::TestWebUI* web_ui() { return &web_ui_; } 67 content::TestWebUI* web_ui() { return &web_ui_; }
62 Profile* profile() const { return profile_; } 68 Profile* profile() const { return profile_; }
63 TestManageProfileHandler* handler() const { return handler_.get(); } 69 TestManageProfileHandler* handler() const { return handler_.get(); }
64 70
65 private: 71 private:
66 content::TestBrowserThreadBundle thread_bundle_; 72 content::TestBrowserThreadBundle thread_bundle_;
67 TestingProfileManager profile_manager_; 73 TestingProfileManager profile_manager_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); 117 EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
112 118
113 std::string event_id; 119 std::string event_id;
114 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); 120 ASSERT_TRUE(data.arg1()->GetAsString(&event_id));
115 EXPECT_EQ("available-icons-changed", event_id); 121 EXPECT_EQ("available-icons-changed", event_id);
116 122
117 VerifyIconList(data.arg2()); 123 VerifyIconList(data.arg2());
118 } 124 }
119 125
120 } // namespace settings 126 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698