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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_test.cc

Issue 2090583003: Introduce password_manager::FormSaver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/manage_passwords_test.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_test.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_command_controller.h" 14 #include "chrome/browser/ui/browser_command_controller.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" 16 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/interactive_test_utils.h" 19 #include "chrome/test/base/interactive_test_utils.h"
20 #include "components/autofill/core/common/password_form.h" 20 #include "components/autofill/core/common/password_form.h"
21 #include "components/password_manager/core/browser/password_form_manager.h" 21 #include "components/password_manager/core/browser/password_form_manager.h"
22 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 22 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
23 #include "components/password_manager/core/browser/stub_form_saver.h"
23 #include "components/password_manager/core/browser/stub_password_manager_client. h" 24 #include "components/password_manager/core/browser/stub_password_manager_client. h"
24 #include "components/password_manager/core/browser/stub_password_manager_driver. h" 25 #include "components/password_manager/core/browser/stub_password_manager_driver. h"
25 26
26 ManagePasswordsTest::ManagePasswordsTest() { 27 ManagePasswordsTest::ManagePasswordsTest() {
27 } 28 }
28 29
29 ManagePasswordsTest::~ManagePasswordsTest() { 30 ManagePasswordsTest::~ManagePasswordsTest() {
30 } 31 }
31 32
32 void ManagePasswordsTest::SetUpOnMainThread() { 33 void ManagePasswordsTest::SetUpOnMainThread() {
(...skipping 22 matching lines...) Expand all
55 nullptr); 56 nullptr);
56 } 57 }
57 58
58 void ManagePasswordsTest::SetupPendingPassword() { 59 void ManagePasswordsTest::SetupPendingPassword() {
59 password_manager::StubPasswordManagerClient client; 60 password_manager::StubPasswordManagerClient client;
60 password_manager::StubLogManager log_manager; 61 password_manager::StubLogManager log_manager;
61 password_manager::StubPasswordManagerDriver driver; 62 password_manager::StubPasswordManagerDriver driver;
62 63
63 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 64 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
64 new password_manager::PasswordFormManager( 65 new password_manager::PasswordFormManager(
65 nullptr, &client, driver.AsWeakPtr(), *test_form(), false)); 66 nullptr, &client, driver.AsWeakPtr(), *test_form(), false,
67 base::WrapUnique(new password_manager::StubFormSaver)));
66 test_form_manager->SimulateFetchMatchingLoginsFromPasswordStore(); 68 test_form_manager->SimulateFetchMatchingLoginsFromPasswordStore();
67 ScopedVector<autofill::PasswordForm> best_matches; 69 ScopedVector<autofill::PasswordForm> best_matches;
68 test_form_manager->OnGetPasswordStoreResults(std::move(best_matches)); 70 test_form_manager->OnGetPasswordStoreResults(std::move(best_matches));
69 GetController()->OnPasswordSubmitted(std::move(test_form_manager)); 71 GetController()->OnPasswordSubmitted(std::move(test_form_manager));
70 } 72 }
71 73
72 void ManagePasswordsTest::SetupAutomaticPassword() { 74 void ManagePasswordsTest::SetupAutomaticPassword() {
73 password_manager::StubPasswordManagerClient client; 75 password_manager::StubPasswordManagerClient client;
74 password_manager::StubLogManager log_manager; 76 password_manager::StubLogManager log_manager;
75 password_manager::StubPasswordManagerDriver driver; 77 password_manager::StubPasswordManagerDriver driver;
76 78
77 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 79 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
78 new password_manager::PasswordFormManager( 80 new password_manager::PasswordFormManager(
79 nullptr, &client, driver.AsWeakPtr(), *test_form(), false)); 81 nullptr, &client, driver.AsWeakPtr(), *test_form(), false,
82 base::WrapUnique(new password_manager::StubFormSaver)));
80 GetController()->OnAutomaticPasswordSave(std::move(test_form_manager)); 83 GetController()->OnAutomaticPasswordSave(std::move(test_form_manager));
81 } 84 }
82 85
83 void ManagePasswordsTest::SetupAutoSignin( 86 void ManagePasswordsTest::SetupAutoSignin(
84 ScopedVector<autofill::PasswordForm> local_credentials) { 87 ScopedVector<autofill::PasswordForm> local_credentials) {
85 ASSERT_FALSE(local_credentials.empty()); 88 ASSERT_FALSE(local_credentials.empty());
86 GURL origin = local_credentials[0]->origin; 89 GURL origin = local_credentials[0]->origin;
87 GetController()->OnAutoSignin(std::move(local_credentials), origin); 90 GetController()->OnAutoSignin(std::move(local_credentials), origin);
88 } 91 }
89 92
90 std::unique_ptr<base::HistogramSamples> ManagePasswordsTest::GetSamples( 93 std::unique_ptr<base::HistogramSamples> ManagePasswordsTest::GetSamples(
91 const char* histogram) { 94 const char* histogram) {
92 // Ensure that everything has been properly recorded before pulling samples. 95 // Ensure that everything has been properly recorded before pulling samples.
93 content::RunAllPendingInMessageLoop(); 96 content::RunAllPendingInMessageLoop();
94 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram); 97 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram);
95 } 98 }
96 99
97 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() { 100 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() {
98 return PasswordsClientUIDelegateFromWebContents( 101 return PasswordsClientUIDelegateFromWebContents(
99 browser()->tab_strip_model()->GetActiveWebContents()); 102 browser()->tab_strip_model()->GetActiveWebContents());
100 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698