| 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/profile_info_handler.h" | 5 #include "chrome/browser/ui/webui/settings/profile_info_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "chrome/test/base/testing_profile_manager.h" | 12 #include "chrome/test/base/testing_profile_manager.h" |
| 13 #include "components/prefs/scoped_user_pref_update.h" | 13 #include "components/prefs/scoped_user_pref_update.h" |
| 14 #include "content/public/browser/web_ui_data_source.h" | 14 #include "content/public/browser/web_ui_data_source.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "content/public/test/test_web_ui.h" | 16 #include "content/public/test/test_web_ui.h" |
| 17 #include "net/base/data_url.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 #include "ui/gfx/codec/png_codec.h" |
| 21 #include "url/gurl.h" |
| 18 | 22 |
| 19 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 20 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 24 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 21 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 25 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 22 #endif | 26 #endif |
| 23 | 27 |
| 24 namespace settings { | 28 namespace settings { |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 std::string name; | 75 std::string name; |
| 72 std::string icon_url; | 76 std::string icon_url; |
| 73 ASSERT_TRUE(response->GetString("name", &name)); | 77 ASSERT_TRUE(response->GetString("name", &name)); |
| 74 ASSERT_TRUE(response->GetString("iconUrl", &icon_url)); | 78 ASSERT_TRUE(response->GetString("iconUrl", &icon_url)); |
| 75 | 79 |
| 76 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 77 EXPECT_EQ(fake_id, name); | 81 EXPECT_EQ(fake_id, name); |
| 78 EXPECT_FALSE(icon_url.empty()); | 82 EXPECT_FALSE(icon_url.empty()); |
| 79 #else | 83 #else |
| 80 EXPECT_EQ("Profile 1", name); | 84 EXPECT_EQ("Profile 1", name); |
| 81 EXPECT_EQ("chrome://theme/IDR_PROFILE_AVATAR_0", icon_url); | 85 |
| 86 std::string mime, charset, data; |
| 87 EXPECT_TRUE(net::DataURL::Parse(GURL(icon_url), &mime, &charset, &data)); |
| 88 |
| 89 EXPECT_EQ("image/png", mime); |
| 90 SkBitmap bitmap; |
| 91 EXPECT_TRUE(gfx::PNGCodec::Decode( |
| 92 reinterpret_cast<const unsigned char*>(data.data()), data.size(), |
| 93 &bitmap)); |
| 82 #endif | 94 #endif |
| 83 } | 95 } |
| 84 | 96 |
| 85 content::TestWebUI* web_ui() { return &web_ui_; } | 97 content::TestWebUI* web_ui() { return &web_ui_; } |
| 86 Profile* profile() const { return profile_; } | 98 Profile* profile() const { return profile_; } |
| 87 TestProfileInfoHandler* handler() const { return handler_.get(); } | 99 TestProfileInfoHandler* handler() const { return handler_.get(); } |
| 88 | 100 |
| 89 private: | 101 private: |
| 90 content::TestBrowserThreadBundle thread_bundle_; | 102 content::TestBrowserThreadBundle thread_bundle_; |
| 91 TestingProfileManager profile_manager_; | 103 TestingProfileManager profile_manager_; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 192 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 181 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, | 193 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, |
| 182 event_id); | 194 event_id); |
| 183 | 195 |
| 184 bool has_supervised_users = false; | 196 bool has_supervised_users = false; |
| 185 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); | 197 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); |
| 186 EXPECT_TRUE(has_supervised_users); | 198 EXPECT_TRUE(has_supervised_users); |
| 187 } | 199 } |
| 188 | 200 |
| 189 } // namespace settings | 201 } // namespace settings |
| OLD | NEW |