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

Unified Diff: chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc

Issue 2062503002: Settings People Revamp: Add 'Manage Supervised Users' row (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc b/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc
index c90a10674d0c38b4686dc6936ec646bfeccac19a..66ccd066ff84e73f0f77da3d6913deef52485265 100644
--- a/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc
+++ b/chrome/browser/ui/webui/settings/profile_info_handler_unittest.cc
@@ -57,7 +57,7 @@ class ProfileInfoHandlerTest : public testing::Test {
handler_->set_web_ui(&web_ui_);
}
- void VerifyResponse(const base::Value* call_argument) {
+ void VerifyProfileInfo(const base::Value* call_argument) {
const base::DictionaryValue* response = nullptr;
ASSERT_TRUE(call_argument->GetAsDictionary(&response));
@@ -112,17 +112,15 @@ TEST_F(ProfileInfoHandlerTest, GetProfileInfo) {
ASSERT_TRUE(data.arg2()->GetAsBoolean(&success));
EXPECT_TRUE(success);
- VerifyResponse(data.arg3());
+ VerifyProfileInfo(data.arg3());
}
TEST_F(ProfileInfoHandlerTest, PushProfileInfo) {
- base::ListValue list_args;
- list_args.AppendString("get-profile-info-callback-id");
- handler()->HandleGetProfileInfo(&list_args);
+ handler()->AllowJavascript();
handler()->OnProfileAvatarChanged(base::FilePath());
- EXPECT_EQ(2U, web_ui()->call_data().size());
+ EXPECT_EQ(1U, web_ui()->call_data().size());
const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
@@ -131,7 +129,50 @@ TEST_F(ProfileInfoHandlerTest, PushProfileInfo) {
ASSERT_TRUE(data.arg1()->GetAsString(&event_id));
EXPECT_EQ(ProfileInfoHandler::kProfileInfoChangedEventName, event_id);
- VerifyResponse(data.arg2());
+ VerifyProfileInfo(data.arg2());
+}
+
+TEST_F(ProfileInfoHandlerTest, GetProfileManagesSupervisedUsers) {
+ base::ListValue list_args;
+ list_args.AppendString("get-profile-manages-supervised-users-callback-id");
+ handler()->HandleGetProfileManagesSupervisedUsers(&list_args);
+
+ EXPECT_EQ(1U, web_ui()->call_data().size());
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIResponse", data.function_name());
+
+ std::string callback_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
+ EXPECT_EQ("get-profile-manages-supervised-users-callback-id", callback_id);
+
+ bool success = false;
+ ASSERT_TRUE(data.arg2()->GetAsBoolean(&success));
+ EXPECT_TRUE(success);
+
+ bool has_supervised_users = false;
+ ASSERT_TRUE(data.arg3()->GetAsBoolean(&has_supervised_users));
+ EXPECT_FALSE(has_supervised_users);
+}
+
+TEST_F(ProfileInfoHandlerTest, PushProfileManagesSupervisedUsers) {
+ handler()->AllowJavascript();
+
+ handler()->PushProfileManagesSupervisedUsersStatus();
+
+ EXPECT_EQ(1U, web_ui()->call_data().size());
+
+ const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
+ EXPECT_EQ("cr.webUIListenerCallback", data.function_name());
+
+ std::string event_id;
+ ASSERT_TRUE(data.arg1()->GetAsString(&event_id));
+ EXPECT_EQ(ProfileInfoHandler::kProfileManagesSupervisedUsersChangedEventName,
+ event_id);
+
+ bool has_supervised_users = false;
+ ASSERT_TRUE(data.arg2()->GetAsBoolean(&has_supervised_users));
+ EXPECT_FALSE(has_supervised_users);
hcarmona 2016/06/10 22:58:08 Is it possible to add a test where |has_supervised
tommycli 2016/06/10 23:28:45 Done. Yes, I was able to enhance the test using th
}
} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698