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

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

Issue 1920863006: [Autofill] Do not show Autocomplete suggestions for credit card fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: arrays... Created 4 years, 8 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/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 56af1b9f0176d839d25b90c67aa4635aa4567a91..d6b62464f2616ef9e4bb7eba45b7864954974b12 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -694,7 +694,10 @@ class TestAutofillExternalDelegate : public AutofillExternalDelegate {
suggestion_vector.push_back(suggestion2);
CheckSuggestions(expected_page_id, 3, &suggestion_vector[0]);
}
-
+ void CheckNoSuggestions(int expected_page_id) {
+ EXPECT_TRUE(on_suggestions_returned_seen());
+ CheckSuggestions(expected_page_id, 0, nullptr);
+ }
bool on_query_seen() const {
return on_query_seen_;
@@ -1510,7 +1513,7 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
// Clear the test credit cards and try again -- we shouldn't return a warning.
personal_data_.ClearCreditCards();
GetAutofillSuggestions(form, field);
- EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
+ external_delegate_->CheckNoSuggestions(kDefaultPageID);
}
// Test that we return all credit card suggestions in the case that two cards
@@ -1618,7 +1621,7 @@ TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
// Clear the test credit cards and try again -- we shouldn't return a warning.
personal_data_.ClearCreditCards();
GetAutofillSuggestions(form, field);
- EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
+ external_delegate_->CheckNoSuggestions(kDefaultPageID);
}
// Test that we return autocomplete-like suggestions when trying to autofill
@@ -3071,6 +3074,35 @@ TEST_F(AutofillManagerTest, AutocompleteSuggestions_SomeWhenAutofillEmpty) {
GetAutofillSuggestions(form, field);
}
+// Test that when Autofill is disabled and the field is a credit card field,
+// autocomplete is not queried for suggestions.
+TEST_F(AutofillManagerTest,
+ AutocompleteSuggestions_CreditCardFieldShouldNotAutocomplete) {
+ TestAutofillClient client;
+ autofill_manager_.reset(
+ new TestAutofillManager(autofill_driver_.get(), &client, NULL));
+ autofill_manager_->set_autofill_enabled(false);
+ autofill_manager_->SetExternalDelegate(external_delegate_.get());
+
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, false, false);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+ FormFieldData field = form.fields[0];
+ field.should_autocomplete = true;
+
+ // Autocomplete manager is not called for suggestions.
+ autofill_manager_->autocomplete_history_manager_.reset(
+ new MockAutocompleteHistoryManager(autofill_driver_.get(), &client));
+ MockAutocompleteHistoryManager* m =
+ static_cast<MockAutocompleteHistoryManager*>(
+ autofill_manager_->autocomplete_history_manager_.get());
+ EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0);
+
+ GetAutofillSuggestions(form, field);
+}
+
// Test that we do not query for Autocomplete suggestions when there are no
// Autofill suggestions available, and that the field should not autocomplete.
TEST_F(
@@ -4791,7 +4823,7 @@ TEST_F(AutofillManagerTest, NoCreditCardSuggestionsForNonPrefixTokenMatch) {
test::CreateTestFormField("Name on Card", "nameoncard", "lvis", "text",
&field);
GetAutofillSuggestions(form, field);
- EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
+ external_delegate_->CheckNoSuggestions(kDefaultPageID);
}
// Verify that typing "S" into the middle name field will match and order middle

Powered by Google App Engine
This is Rietveld 408576698