OLD | NEW |
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 <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_command_controller.h" | 16 #include "chrome/browser/ui/browser_command_controller.h" |
15 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" | 18 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" |
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/interactive_test_utils.h" | 21 #include "chrome/test/base/interactive_test_utils.h" |
20 #include "components/autofill/core/common/password_form.h" | 22 #include "components/autofill/core/common/password_form.h" |
(...skipping 20 matching lines...) Expand all Loading... |
41 CommandUpdater* updater = browser()->command_controller()->command_updater(); | 43 CommandUpdater* updater = browser()->command_controller()->command_updater(); |
42 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | 44 EXPECT_TRUE(updater->IsCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE)); |
43 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); | 45 EXPECT_TRUE(updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE)); |
44 | 46 |
45 // Wait for the command execution to pop up the bubble. | 47 // Wait for the command execution to pop up the bubble. |
46 content::RunAllPendingInMessageLoop(); | 48 content::RunAllPendingInMessageLoop(); |
47 } | 49 } |
48 | 50 |
49 void ManagePasswordsTest::SetupManagingPasswords() { | 51 void ManagePasswordsTest::SetupManagingPasswords() { |
50 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); | 52 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); |
51 autofill::PasswordFormMap map; | 53 std::map<base::string16, const autofill::PasswordForm*> map; |
52 map.insert(std::make_pair( | 54 map.insert(std::make_pair(kTestUsername, test_form())); |
53 kTestUsername, | |
54 base::WrapUnique(new autofill::PasswordForm(*test_form())))); | |
55 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin, | 55 GetController()->OnPasswordAutofilled(map, map.begin()->second->origin, |
56 nullptr); | 56 nullptr); |
57 } | 57 } |
58 | 58 |
59 void ManagePasswordsTest::SetupPendingPassword() { | 59 void ManagePasswordsTest::SetupPendingPassword() { |
60 password_manager::StubPasswordManagerClient client; | 60 password_manager::StubPasswordManagerClient client; |
61 password_manager::StubLogManager log_manager; | 61 password_manager::StubLogManager log_manager; |
62 password_manager::StubPasswordManagerDriver driver; | 62 password_manager::StubPasswordManagerDriver driver; |
63 | 63 |
64 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( | 64 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( |
(...skipping 28 matching lines...) Expand all Loading... |
93 const char* histogram) { | 93 const char* histogram) { |
94 // Ensure that everything has been properly recorded before pulling samples. | 94 // Ensure that everything has been properly recorded before pulling samples. |
95 content::RunAllPendingInMessageLoop(); | 95 content::RunAllPendingInMessageLoop(); |
96 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram); | 96 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram); |
97 } | 97 } |
98 | 98 |
99 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() { | 99 PasswordsClientUIDelegate* ManagePasswordsTest::GetController() { |
100 return PasswordsClientUIDelegateFromWebContents( | 100 return PasswordsClientUIDelegateFromWebContents( |
101 browser()->tab_strip_model()->GetActiveWebContents()); | 101 browser()->tab_strip_model()->GetActiveWebContents()); |
102 } | 102 } |
OLD | NEW |