Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1182)

Unified Diff: components/autofill/core/browser/password_autofill_manager_unittest.cc

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per Ilya's comment. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)));
}

Powered by Google App Engine
This is Rietveld 408576698