Chromium Code Reviews| Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| index 02eef49a6eb142f44553ef85359279a3e24672b5..99df189b330095949c428b6f4d97087287a62c5c 100644 |
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| @@ -4,6 +4,7 @@ |
| #include <tuple> |
| +#include "base/command_line.h" |
| #include "base/macros.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| @@ -245,6 +246,17 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
| ->OnMessageReceived(msg); |
| } |
| + // Simulates the show initiall password account suggestions message being sent |
| + // to the renderer. We use that so we don't have to make |
| + // RenderView::OnShowInitialPasswordAccountSuggestions() protected. |
| + void SimulateOnShowInitialPasswordAccountSuggestions( |
| + const PasswordFormFillData& fill_data) { |
| + AutofillMsg_ShowInitialPasswordAccountSuggestions msg( |
| + 0, kPasswordFillFormDataId, fill_data); |
| + static_cast<content::RenderFrameObserver*>(autofill_agent_) |
| + ->OnMessageReceived(msg); |
| + } |
| + |
| // As above, but fills for an iframe. |
|
vabr (Chromium)
2016/06/10 14:19:51
nit: This comment refers to line 239, but looks li
jww
2016/06/10 23:06:54
Nice catch. I swapped the location of the actual f
|
| void SimulateOnFillPasswordFormForFrame( |
| WebFrame* frame, |
| @@ -1282,7 +1294,7 @@ TEST_F(PasswordAutofillAgentTest, |
| autofill::switches::kEnableFillOnAccountSelect); |
| // Simulate the browser sending back the login info. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| // Clear the text fields to start fresh. |
| ClearUsernameAndPasswordFields(); |
| @@ -1312,7 +1324,7 @@ TEST_F(PasswordAutofillAgentTest, |
| autofill::switches::kEnableFillOnAccountSelect); |
| // Simulate the browser sending back the login info. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| // Clear the text fields to start fresh. |
| ClearUsernameAndPasswordFields(); |
| @@ -1564,9 +1576,10 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnly) { |
| ClearUsernameAndPasswordFields(); |
| // Simulate the browser sending back the login info for an initial page load. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| - CheckTextFieldsState(std::string(), true, std::string(), false); |
| + CheckTextFieldsState(std::string(), false, std::string(), false); |
| + CheckSuggestions(std::string(), true); |
| } |
| TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyReadonlyUsername) { |
| @@ -1579,9 +1592,9 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyReadonlyUsername) { |
| SetElementReadOnly(username_element_, true); |
| // Simulate the browser sending back the login info for an initial page load. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| - CheckTextFieldsState(std::string("alice"), false, std::string(), true); |
| + CheckTextFieldsState(std::string("alice"), false, std::string(), false); |
| } |
| TEST_F(PasswordAutofillAgentTest, |
| @@ -1595,9 +1608,9 @@ TEST_F(PasswordAutofillAgentTest, |
| SetElementReadOnly(username_element_, true); |
| // Simulate the browser sending back the login info for an initial page load. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| - CheckTextFieldsState(std::string("Carol"), false, std::string(), true); |
| + CheckTextFieldsState(std::string("Carol"), false, std::string(), false); |
| } |
| TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyNoUsername) { |
| @@ -1621,10 +1634,11 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyNoUsername) { |
| password_element_.setAutofilled(false); |
| // Simulate the browser sending back the login info for an initial page load. |
| - SimulateOnFillPasswordForm(fill_data_); |
| + SimulateOnShowInitialPasswordAccountSuggestions(fill_data_); |
| EXPECT_TRUE(password_element_.suggestedValue().isEmpty()); |
| - EXPECT_TRUE(password_element_.isAutofilled()); |
| + EXPECT_FALSE(password_element_.isAutofilled()); |
| + CheckSuggestions(std::string(), false); |
| } |
| TEST_F(PasswordAutofillAgentTest, ShowPopupOnEmptyPasswordField) { |