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 <utility> | 8 #include <utility> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
13 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" | 14 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" |
14 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" | 15 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "components/autofill/core/common/password_form.h" | 17 #include "components/autofill/core/common/password_form.h" |
17 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 18 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
18 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 19 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
19 #include "components/password_manager/core/common/password_manager_pref_names.h" | 20 #include "components/password_manager/core/common/password_manager_pref_names.h" |
20 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return *ui_controller_mock_; | 73 return *ui_controller_mock_; |
73 } | 74 } |
74 | 75 |
75 PasswordDialogControllerImpl& controller() { return controller_; } | 76 PasswordDialogControllerImpl& controller() { return controller_; } |
76 | 77 |
77 PrefService* prefs() { return profile_.GetPrefs(); } | 78 PrefService* prefs() { return profile_.GetPrefs(); } |
78 | 79 |
79 private: | 80 private: |
80 content::TestBrowserThreadBundle thread_bundle_; | 81 content::TestBrowserThreadBundle thread_bundle_; |
81 TestingProfile profile_; | 82 TestingProfile profile_; |
82 scoped_ptr<content::WebContents> test_web_contents_; | 83 std::unique_ptr<content::WebContents> test_web_contents_; |
83 // Owned by |test_web_contents_|. | 84 // Owned by |test_web_contents_|. |
84 ManagePasswordsUIControllerMock* ui_controller_mock_; | 85 ManagePasswordsUIControllerMock* ui_controller_mock_; |
85 PasswordDialogControllerImpl controller_; | 86 PasswordDialogControllerImpl controller_; |
86 }; | 87 }; |
87 | 88 |
88 TEST_F(PasswordDialogControllerTest, ShowAccountChooser) { | 89 TEST_F(PasswordDialogControllerTest, ShowAccountChooser) { |
89 base::HistogramTester histogram_tester; | 90 base::HistogramTester histogram_tester; |
90 StrictMock<MockPasswordPrompt> prompt; | 91 StrictMock<MockPasswordPrompt> prompt; |
91 autofill::PasswordForm local_form = GetLocalForm(); | 92 autofill::PasswordForm local_form = GetLocalForm(); |
92 autofill::PasswordForm idp_form = GetFederationProviderForm(); | 93 autofill::PasswordForm idp_form = GetFederationProviderForm(); |
93 std::vector<scoped_ptr<autofill::PasswordForm>> locals; | 94 std::vector<std::unique_ptr<autofill::PasswordForm>> locals; |
94 locals.push_back(make_scoped_ptr(new autofill::PasswordForm(local_form))); | 95 locals.push_back(base::WrapUnique(new autofill::PasswordForm(local_form))); |
95 autofill::PasswordForm* local_form_ptr = locals[0].get(); | 96 autofill::PasswordForm* local_form_ptr = locals[0].get(); |
96 std::vector<scoped_ptr<autofill::PasswordForm>> federations; | 97 std::vector<std::unique_ptr<autofill::PasswordForm>> federations; |
97 federations.push_back(make_scoped_ptr(new autofill::PasswordForm(idp_form))); | 98 federations.push_back(base::WrapUnique(new autofill::PasswordForm(idp_form))); |
98 | 99 |
99 EXPECT_CALL(prompt, ShowAccountChooser()); | 100 EXPECT_CALL(prompt, ShowAccountChooser()); |
100 controller().ShowAccountChooser(&prompt, | 101 controller().ShowAccountChooser(&prompt, |
101 std::move(locals), std::move(federations)); | 102 std::move(locals), std::move(federations)); |
102 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); | 103 EXPECT_THAT(controller().GetLocalForms(), ElementsAre(Pointee(local_form))); |
103 EXPECT_THAT(controller().GetFederationsForms(), | 104 EXPECT_THAT(controller().GetFederationsForms(), |
104 ElementsAre(Pointee(idp_form))); | 105 ElementsAre(Pointee(idp_form))); |
105 | 106 |
106 // Close the dialog. | 107 // Close the dialog. |
107 EXPECT_CALL(prompt, ControllerGone()); | 108 EXPECT_CALL(prompt, ControllerGone()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 "PasswordManager.AutoSigninFirstRunDialog", | 195 "PasswordManager.AutoSigninFirstRunDialog", |
195 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); | 196 password_manager::metrics_util::AUTO_SIGNIN_TURN_OFF, 1); |
196 } | 197 } |
197 | 198 |
198 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { | 199 TEST_F(PasswordDialogControllerTest, OnBrandLinkClicked) { |
199 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); | 200 EXPECT_CALL(ui_controller_mock(), NavigateToSmartLockHelpPage()); |
200 controller().OnSmartLockLinkClicked(); | 201 controller().OnSmartLockLinkClicked(); |
201 } | 202 } |
202 | 203 |
203 } // namespace | 204 } // namespace |
OLD | NEW |