Index: components/autofill/core/browser/password_autofill_manager_unittest.cc |
diff --git a/components/autofill/core/browser/password_autofill_manager_unittest.cc b/components/autofill/core/browser/password_autofill_manager_unittest.cc |
index 73241a5ff73007612dcde40a1cd0f59a91653428..45bcfb8d677e1c1ca5eeff9fc3d47b21645967c8 100644 |
--- a/components/autofill/core/browser/password_autofill_manager_unittest.cc |
+++ b/components/autofill/core/browser/password_autofill_manager_unittest.cc |
@@ -25,6 +25,7 @@ class MockAutofillDriver : public autofill::TestAutofillDriver { |
MockAutofillDriver() {} |
MOCK_METHOD1(RendererShouldAcceptPasswordAutofillSuggestion, |
void(const base::string16&)); |
+ MOCK_METHOD1(RendererShouldPreviewPassword, void(const base::string16&)); |
}; |
} // namespace |
@@ -99,4 +100,28 @@ TEST_F(PasswordAutofillManagerTest, DidAcceptAutofillSuggestion) { |
username_field(), base::ASCIIToUTF16(kAliceUsername))); |
} |
+TEST_F(PasswordAutofillManagerTest, DidSelectAutofillSuggestion) { |
+ EXPECT_CALL(*autofill_driver(), |
+ RendererShouldPreviewPassword( |
+ base::ASCIIToUTF16(kAliceUsername))); |
+ EXPECT_TRUE(password_autofill_manager()->DidSelectAutofillSuggestion( |
+ username_field(), base::ASCIIToUTF16(kAliceUsername))); |
+ |
+ EXPECT_CALL(*autofill_driver(), |
+ RendererShouldPreviewPassword( |
+ base::ASCIIToUTF16(kInvalidUsername))).Times(0); |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectAutofillSuggestion( |
+ username_field(), base::ASCIIToUTF16(kInvalidUsername))); |
+ |
+ FormFieldData invalid_username_field; |
+ invalid_username_field.name = base::ASCIIToUTF16(kInvalidUsername); |
+ |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectAutofillSuggestion( |
+ invalid_username_field, base::ASCIIToUTF16(kAliceUsername))); |
+ |
+ password_autofill_manager()->Reset(); |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectAutofillSuggestion( |
+ username_field(), base::ASCIIToUTF16(kAliceUsername))); |
+} |
+ |
} // namespace autofill |