| 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/passwords/password_dialog_controller_impl.h" | 5 #include "chrome/browser/ui/passwords/password_dialog_controller_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 EXPECT_CALL(prompt, ControllerGone()); | 114 EXPECT_CALL(prompt, ControllerGone()); |
| 115 EXPECT_CALL(ui_controller_mock(), ChooseCredential( | 115 EXPECT_CALL(ui_controller_mock(), ChooseCredential( |
| 116 local_form, | 116 local_form, |
| 117 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); | 117 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); |
| 118 controller().OnChooseCredentials( | 118 controller().OnChooseCredentials( |
| 119 *local_form_ptr, | 119 *local_form_ptr, |
| 120 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); | 120 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); |
| 121 histogram_tester.ExpectUniqueSample( | 121 histogram_tester.ExpectUniqueSample( |
| 122 "PasswordManager.AccountChooserDialog", | 122 "PasswordManager.AccountChooserDialog", |
| 123 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); | 123 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); |
| 124 histogram_tester.ExpectUniqueSample( |
| 125 "PasswordManager.AccountChooserDialogMultipleAccounts", |
| 126 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); |
| 127 histogram_tester.ExpectTotalCount( |
| 128 "PasswordManager.AccountChooserDialogOneAccount", 0); |
| 124 } | 129 } |
| 125 | 130 |
| 126 TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) { | 131 TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) { |
| 127 base::HistogramTester histogram_tester; | 132 base::HistogramTester histogram_tester; |
| 128 StrictMock<MockPasswordPrompt> prompt; | 133 StrictMock<MockPasswordPrompt> prompt; |
| 129 autofill::PasswordForm local_form = GetLocalForm(); | 134 autofill::PasswordForm local_form = GetLocalForm(); |
| 130 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; | 135 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
| 131 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form))); | 136 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form))); |
| 132 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; | 137 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; |
| 133 | 138 |
| 134 EXPECT_CALL(prompt, ShowAccountChooser()); | 139 EXPECT_CALL(prompt, ShowAccountChooser()); |
| 135 controller().ShowAccountChooser(&prompt, | 140 controller().ShowAccountChooser(&prompt, |
| 136 std::move(locals), std::move(federations)); | 141 std::move(locals), std::move(federations)); |
| 137 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); | 142 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); |
| 138 EXPECT_THAT(controller().GetFederationsForms(), testing::IsEmpty()); | 143 EXPECT_THAT(controller().GetFederationsForms(), testing::IsEmpty()); |
| 139 EXPECT_TRUE(controller().ShouldShowSignInButton()); | 144 EXPECT_TRUE(controller().ShouldShowSignInButton()); |
| 140 | 145 |
| 141 // Close the dialog. | 146 // Close the dialog. |
| 142 EXPECT_CALL(prompt, ControllerGone()); | 147 EXPECT_CALL(prompt, ControllerGone()); |
| 143 EXPECT_CALL(ui_controller_mock(), ChooseCredential( | 148 EXPECT_CALL(ui_controller_mock(), ChooseCredential( |
| 144 local_form, | 149 local_form, |
| 145 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); | 150 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); |
| 146 controller().OnSignInClicked(); | 151 controller().OnSignInClicked(); |
| 147 histogram_tester.ExpectUniqueSample( | 152 histogram_tester.ExpectUniqueSample( |
| 148 "PasswordManager.AccountChooserDialog", | 153 "PasswordManager.AccountChooserDialog", |
| 149 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); | 154 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); |
| 155 histogram_tester.ExpectUniqueSample( |
| 156 "PasswordManager.AccountChooserDialogOneAccount", |
| 157 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); |
| 158 histogram_tester.ExpectTotalCount( |
| 159 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); |
| 150 } | 160 } |
| 151 | 161 |
| 152 TEST_F(PasswordDialogControllerTest, AccountChooserClosed) { | 162 TEST_F(PasswordDialogControllerTest, AccountChooserClosed) { |
| 153 base::HistogramTester histogram_tester; | 163 base::HistogramTester histogram_tester; |
| 154 StrictMock<MockPasswordPrompt> prompt; | 164 StrictMock<MockPasswordPrompt> prompt; |
| 165 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
| 166 locals.push_back( |
| 167 base::WrapUnique(new autofill::PasswordForm(GetLocalForm()))); |
| 155 EXPECT_CALL(prompt, ShowAccountChooser()); | 168 EXPECT_CALL(prompt, ShowAccountChooser()); |
| 156 controller().ShowAccountChooser(&prompt, | 169 controller().ShowAccountChooser(&prompt, std::move(locals), |
| 157 PasswordDialogController::FormsVector(), | |
| 158 PasswordDialogController::FormsVector()); | 170 PasswordDialogController::FormsVector()); |
| 159 | 171 |
| 160 EXPECT_CALL(ui_controller_mock(), OnDialogHidden()); | 172 EXPECT_CALL(ui_controller_mock(), OnDialogHidden()); |
| 161 controller().OnCloseDialog(); | 173 controller().OnCloseDialog(); |
| 162 histogram_tester.ExpectUniqueSample( | 174 histogram_tester.ExpectUniqueSample( |
| 163 "PasswordManager.AccountChooserDialog", | 175 "PasswordManager.AccountChooserDialog", |
| 164 password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1); | 176 password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1); |
| 177 histogram_tester.ExpectUniqueSample( |
| 178 "PasswordManager.AccountChooserDialogOneAccount", |
| 179 password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1); |
| 180 histogram_tester.ExpectTotalCount( |
| 181 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); |
| 165 } | 182 } |
| 166 | 183 |
| 167 TEST_F(PasswordDialogControllerTest, AutoSigninPromo) { | 184 TEST_F(PasswordDialogControllerTest, AutoSigninPromo) { |
| 168 base::HistogramTester histogram_tester; | 185 base::HistogramTester histogram_tester; |
| 169 StrictMock<MockPasswordPrompt> prompt; | 186 StrictMock<MockPasswordPrompt> prompt; |
| 170 EXPECT_CALL(prompt, ShowAutoSigninPrompt()); | 187 EXPECT_CALL(prompt, ShowAutoSigninPrompt()); |
| 171 controller().ShowAutosigninPrompt(&prompt); | 188 controller().ShowAutosigninPrompt(&prompt); |
| 172 | 189 |
| 173 prefs()->SetBoolean( | 190 prefs()->SetBoolean( |
| 174 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); | 191 password_manager::prefs::kWasAutoSignInFirstRunExperienceShown, false); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 "PasswordManager.AutoSigninFirstRunDialog", | 244 "PasswordManager.AutoSigninFirstRunDialog", |
| 228 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); | 245 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); |
| 229 } | 246 } |
| 230 | 247 |
| 231 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { | 248 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { |
| 232 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); | 249 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); |
| 233 controller().OnSmartLockLinkClicked(); | 250 controller().OnSmartLockLinkClicked(); |
| 234 } | 251 } |
| 235 | 252 |
| 236 } // namespace | 253 } // namespace |
| OLD | NEW |