| 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 "base/memory/ptr_util.h" |
| 10 #include "base/values.h" |
| 9 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" | 12 #include "chrome/test/base/testing_browser_process.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 12 #include "chrome/test/base/testing_profile_manager.h" | 14 #include "chrome/test/base/testing_profile_manager.h" |
| 13 #include "components/prefs/scoped_user_pref_update.h" | 15 #include "components/prefs/scoped_user_pref_update.h" |
| 14 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 17 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "content/public/test/test_web_ui.h" | 18 #include "content/public/test/test_web_ui.h" |
| 17 #include "net/base/data_url.h" | 19 #include "net/base/data_url.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 175 } |
| 174 | 176 |
| 175 TEST_F(ProfileInfoHandlerTest, PushProfileManagesSupervisedUsers) { | 177 TEST_F(ProfileInfoHandlerTest, PushProfileManagesSupervisedUsers) { |
| 176 handler()->AllowJavascript(); | 178 handler()->AllowJavascript(); |
| 177 | 179 |
| 178 // The handler is notified of the change after |update| is destroyed. | 180 // The handler is notified of the change after |update| is destroyed. |
| 179 std::unique_ptr<DictionaryPrefUpdate> update( | 181 std::unique_ptr<DictionaryPrefUpdate> update( |
| 180 new DictionaryPrefUpdate(profile()->GetPrefs(), prefs::kSupervisedUsers)); | 182 new DictionaryPrefUpdate(profile()->GetPrefs(), prefs::kSupervisedUsers)); |
| 181 base::DictionaryValue* dict = update->Get(); | 183 base::DictionaryValue* dict = update->Get(); |
| 182 dict->SetWithoutPathExpansion("supervised-user-id", | 184 dict->SetWithoutPathExpansion("supervised-user-id", |
| 183 new base::DictionaryValue); | 185 base::MakeUnique<base::DictionaryValue>()); |
| 184 update.reset(); | 186 update.reset(); |
| 185 | 187 |
| 186 EXPECT_EQ(1U, web_ui()->call_data().size()); | 188 EXPECT_EQ(1U, web_ui()->call_data().size()); |
| 187 | 189 |
| 188 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); | 190 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); |
| 189 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); | 191 EXPECT_EQ("cr.webUIListenerCallback", data.function_name()); |
| 190 | 192 |
| 191 std::string event_id; | 193 std::string event_id; |
| 192 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); | 194 ASSERT_TRUE(data.arg1()->GetAsString(&event_id)); |
| 193 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, | 195 EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName, |
| 194 event_id); | 196 event_id); |
| 195 | 197 |
| 196 bool has_supervised_users = false; | 198 bool has_supervised_users = false; |
| 197 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); | 199 ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users)); |
| 198 EXPECT_TRUE(has_supervised_users); | 200 EXPECT_TRUE(has_supervised_users); |
| 199 } | 201 } |
| 200 | 202 |
| 201 } // namespace settings | 203 } // namespace settings |
| OLD | NEW |