| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 TEST_F(PasswordDialogControllerTest, ShowAccountChooser) { | 83 TEST_F(PasswordDialogControllerTest, ShowAccountChooser) { |
| 84 base::HistogramTester histogram_tester; | 84 base::HistogramTester histogram_tester; |
| 85 StrictMock<MockPasswordPrompt> prompt; | 85 StrictMock<MockPasswordPrompt> prompt; |
| 86 autofill::PasswordForm local_form = GetLocalForm(); | 86 autofill::PasswordForm local_form = GetLocalForm(); |
| 87 autofill::PasswordForm local_form2 = local_form; | 87 autofill::PasswordForm local_form2 = local_form; |
| 88 local_form2.username_value = base::ASCIIToUTF16(kUsername2); | 88 local_form2.username_value = base::ASCIIToUTF16(kUsername2); |
| 89 autofill::PasswordForm idp_form = GetFederationProviderForm(); | 89 autofill::PasswordForm idp_form = GetFederationProviderForm(); |
| 90 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; | 90 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
| 91 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form))); | 91 locals.push_back(base::MakeUnique<autofill::PasswordForm>(local_form)); |
| 92 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form2))); | 92 locals.push_back(base::MakeUnique<autofill::PasswordForm>(local_form2)); |
| 93 autofill::PasswordForm* local_form_ptr = locals[0].get(); | 93 autofill::PasswordForm* local_form_ptr = locals[0].get(); |
| 94 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; | 94 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; |
| 95 federations.push_back(base::WrapUnique(new autofill::PasswordForm(idp_form))); | 95 federations.push_back(base::MakeUnique<autofill::PasswordForm>(idp_form)); |
| 96 | 96 |
| 97 EXPECT_CALL(prompt, ShowAccountChooser()); | 97 EXPECT_CALL(prompt, ShowAccountChooser()); |
| 98 controller().ShowAccountChooser(&prompt, | 98 controller().ShowAccountChooser(&prompt, |
| 99 std::move(locals), std::move(federations)); | 99 std::move(locals), std::move(federations)); |
| 100 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form), | 100 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form), |
| 101 Pointee(local_form2))); | 101 Pointee(local_form2))); |
| 102 EXPECT_THAT(controller().GetFederationsForms(), | 102 EXPECT_THAT(controller().GetFederationsForms(), |
| 103 ElementsAre(Pointee(idp_form))); | 103 ElementsAre(Pointee(idp_form))); |
| 104 EXPECT_FALSE(controller().ShouldShowSignInButton()); | 104 EXPECT_FALSE(controller().ShouldShowSignInButton()); |
| 105 | 105 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 119 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); | 119 password_manager::metrics_util::ACCOUNT_CHOOSER_CREDENTIAL_CHOSEN, 1); |
| 120 histogram_tester.ExpectTotalCount( | 120 histogram_tester.ExpectTotalCount( |
| 121 "PasswordManager.AccountChooserDialogOneAccount", 0); | 121 "PasswordManager.AccountChooserDialogOneAccount", 0); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) { | 124 TEST_F(PasswordDialogControllerTest, ShowAccountChooserAndSignIn) { |
| 125 base::HistogramTester histogram_tester; | 125 base::HistogramTester histogram_tester; |
| 126 StrictMock<MockPasswordPrompt> prompt; | 126 StrictMock<MockPasswordPrompt> prompt; |
| 127 autofill::PasswordForm local_form = GetLocalForm(); | 127 autofill::PasswordForm local_form = GetLocalForm(); |
| 128 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; | 128 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
| 129 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form))); | 129 locals.push_back(base::MakeUnique<autofill::PasswordForm>(local_form)); |
| 130 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; | 130 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; |
| 131 | 131 |
| 132 EXPECT_CALL(prompt, ShowAccountChooser()); | 132 EXPECT_CALL(prompt, ShowAccountChooser()); |
| 133 controller().ShowAccountChooser(&prompt, | 133 controller().ShowAccountChooser(&prompt, |
| 134 std::move(locals), std::move(federations)); | 134 std::move(locals), std::move(federations)); |
| 135 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); | 135 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); |
| 136 EXPECT_THAT(controller().GetFederationsForms(), testing::IsEmpty()); | 136 EXPECT_THAT(controller().GetFederationsForms(), testing::IsEmpty()); |
| 137 EXPECT_TRUE(controller().ShouldShowSignInButton()); | 137 EXPECT_TRUE(controller().ShouldShowSignInButton()); |
| 138 | 138 |
| 139 // Close the dialog. | 139 // Close the dialog. |
| 140 EXPECT_CALL(prompt, ControllerGone()); | 140 EXPECT_CALL(prompt, ControllerGone()); |
| 141 EXPECT_CALL(ui_controller_mock(), ChooseCredential( | 141 EXPECT_CALL(ui_controller_mock(), ChooseCredential( |
| 142 local_form, | 142 local_form, |
| 143 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); | 143 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)); |
| 144 controller().OnSignInClicked(); | 144 controller().OnSignInClicked(); |
| 145 histogram_tester.ExpectUniqueSample( | 145 histogram_tester.ExpectUniqueSample( |
| 146 "PasswordManager.AccountChooserDialog", | 146 "PasswordManager.AccountChooserDialog", |
| 147 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); | 147 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); |
| 148 histogram_tester.ExpectUniqueSample( | 148 histogram_tester.ExpectUniqueSample( |
| 149 "PasswordManager.AccountChooserDialogOneAccount", | 149 "PasswordManager.AccountChooserDialogOneAccount", |
| 150 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); | 150 password_manager::metrics_util::ACCOUNT_CHOOSER_SIGN_IN, 1); |
| 151 histogram_tester.ExpectTotalCount( | 151 histogram_tester.ExpectTotalCount( |
| 152 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); | 152 "PasswordManager.AccountChooserDialogMultipleAccounts", 0); |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST_F(PasswordDialogControllerTest, AccountChooserClosed) { | 155 TEST_F(PasswordDialogControllerTest, AccountChooserClosed) { |
| 156 base::HistogramTester histogram_tester; | 156 base::HistogramTester histogram_tester; |
| 157 StrictMock<MockPasswordPrompt> prompt; | 157 StrictMock<MockPasswordPrompt> prompt; |
| 158 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; | 158 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
| 159 locals.push_back( | 159 locals.push_back(base::MakeUnique<autofill::PasswordForm>(GetLocalForm())); |
| 160 base::WrapUnique(new autofill::PasswordForm(GetLocalForm()))); | |
| 161 EXPECT_CALL(prompt, ShowAccountChooser()); | 160 EXPECT_CALL(prompt, ShowAccountChooser()); |
| 162 controller().ShowAccountChooser(&prompt, std::move(locals), | 161 controller().ShowAccountChooser(&prompt, std::move(locals), |
| 163 PasswordDialogController::FormsVector()); | 162 PasswordDialogController::FormsVector()); |
| 164 | 163 |
| 165 EXPECT_CALL(ui_controller_mock(), OnDialogHidden()); | 164 EXPECT_CALL(ui_controller_mock(), OnDialogHidden()); |
| 166 controller().OnCloseDialog(); | 165 controller().OnCloseDialog(); |
| 167 histogram_tester.ExpectUniqueSample( | 166 histogram_tester.ExpectUniqueSample( |
| 168 "PasswordManager.AccountChooserDialog", | 167 "PasswordManager.AccountChooserDialog", |
| 169 password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1); | 168 password_manager::metrics_util::ACCOUNT_CHOOSER_DISMISSED, 1); |
| 170 histogram_tester.ExpectUniqueSample( | 169 histogram_tester.ExpectUniqueSample( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 "PasswordManager.AutoSigninFirstRunDialog", | 236 "PasswordManager.AutoSigninFirstRunDialog", |
| 238 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); | 237 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); |
| 239 } | 238 } |
| 240 | 239 |
| 241 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { | 240 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { |
| 242 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); | 241 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); |
| 243 controller().OnSmartLockLinkClicked(); | 242 controller().OnSmartLockLinkClicked(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 } // namespace | 245 } // namespace |
| OLD | NEW |