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

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

Issue 2473493002: [Autofill] Credit card signin promo: do not require a local suggestion first. (Closed)
Patch Set: added test Created 4 years, 1 month 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
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a188001a1338d9242262b9f49d1df2a6c83930a2..288b2a9e2ab8dcd2a8415b9138dd48cdbe07bf13 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -62,6 +62,7 @@ using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
using testing::_;
using testing::AtLeast;
+using testing::Return;
using testing::SaveArg;
namespace autofill {
@@ -1600,6 +1601,41 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonSecureContext) {
EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
}
+// Test that we will eventually return the credit card signin promo when there
+// are no credit card suggestions and the promo is active. See the tests in
+// AutofillExternalDelegateTest that test whether the promo is added.
+TEST_F(AutofillManagerTest, GetCreditCardSuggestions_OnlySigninPromo) {
+ // Enable the signin promo feature with no impression limit.
+ EnableCreditCardSigninPromoFeatureWithLimit(0);
+
+ // Make sure there are no credit cards.
+ personal_data_.ClearCreditCards();
+
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, true, false);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+ FormFieldData field = form.fields[1];
+
+ ON_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillByDefault(Return(true));
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo()).Times(2);
+ EXPECT_TRUE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ // Autocomplete suggestions are not queried.
+ MockAutocompleteHistoryManager* m = RecreateMockAutocompleteHistoryManager();
+ EXPECT_CALL(*m, OnGetAutocompleteSuggestions(_, _, _, _)).Times(0);
+
+ GetAutofillSuggestions(form, field);
+
+ // Test that we sent no values to the external delegate. It will add the promo
+ // before passing along the results.
+ external_delegate_->CheckNoSuggestions(kDefaultPageID);
+
+ EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
+}
+
// Test that we return a warning explaining that credit card profile suggestions
// are unavailable when the page is secure, but the form action URL is valid but
// not secure.
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698