Chromium Code Reviews| 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 "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
| 20 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | |
| 20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 21 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 21 #include "components/user_manager/fake_user_manager.h" | |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace settings { | 24 namespace settings { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class TestProfileInfoHandler : public ProfileInfoHandler { | 28 class TestProfileInfoHandler : public ProfileInfoHandler { |
| 29 public: | 29 public: |
| 30 explicit TestProfileInfoHandler(Profile* profile) | 30 explicit TestProfileInfoHandler(Profile* profile) |
| 31 : ProfileInfoHandler(profile) {} | 31 : ProfileInfoHandler(profile) {} |
| 32 | 32 |
| 33 using ProfileInfoHandler::set_web_ui; | 33 using ProfileInfoHandler::set_web_ui; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 class ProfileInfoHandlerTest : public testing::Test { | 38 class ProfileInfoHandlerTest : public testing::Test { |
| 39 public: | 39 public: |
| 40 ProfileInfoHandlerTest() | 40 ProfileInfoHandlerTest() |
| 41 : profile_manager_(TestingBrowserProcess::GetGlobal()), | 41 : profile_manager_(TestingBrowserProcess::GetGlobal()), |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 user_manager_(new user_manager::FakeUserManager), | 43 user_manager_(new chromeos::FakeChromeUserManager), |
| 44 user_manager_enabler_(user_manager_), | 44 user_manager_enabler_(user_manager_), |
| 45 #endif | 45 #endif |
| 46 profile_(nullptr) { | 46 profile_(nullptr) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 void SetUp() override { | 49 void SetUp() override { |
| 50 ASSERT_TRUE(profile_manager_.SetUp()); | 50 ASSERT_TRUE(profile_manager_.SetUp()); |
| 51 | 51 |
| 52 #if defined(OS_CHROMEOS) | 52 #if defined(OS_CHROMEOS) |
| 53 profile_ = profile_manager_.CreateTestingProfile("fake_id@gmail.com"); | 53 profile_ = profile_manager_.CreateTestingProfile("fake_id@gmail.com"); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 80 content::TestWebUI* web_ui() { return &web_ui_; } | 80 content::TestWebUI* web_ui() { return &web_ui_; } |
| 81 Profile* profile() const { return profile_; } | 81 Profile* profile() const { return profile_; } |
| 82 TestProfileInfoHandler* handler() const { return handler_.get(); } | 82 TestProfileInfoHandler* handler() const { return handler_.get(); } |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 content::TestBrowserThreadBundle thread_bundle_; | 85 content::TestBrowserThreadBundle thread_bundle_; |
| 86 TestingProfileManager profile_manager_; | 86 TestingProfileManager profile_manager_; |
| 87 content::TestWebUI web_ui_; | 87 content::TestWebUI web_ui_; |
| 88 | 88 |
| 89 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
| 90 // |user_manager_| is destroyed by |user_manager_enabler_|. | 90 // |user_manager_| is destroyed by |user_manager_enabler_|. |
|
msw
2016/11/17 18:31:22
ditto nit: this comment is sufficient, but the |us
yoshiki
2016/11/18 15:54:15
Done.
| |
| 91 user_manager::FakeUserManager* user_manager_; | 91 chromeos::FakeChromeUserManager* user_manager_; |
| 92 chromeos::ScopedUserManagerEnabler user_manager_enabler_; | 92 chromeos::ScopedUserManagerEnabler user_manager_enabler_; |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 Profile* profile_; | 95 Profile* profile_; |
| 96 std::unique_ptr<TestProfileInfoHandler> handler_; | 96 std::unique_ptr<TestProfileInfoHandler> handler_; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 TEST_F(ProfileInfoHandlerTest, GetProfileInfo) { | 99 TEST_F(ProfileInfoHandlerTest, GetProfileInfo) { |
| 100 base::ListValue list_args; | 100 base::ListValue list_args; |
| 101 list_args.AppendString("get-profile-info-callback-id"); | 101 list_args.AppendString("get-profile-info-callback-id"); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 177 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 178 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, | 178 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, |
| 179 event_id); | 179 event_id); |
| 180 | 180 |
| 181 bool has_supervised_users = false; | 181 bool has_supervised_users = false; |
| 182 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); | 182 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); |
| 183 EXPECT_TRUE(has_supervised_users); | 183 EXPECT_TRUE(has_supervised_users); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace settings | 186 } // namespace settings |
| OLD | NEW |