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

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

Issue 2263933002: Make FormFetcher a PasswordStoreConsumer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@621355_form_fetcher
Patch Set: Also operator= is now default Created 4 years 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 <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_command_controller.h" 16 #include "chrome/browser/ui/browser_command_controller.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" 18 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/test/base/in_process_browser_test.h" 20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/interactive_test_utils.h" 21 #include "chrome/test/base/interactive_test_utils.h"
22 #include "components/autofill/core/common/password_form.h" 22 #include "components/autofill/core/common/password_form.h"
23 #include "components/password_manager/core/browser/password_form_manager.h" 23 #include "components/password_manager/core/browser/password_form_manager.h"
24 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 24 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
25 #include "components/password_manager/core/browser/stub_form_saver.h" 25 #include "components/password_manager/core/browser/stub_form_saver.h"
26 #include "components/password_manager/core/browser/stub_password_manager_client. h"
27 #include "components/password_manager/core/browser/stub_password_manager_driver. h"
28 26
29 ManagePasswordsTest::ManagePasswordsTest() { 27 ManagePasswordsTest::ManagePasswordsTest() {
28 fetcher_.Fetch();
30 } 29 }
31 30
32 ManagePasswordsTest::~ManagePasswordsTest() { 31 ManagePasswordsTest::~ManagePasswordsTest() {
33 } 32 }
34 33
35 void ManagePasswordsTest::SetUpOnMainThread() { 34 void ManagePasswordsTest::SetUpOnMainThread() {
36 AddTabAtIndex(0, GURL("http://example.com/"), ui::PAGE_TRANSITION_TYPED); 35 AddTabAtIndex(0, GURL("http://example.com/"), ui::PAGE_TRANSITION_TYPED);
37 } 36 }
38 37
39 void ManagePasswordsTest::ExecuteManagePasswordsCommand() { 38 void ManagePasswordsTest::ExecuteManagePasswordsCommand() {
(...skipping 10 matching lines...) Expand all
50 49
51 void ManagePasswordsTest::SetupManagingPasswords() { 50 void ManagePasswordsTest::SetupManagingPasswords() {
52 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); 51 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
53 std::map<base::string16, const autofill::PasswordForm*> map; 52 std::map<base::string16, const autofill::PasswordForm*> map;
54 map.insert(std::make_pair(kTestUsername, test_form())); 53 map.insert(std::make_pair(kTestUsername, test_form()));
55 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin, 54 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin,
56 nullptr); 55 nullptr);
57 } 56 }
58 57
59 void ManagePasswordsTest::SetupPendingPassword() { 58 void ManagePasswordsTest::SetupPendingPassword() {
60 password_manager::StubPasswordManagerClient client;
61 password_manager::StubLogManager log_manager;
62 password_manager::StubPasswordManagerDriver driver;
63
64 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 59 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
65 new password_manager::PasswordFormManager( 60 new password_manager::PasswordFormManager(
66 nullptr, &client, driver.AsWeakPtr(), *test_form(), 61 nullptr, &client_, driver_.AsWeakPtr(), *test_form(),
67 base::WrapUnique(new password_manager::StubFormSaver))); 62 base::WrapUnique(new password_manager::StubFormSaver), &fetcher_));
68 std::vector<std::unique_ptr<autofill::PasswordForm>> best_matches; 63 fetcher_.SetNonFederated(std::vector<const autofill::PasswordForm*>(), 0u);
69 test_form_manager->OnGetPasswordStoreResults(std::move(best_matches));
70 GetController()->OnPasswordSubmitted(std::move(test_form_manager)); 64 GetController()->OnPasswordSubmitted(std::move(test_form_manager));
71 } 65 }
72 66
73 void ManagePasswordsTest::SetupAutomaticPassword() { 67 void ManagePasswordsTest::SetupAutomaticPassword() {
74 password_manager::StubPasswordManagerClient client;
75 password_manager::StubLogManager log_manager;
76 password_manager::StubPasswordManagerDriver driver;
77
78 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( 68 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
79 new password_manager::PasswordFormManager( 69 new password_manager::PasswordFormManager(
80 nullptr, &client, driver.AsWeakPtr(), *test_form(), 70 nullptr, &client_, driver_.AsWeakPtr(), *test_form(),
81 base::WrapUnique(new password_manager::StubFormSaver))); 71 base::WrapUnique(new password_manager::StubFormSaver), &fetcher_));
72 fetcher_.SetNonFederated(std::vector<const autofill::PasswordForm*>(), 0u);
82 GetController()->OnAutomaticPasswordSave(std::move(test_form_manager)); 73 GetController()->OnAutomaticPasswordSave(std::move(test_form_manager));
83 } 74 }
84 75
85 void ManagePasswordsTest::SetupAutoSignin( 76 void ManagePasswordsTest::SetupAutoSignin(
86 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials) { 77 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials) {
87 ASSERT_FALSE(local_credentials.empty()); 78 ASSERT_FALSE(local_credentials.empty());
88 GURL origin = local_credentials[0]->origin; 79 GURL origin = local_credentials[0]->origin;
89 GetController()->OnAutoSignin(std::move(local_credentials), origin); 80 GetController()->OnAutoSignin(std::move(local_credentials), origin);
90 } 81 }
91 82
92 std::unique_ptr<base::HistogramSamples> ManagePasswordsTest::GetSamples( 83 std::unique_ptr<base::HistogramSamples> ManagePasswordsTest::GetSamples(
93 const char* histogram) { 84 const char* histogram) {
94 // Ensure that everything has been properly recorded before pulling samples. 85 // Ensure that everything has been properly recorded before pulling samples.
95 content::RunAllPendingInMessageLoop(); 86 content::RunAllPendingInMessageLoop();
96 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram); 87 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram);
97 } 88 }
98 89
99 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() { 90 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() {
100 return PasswordsClientUIDelegateFromWebContents( 91 return PasswordsClientUIDelegateFromWebContents(
101 browser()->tab_strip_model()->GetActiveWebContents()); 92 browser()->tab_strip_model()->GetActiveWebContents());
102 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698