| 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_command_controller.h" | 10 #include "chrome/browser/ui/browser_command_controller.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 map[kTestUsername] = test_form(); | 42 map[kTestUsername] = test_form(); |
| 43 GetController()->OnPasswordAutofilled(map); | 43 GetController()->OnPasswordAutofilled(map); |
| 44 GetController()->UpdateIconAndBubbleState(view()); | 44 GetController()->UpdateIconAndBubbleState(view()); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ManagePasswordsTest::SetupPendingPassword() { | 47 void ManagePasswordsTest::SetupPendingPassword() { |
| 48 password_manager::StubPasswordManagerClient client; | 48 password_manager::StubPasswordManagerClient client; |
| 49 password_manager::StubPasswordManagerDriver driver; | 49 password_manager::StubPasswordManagerDriver driver; |
| 50 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( | 50 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( |
| 51 new password_manager::PasswordFormManager( | 51 new password_manager::PasswordFormManager( |
| 52 NULL, &client, &driver, *test_form(), false)); | 52 NULL, &client, driver.AsWeakPtr(), *test_form(), false)); |
| 53 GetController()->OnPasswordSubmitted(test_form_manager.Pass()); | 53 GetController()->OnPasswordSubmitted(test_form_manager.Pass()); |
| 54 | 54 |
| 55 // Wait for the command execution triggered by the automatic popup to pop up | 55 // Wait for the command execution triggered by the automatic popup to pop up |
| 56 // the bubble. | 56 // the bubble. |
| 57 content::RunAllPendingInMessageLoop(); | 57 content::RunAllPendingInMessageLoop(); |
| 58 GetController()->UpdateIconAndBubbleState(view()); | 58 GetController()->UpdateIconAndBubbleState(view()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ManagePasswordsTest::SetupAutomaticPassword() { | 61 void ManagePasswordsTest::SetupAutomaticPassword() { |
| 62 password_manager::StubPasswordManagerClient client; | 62 password_manager::StubPasswordManagerClient client; |
| 63 password_manager::StubPasswordManagerDriver driver; | 63 password_manager::StubPasswordManagerDriver driver; |
| 64 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( | 64 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( |
| 65 new password_manager::PasswordFormManager( | 65 new password_manager::PasswordFormManager( |
| 66 NULL, &client, &driver, *test_form(), false)); | 66 NULL, &client, driver.AsWeakPtr(), *test_form(), false)); |
| 67 GetController()->OnAutomaticPasswordSave(test_form_manager.Pass()); | 67 GetController()->OnAutomaticPasswordSave(test_form_manager.Pass()); |
| 68 | 68 |
| 69 // Wait for the command execution triggered by the automatic popup to pop up | 69 // Wait for the command execution triggered by the automatic popup to pop up |
| 70 // the bubble. | 70 // the bubble. |
| 71 content::RunAllPendingInMessageLoop(); | 71 content::RunAllPendingInMessageLoop(); |
| 72 GetController()->UpdateIconAndBubbleState(view()); | 72 GetController()->UpdateIconAndBubbleState(view()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ManagePasswordsTest::SetupBlackistedPassword() { | 75 void ManagePasswordsTest::SetupBlackistedPassword() { |
| 76 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); | 76 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); |
| 77 autofill::PasswordFormMap map; | 77 autofill::PasswordFormMap map; |
| 78 map[kTestUsername] = test_form(); | 78 map[kTestUsername] = test_form(); |
| 79 GetController()->OnBlacklistBlockedAutofill(map); | 79 GetController()->OnBlacklistBlockedAutofill(map); |
| 80 GetController()->UpdateIconAndBubbleState(view()); | 80 GetController()->UpdateIconAndBubbleState(view()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 base::HistogramSamples* ManagePasswordsTest::GetSamples( | 83 base::HistogramSamples* ManagePasswordsTest::GetSamples( |
| 84 const char* histogram) { | 84 const char* histogram) { |
| 85 // Ensure that everything has been properly recorded before pulling samples. | 85 // Ensure that everything has been properly recorded before pulling samples. |
| 86 content::RunAllPendingInMessageLoop(); | 86 content::RunAllPendingInMessageLoop(); |
| 87 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram) | 87 return histogram_tester_.GetHistogramSamplesSinceCreation(histogram) |
| 88 .release(); | 88 .release(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 ManagePasswordsUIController* ManagePasswordsTest::GetController() { | 91 ManagePasswordsUIController* ManagePasswordsTest::GetController() { |
| 92 return ManagePasswordsUIController::FromWebContents( | 92 return ManagePasswordsUIController::FromWebContents( |
| 93 browser()->tab_strip_model()->GetActiveWebContents()); | 93 browser()->tab_strip_model()->GetActiveWebContents()); |
| 94 } | 94 } |
| OLD | NEW |