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