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..298ada9406870e1c53e5ed30dcdbd11a51012f8b 100644 |
--- a/components/autofill/core/browser/password_autofill_manager_unittest.cc |
+++ b/components/autofill/core/browser/password_autofill_manager_unittest.cc |
@@ -23,8 +23,8 @@ namespace { |
class MockAutofillDriver : public autofill::TestAutofillDriver { |
public: |
MockAutofillDriver() {} |
- MOCK_METHOD1(RendererShouldAcceptPasswordAutofillSuggestion, |
- void(const base::string16&)); |
+ MOCK_METHOD1(RendererShouldFillPassword, void(const base::string16&)); |
+ MOCK_METHOD1(RendererShouldPreviewPassword, void(const base::string16&)); |
}; |
} // namespace |
@@ -75,27 +75,50 @@ class PasswordAutofillManagerTest : public testing::Test { |
PasswordAutofillManager password_autofill_manager_; |
}; |
-TEST_F(PasswordAutofillManagerTest, DidAcceptAutofillSuggestion) { |
+TEST_F(PasswordAutofillManagerTest, DidAcceptSuggestion) { |
EXPECT_CALL(*autofill_driver(), |
- RendererShouldAcceptPasswordAutofillSuggestion( |
+ RendererShouldFillPassword(base::ASCIIToUTF16(kAliceUsername))); |
+ EXPECT_TRUE(password_autofill_manager()->DidAcceptSuggestion( |
+ username_field(), base::ASCIIToUTF16(kAliceUsername))); |
+ |
+ EXPECT_CALL(*autofill_driver(), |
+ RendererShouldFillPassword( |
+ base::ASCIIToUTF16(kInvalidUsername))).Times(0); |
+ EXPECT_FALSE(password_autofill_manager()->DidAcceptSuggestion( |
+ username_field(), base::ASCIIToUTF16(kInvalidUsername))); |
+ |
+ FormFieldData invalid_username_field; |
+ invalid_username_field.name = base::ASCIIToUTF16(kInvalidUsername); |
+ |
+ EXPECT_FALSE(password_autofill_manager()->DidAcceptSuggestion( |
+ invalid_username_field, base::ASCIIToUTF16(kAliceUsername))); |
+ |
+ password_autofill_manager()->Reset(); |
+ EXPECT_FALSE(password_autofill_manager()->DidAcceptSuggestion( |
+ username_field(), base::ASCIIToUTF16(kAliceUsername))); |
+} |
+ |
+TEST_F(PasswordAutofillManagerTest, DidSelectSuggestion) { |
+ EXPECT_CALL(*autofill_driver(), |
+ RendererShouldPreviewPassword( |
base::ASCIIToUTF16(kAliceUsername))); |
- EXPECT_TRUE(password_autofill_manager()->DidAcceptAutofillSuggestion( |
+ EXPECT_TRUE(password_autofill_manager()->DidSelectSuggestion( |
username_field(), base::ASCIIToUTF16(kAliceUsername))); |
EXPECT_CALL(*autofill_driver(), |
- RendererShouldAcceptPasswordAutofillSuggestion( |
+ RendererShouldPreviewPassword( |
base::ASCIIToUTF16(kInvalidUsername))).Times(0); |
- EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion( |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectSuggestion( |
username_field(), base::ASCIIToUTF16(kInvalidUsername))); |
FormFieldData invalid_username_field; |
invalid_username_field.name = base::ASCIIToUTF16(kInvalidUsername); |
- EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion( |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectSuggestion( |
invalid_username_field, base::ASCIIToUTF16(kAliceUsername))); |
password_autofill_manager()->Reset(); |
- EXPECT_FALSE(password_autofill_manager()->DidAcceptAutofillSuggestion( |
+ EXPECT_FALSE(password_autofill_manager()->DidSelectSuggestion( |
username_field(), base::ASCIIToUTF16(kAliceUsername))); |
} |