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

Unified Diff: chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc

Issue 2383823002: With force signin enabled, the signin dialog will be displayed after profile creation instead of br… (Closed)
Patch Set: cr Created 4 years, 3 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/signin/signin_create_profile_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc b/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc
index 3b732773c30c7821532cb433328220dc60ddc6c9..1e2805e34bd44ac64580f3dc5606702fee2d3512 100644
--- a/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc
+++ b/chrome/browser/ui/webui/signin/signin_create_profile_handler_unittest.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
+#include "chrome/browser/ui/webui/signin/signin_utils.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/browser_with_test_window_test.h"
@@ -132,6 +133,10 @@ class TestSigninCreateProfileHandler : public SigninCreateProfileHandler {
MOCK_METHOD2(OpenNewWindowForProfile,
void(Profile* profile, Profile::CreateStatus status));
+ // Mock this method so that we don't actually open the signin dialog during
+ // the test.
+ MOCK_METHOD1(OpenSigninDialogForProfile, void(Profile* profile));
+
// We don't actually need to register supervised users in the test. Mock this
// method to fake the registration part.
MOCK_METHOD4(RegisterSupervisedUser,
@@ -341,6 +346,9 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfile) {
// Expect a new browser window for the new profile to be opened.
EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _));
+ // Expect no signin dialog opened for the new profile.
+ EXPECT_CALL(*handler(), OpenSigninDialogForProfile(_)).Times(0);
+
// Create a non-supervised profile.
base::ListValue list_args;
list_args.AppendString(kTestProfileName);
@@ -371,6 +379,57 @@ TEST_F(SigninCreateProfileHandlerTest, CreateProfile) {
ASSERT_FALSE(is_supervised);
}
+TEST_F(SigninCreateProfileHandlerTest, CreateProfileWithForceSignin) {
+ g_browser_process->local_state()->SetBoolean(prefs::kForceBrowserSignin,
+ true);
+ ASSERT_TRUE(signin::IsForceSigninEnabled());
+
+ // Expect the call to create the profile.
+ EXPECT_CALL(*handler(), DoCreateProfile(_, _, _, _, _))
+ .WillOnce(Invoke(handler(),
+ &TestSigninCreateProfileHandler::RealDoCreateProfile));
+
+ // Expect no calls to register a supervised user.
+ EXPECT_CALL(*handler(), RegisterSupervisedUser(_, _, _, _)).Times(0);
+
+ // Expect no new browser window for the new profile.
+ EXPECT_CALL(*handler(), OpenNewWindowForProfile(_, _)).Times(0);
+
+ // Expect a signin dialog opened for the new profile.
+ EXPECT_CALL(*handler(), OpenSigninDialogForProfile(_)).Times(1);
+
+ base::ListValue list_args;
+ list_args.AppendString(kTestProfileName);
+ list_args.AppendString(profiles::GetDefaultAvatarIconUrl(0));
+ list_args.AppendBoolean(false); // create_shortcut
+ list_args.AppendBoolean(false); // is_supervised
+ handler()->CreateProfile(&list_args);
+
+ // Expect a JS callbacks with the new profile information.
+ EXPECT_EQ(1U, web_ui()->call_data().size());
+
+ EXPECT_EQ(kTestWebUIResponse, web_ui()->call_data()[0]->function_name());
+
+ std::string callback_name;
+ ASSERT_TRUE(web_ui()->call_data()[0]->arg1()->GetAsString(&callback_name));
+ EXPECT_EQ("create-profile-success", callback_name);
+
+ const base::DictionaryValue* profile;
+ ASSERT_TRUE(web_ui()->call_data()[0]->arg2()->GetAsDictionary(&profile));
+ std::string profile_name;
+ ASSERT_TRUE(profile->GetString("name", &profile_name));
+ EXPECT_NE("", profile_name);
+ std::string profile_path;
+ ASSERT_TRUE(profile->GetString("filePath", &profile_path));
+ EXPECT_NE("", profile_path);
+ bool is_supervised;
+ ASSERT_TRUE(profile->GetBoolean("isSupervised", &is_supervised));
+ ASSERT_FALSE(is_supervised);
+ bool show_confirmation;
+ ASSERT_TRUE(profile->GetBoolean("showConfirmation", &show_confirmation));
+ ASSERT_FALSE(show_confirmation);
+}
+
#if defined(ENABLE_SUPERVISED_USERS)
TEST_F(SigninCreateProfileHandlerTest, CreateSupervisedUser) {
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_create_profile_handler.cc ('k') | chrome/browser/ui/webui/signin/signin_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698