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

Unified Diff: chrome/browser/ui/passwords/password_dialog_controller_impl_unittest.cc

Issue 1992633003: Add "Sign In" button to the account chooser on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/passwords/password_dialog_controller_impl_unittest.cc
diff --git a/chrome/browser/ui/passwords/password_dialog_controller_impl_unittest.cc b/chrome/browser/ui/passwords/password_dialog_controller_impl_unittest.cc
index 6a52b289a2f39c5d481c634f2c1006db9acb7b5e..5599335821f22eda382268ef5d3cb2fd39a01a51 100644
--- a/chrome/browser/ui/passwords/password_dialog_controller_impl_unittest.cc
+++ b/chrome/browser/ui/passwords/password_dialog_controller_impl_unittest.cc
@@ -31,6 +31,7 @@ using testing::Pointee;
using testing::StrictMock;
const char kUsername[] = "user1";
+const char kUsername2[] = "user2";
class MockPasswordPrompt : public AccountChooserPrompt,
public AutoSigninFirstRunPrompt {
@@ -90,9 +91,12 @@ TEST_F(PasswordDialogControllerTest, ShowAccountChooser) {
base::HistogramTester histogram_tester;
StrictMock<MockPasswordPrompt> prompt;
autofill::PasswordForm local_form = GetLocalForm();
+ autofill::PasswordForm local_form2 = local_form;
+ local_form2.username_value = base::ASCIIToUTF16(kUsername2);
autofill::PasswordForm idp_form = GetFederationProviderForm();
std::vector<std::unique_ptr<autofill::PasswordForm>> locals;
locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form)));
+ locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form2)));
autofill::PasswordForm* local_form_ptr = locals[0].get();
std::vector<std::unique_ptr<autofill::PasswordForm>> federations;
federations.push_back(base::WrapUnique(new autofill::PasswordForm(idp_form)));
@@ -100,9 +104,11 @@ TEST_F(PasswordDialogControllerTest, ShowAccountChooser) {
EXPECT_CALL(prompt, ShowAccountChooser());
controller().ShowAccountChooser(&prompt,
std::move(locals), std::move(federations));
- EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form)));
+ EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form),
+ Pointee(local_form2)));
EXPECT_THAT(controller().GetFederationsForms(),
ElementsAre(Pointee(idp_form)));
+ EXPECT_FALSE(controller().ShouldShowSignInButton());
// Close the dialog.
EXPECT_CALL(prompt, ControllerGone());
@@ -117,6 +123,32 @@ TEST_F(PasswordDialogControllerTest, ShowAccountChooser) {
password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1);
}
+TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) {
+ base::HistogramTester histogram_tester;
+ StrictMock<MockPasswordPrompt> prompt;
+ autofill::PasswordForm local_form = GetLocalForm();
+ std::vector<std::unique_ptr<autofill::PasswordForm>> locals;
+ locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form)));
+ std::vector<std::unique_ptr<autofill::PasswordForm>> federations;
+
+ EXPECT_CALL(prompt, ShowAccountChooser());
+ controller().ShowAccountChooser(&prompt,
+ std::move(locals), std::move(federations));
+ EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form)));
+ EXPECT_THAT(controller().GetFederationsForms(), testing::IsEmpty());
+ EXPECT_TRUE(controller().ShouldShowSignInButton());
+
+ // Close the dialog.
+ EXPECT_CALL(prompt, ControllerGone());
+ EXPECT_CALL(ui_controller_mock(), ChooseCredential(
+ local_form,
+ password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD));
+ controller().OnSignInClicked();
+ histogram_tester.ExpectUniqueSample(
+ "PasswordManager.AccountChooserDialog",
+ password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1);
+}
+
TEST_F(PasswordDialogControllerTest, AccountChooserClosed) {
base::HistogramTester histogram_tester;
StrictMock<MockPasswordPrompt> prompt;

Powered by Google App Engine
This is Rietveld 408576698